Book a class
The scenario is as follows: an application for club members displays the weekly schedule and allows them to book a spot in a class and cancel it.
Before you start
Let’s make sure we’re using the same terminology.
Contact
This is the customer who wants to make a booking. To avoid confusion with their potential status (prospect, member, former member ...), we will simply call them contact in this document.
Activity
This is the type of exercises practiced during a fitness class.
Studio
This is the physical location where the class takes place. A club can have multiple studios, and each studio is linked to a club.
Understanding calendars
A calendar groups different classes, and one class can belong to multiple calendars. These are different views of the available classes.
For example, a cycling class held in studio 1 of the Paris 18th club with coach John will appear in the following calendars:
- the cycling calendar
- the studio 1 calendar
- John’s calendar
Note that there is no calendar tied to the club itself. To do so, you must query all calendars for the club’s studios.
Querying classes for a given period
Before booking, it is common to display the list of classes scheduled for a given period. You can therefore query either a complete list or a partial view related to specific calendars.
Make a GET request to the Resamania API as follows:
https://{api_base_url}/{client_token}/events?startedAt={started_at}&endedAt={ended_At}&calendars[]={calendar_id}
See the table below for query parameters:
parameter | description |
---|---|
api_base_url | The API URL you want to use. This varies between integration and production environments |
client_token | Each club chain has a unique Resamania identifier called client_token |
started_at | Start date and time (inclusive). Format YYYY-MM-ddTHH:mm:ss, e.g. 2019-09-30T00:00:00 |
ended_at | End date and time (inclusive). Format YYYY-MM-ddTHH:mm:ss, e.g. 2019-09-30T24:00:00 |
calendars[] | List of calendars to query. A calendar is identified by the textual ID of its resource. For example, for a coach: /{client_token}/coaches/{id} |
Getting activities
When displaying the schedule, querying the activity reference is essential.
Make a GET request to the Resamania API as follows:
https://{api_base_url}/{client_token}/activities?archived=true
parameter | description |
---|---|
api_base_url | The API URL you want to use. This varies between integration and production environments |
client_token | Each club chain has a unique Resamania identifier called client_token |
archived | Include archived activities (false by default) |
Getting studios
Just like activities, querying the studio reference is unavoidable.
Make a GET request to the Resamania API as follows:
https://{api_base_url}/{client_token}/studios
Getting coaches
The last unavoidable reference when working with calendars is the list of coaches.
Make a GET request to the Resamania API as follows:
https://{api_base_url}/{client_token}/coaches
Booking a class
Once the class is identified, the contact’s participation must be declared. The booking will automatically be placed depending on availability:
- in the main attendee list
- in the waitlist, which overflows from the main list
- in the rejection list once the waitlist is full
It is possible to predict placement with the class data.
Make a POST request to the Resamania API as follows:
https://{api_base_url}/{client_token}/attendees/
Body
{
"classEvent": "{class_event_id}",
"contactClubId": "{club_id}",
"contactCreatedAt": "{created_at}",
"contactFamilyName": "{family_name}",
"contactGivenName": "{given_name}",
"contactId": "{contact_id}",
"contactNumber": "{contact_number}",
"contactPictureId": "{picture_id}"
}
parameter | description |
---|---|
api_base_url | The API URL you want to use. This varies between integration and production environments |
client_token | Each club chain has a unique Resamania identifier called client_token |
class_event_id | Textual identifier of the class to book. Format: /{client_token}/class_events/{id} |
club_id | Textual identifier of the contact’s club |
created_at | Creation date of the contact participating in the class |
family_name | Last name of the contact |
given_name | First name of the contact |
contact_id | Textual identifier of the contact |
contact_number | Membership number of the contact |
picture_id | Textual identifier of the contact’s profile picture |
Canceling a booking
Canceling a booking means changing its state, not deleting it “physically.”
Make a POST request to the Resamania API as follows:
https://{api_base_url}/{client_token}/attendees/{attendee_id}/transitions
Body
{
"transition": "cancel"
}
parameter | description |
---|---|
api_base_url | The API URL you want to use. This varies between integration and production environments |
client_token | Each club chain has a unique Resamania identifier called client_token |
attendee_id | Identifier of the booking to cancel |
List of possible errors
During the booking and cancellation process, several business rules configured by the client may prevent booking or cancellation. Here is the list of error codes you may encounter and their definitions:
Error code | Description |
---|---|
api.error.attendee.event-in-the-past | The class start date has already passed |
api.error.attendee.already-attending | You are already registered for the class |
api.error.attendee.contact-attendees-blocked | You are no longer allowed to book |
api.error.attendee.contact-debt | Booking impossible because you have an outstanding debt |
api.error.attendee.no-units | You don’t have a booklet |
api.error.attendee.no-valid-counter-credit | You don’t have a booklet for this event with enough credits |
api.error.attendee.no-valid-counter-type | You don’t have a booklet matching this event |
api.error.attendee.no-valid-tag | You don’t have a membership matching this event |
api.error.attendee.is-suspended | Booking impossible because your membership is suspended on this date |
api.error.attendee.limit-reached | No more spots available for this event |
api.error.attendee.limit | You have exceeded the allowed number of bookings |
api.error.attendee.anticipation | The anticipation period is not respected |
api.error.attendee.automatic-reject | The class does not accept bookings |
api.error.attendee.club-restriction | You don’t have a membership or booklet allowing you to book a class in this club |
api.error.attendee.coach-restriction | You don’t have a membership or booklet allowing you to book a class with this coach |
api.error.attendee.deadline | The deadline is not respected |
api.error.attendee.delay-exceed | The cancellation deadline is not respected |
api.error.attendee.missing-mandate | Booking impossible because you don’t have a valid mandate |
api.error.attendee.no-counters-with-rule | You don’t have a booklet matching this event |
api.error.attendee.no-tags-with-rule | You don’t have a membership matching this event |
api.error.attendee.no-tags | You don’t have a membership |
api.error.attendee.online.limit | Online booking limit reached |
api.error.attendee.period-restriction | The time restriction is not respected |
api.error.attendee.studio-restriction | You cannot book this event |
api.error.attendee.tags-and-counters | You don’t have a membership or a booklet |
api.error.attendee.tags-or-counters | You have neither a valid membership nor a booklet for booking |
api.error.attendee.unable-to-debit | Unable to debit the booklet(s) at this time |