Skip to content

Models

SportBot returns centres, activities and slots as frozen dataclasses. All three can be imported from pysportbot.

Centre dataclass

A sports centre that uses Resasports.

Attributes:

Name Type Description
slug str

The identifier to pass to SportBot.login().

name str

The display name.

town str | None

The town, if listed.

country str | None

The country, if listed.

address str | None

The street address, if listed.

Activity dataclass

An activity offered by the centre, such as a class.

Attributes:

Name Type Description
id int

The activity ID.

name str

The name to pass to SportBot.daily_slots(), SportBot.book() and SportBot.cancel().

category_id int

The ID of the activity's category.

from_listing classmethod

from_listing(data: Mapping[str, Any]) -> Self | None

Build an activity from one entry of the activities list, or return None if it cannot be booked: archived, a course, or not bookable online.

Raises:

Type Description
APIError

If a field is missing or not an integer where one is expected.

Slot dataclass

One scheduled session of an activity.

Attributes:

Name Type Description
id int

The slot ID, which booking and cancelling send to the API.

activity_id int

The ID of the activity.

activity_name str

The name of the activity.

category_id int

The ID of the activity's category.

start datetime

The start time, time zone aware, in the bot's time zone. The API sends local times without a UTC offset, so a time in the hour skipped or repeated by a DST change gets the offset in effect before it.

end datetime

The end time, time zone aware, in the bot's time zone.

capacity int

The total number of places.

inscribed int

The number of places already taken.

waiting_list int

The number of people on the waiting list.

cancelled bool

Whether the session is cancelled.

trainer str | None

The trainer's name, if listed.

is_full property

is_full: bool

Whether no places are left.

available property

available: int

The number of places left.