Holdsport¶
pyholdsport.Holdsport
¶
Class for interacting with Holdsport.
__init__(holdsport_username: str | None = None, holdsport_password: str | None = None, *, timeout: float = 30.0, client: httpx2.Client | None = None) -> None
¶
Initialization of the Holdsport object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
holdsport_username
|
str | None
|
The Holdsport login username. If not specified environment variable HOLDSPORT_USERNAME will be used. If neither are set, an exception will be raised. |
None
|
holdsport_password
|
str | None
|
The Holdsport login password. If not specified environment variable HOLDSPORT_PASSWORD will be used. If neither are set, an exception will be raised. |
None
|
timeout
|
float
|
The timeout in seconds for requests. Only used when |
30.0
|
client
|
Client | None
|
The httpx2 client to use for requests. If not provided, a client is
created using |
None
|
close() -> None
¶
Close the httpx2 client if this instance created it, otherwise do nothing.
__enter__() -> Self
¶
Enter the context manager.
__exit__(*args: object) -> None
¶
Exit the context manager by closing any client owned by this instance.
get_teams() -> list[HoldsportTeam]
¶
Return a list of HoldsportTeam objects the user is member of.
Returns:
| Type | Description |
|---|---|
list[HoldsportTeam]
|
list[HoldsportTeam]: List of teams the user is member of. |
Raises:
| Type | Description |
|---|---|
HTTPStatusError
|
If the request fails. |
get_members(team_id: int) -> list[HoldsportMember]
¶
Return a list of HoldsportMember objects for the requested team.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_id
|
int
|
The id of the team. |
required |
Returns:
| Type | Description |
|---|---|
list[HoldsportMember]
|
list[HoldsportMember]: List of members in the requested team. |
Raises:
| Type | Description |
|---|---|
HTTPStatusError
|
If the request fails. |
get_member(team_id: int, member_id: int) -> HoldsportMember | None
¶
Return a HoldsportMember object for the requested team and member id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_id
|
int
|
The id of the team. |
required |
member_id
|
int
|
The id of the member. |
required |
Returns:
| Type | Description |
|---|---|
HoldsportMember | None
|
HoldsportMember | None: The requested member, or None if the member is not found. |
Raises:
| Type | Description |
|---|---|
HTTPStatusError
|
If the request fails. |
get_activities(team_id: int, date: str | None = None, page: int = 1, per_page: int = 20) -> list[HoldsportActivity]
¶
Return a list of HoldsportActivity objects for the requested team.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_id
|
int
|
The id of the team. |
required |
date
|
str | None
|
The inclusive starting date to query activities from, in YYYY-MM-DD format. If not defined today is used. |
None
|
page
|
int
|
The page number to query. Defaults to 1. API default is 1. |
1
|
per_page
|
int
|
The number of activities to query. Defaults to 20. API default is 20, maximum is 100. |
20
|
Returns:
| Type | Description |
|---|---|
list[HoldsportActivity]
|
list[HoldsportActivity]: List of activities in the requested team. |
Raises:
| Type | Description |
|---|---|
HTTPStatusError
|
If the request fails. |
get_activity(team_id: int, activity_id: int) -> HoldsportActivity | None
¶
Return a HoldsportActivity object for the requested team and activity id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_id
|
int
|
The id of the team. |
required |
activity_id
|
int
|
The id of the activity. |
required |
Returns:
| Type | Description |
|---|---|
HoldsportActivity | None
|
HoldsportActivity | None: The requested activity, or None for HTTP 404 or an empty response. The API may also use HTTP 404 for an activity the user cannot access. |
Raises:
| Type | Description |
|---|---|
HTTPStatusError
|
If the request fails with a status other than HTTP 404. |
get_activities_users(activity_id: int) -> list[HoldsportActivitiesUser]
¶
Return a list of HoldsportActivitiesUser objects for the requested activity.
This endpoint omits nonresponders that may appear with Unknown status in
an activity's embedded activities_users list. It is not a complete team roster.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
activity_id
|
int
|
The id of the activity. |
required |
Returns:
| Type | Description |
|---|---|
list[HoldsportActivitiesUser]
|
list[HoldsportActivitiesUser]: List of users in the requested activity. |
Raises:
| Type | Description |
|---|---|
HTTPStatusError
|
If the request fails. |