CreateAthletes
CreateAthletes(athletes: List[NewAthletes])
Description
Create athletes for your account. Up to 500 at one time.
Parameters
athletes
: (list) A list of Athletes with class of NewAthlete
, which requires a "name". If other parameters are left, they will assume default values.
Classes
NewAthlete
: (class)
REQUIRED
* name: str
* active: str
Optional
* teams: list
* groups: list
* external: dict {externalName1 : externalValue1, externalName2 : externalValue2}
Returns
A list of AthleteResult objects indicating the success or failure of each athlete creation.
- successful: list of names of athletes added successfully
- failures: list of athletes that failed in execution, grouped by their reason for failure.
Raises
Exception
- No Access Token Found.
- If the HTTP response status is not 200, indicating an unsuccessful API request, or if there is a failure in parsing the JSON response.
Example
from hdforce import CreateAthletes, NewAthlete
# Create list of athletes to add using NewAthlete class
players = [
NewAthlete(name= "New Guy", active=False, teams=[], groups=[], external={"Title": "Younger Brother"}),
NewAthlete(name= "Old Guy", active=False, teams=[], groups=[], external={"Title": "Older Brother"})
]
# Create players
newRoster = CreateAthletes(athletes = players)
# Print lgCreation Response
print(newRoster)
output
{ "successful": ["New Guy", "Old Guy"], "failures": [] }