CAPI - Class Booking
This document guides the developer on how to use CAPI services
to perform a Class Booking. The reader is advised to familiarise
himself/herself with the Class Booking process by reading
CReME™ - Class Booking
before this.
This document is divided into the following parts:
- displaying the class calendar for 7 days
-
filtering the class calendar by title
-
filtering the class calendar by trainer
-
displaying a single class instance for booking
Displaying the weekly calendar requires the programmer to populate the following:
- list of class titles
- list of trainers
- fill the calendar area with tiles for each class
- Request URI: [CAPI base address] + capi/GetClassTitlesFor7Days
- Body: ChannelKey:CEV75FGS6TA2VMYHF6G9MKV7;InputDate:2022-08-29 (there is no ";" at the end of the request)
- Response:
[
{ "ClassInstanceTitle": "FOD" },
{ "ClassInstanceTitle": "Kickboxing" },
{ "ClassInstanceTitle": "Lean Bodies" },
{ "ClassInstanceTitle": "RFC Dance Off" },
{ "ClassInstanceTitle": "RFC Pilates" },
{ "ClassInstanceTitle": "ROW out" },
{ "ClassInstanceTitle": "T3" },
{ "ClassInstanceTitle": "TRX Functional" },
{ "ClassInstanceTitle": "TRX Strength" },
{ "ClassInstanceTitle": "TRX Yoga" },
{ "ClassInstanceTitle": "TRX Yoga Flow" }
]
- Request URI: [CAPI base address] + capi/ReadMatrix
- Body: ChannelKey:CEV75FGS6TA2VMYHF6G9MKV7;MatrixName:ClassInstructors (there is no ";" at the end of the request)
- Response:
[
{
"MembershipNumber": "20012",
"GivenName": "Guru ",
"Surname": "Twoo",
"FullName": "Guru Twoo"
},
{
"MembershipNumber": "20060",
"GivenName": "Naomi ",
"Surname": "Bessant ",
"FullName": "Naomi Bessant "
},
{
"MembershipNumber": "40005",
"GivenName": "Guru ",
"Surname": "Wan ",
"FullName": "Guru Wan "
}
]
- Request URI: [CAPI base address] + capi/GetEventsFor7Days
- Body: ChannelKey:CEV75FGS6TA2VMYHF6G9MKV7;InputDate:2022-08-29 (there is no ";" at the end of the request)
- Response: (the following response has been truncated to show only two class instances. An actual response could contain fewer or more class instances)
[
{
"Id": 2881458,
"ClassInstanceTitle": "TRX Strength",
"ClassCategoryCode": "GX",
"Colour": "#FF8C00",
"ClassLayoutTitle": "4,4,4,4",
"ClassLocationTitle": "TRX Studio",
"ClubCode": "ECO",
"BitIdentifier": 1,
"LocationClubCode": "TRX Studio, ECO",
"StartTimeDayOfYear": 241,
"DaysAfterInputDate": 0,
"StartHour": 7,
"Description": "A total body, strength and conditioning workout that will have all shaking within 45 minutes! The best class to test your absolute strength paired with dynamic mobility and explosive movements to bring out the Athlete in you. Suitable from beginner to advanced athletes, this class will teach you basic TRX movements while allowing progression and regression within the same exercise.",
"StartTime": "Aug 29 2022 7:15AM",
"StartTimeYYMMDD": "2022-08-29",
"StartTimeYYMMDDTHHmmss": "2022-08-29T07:15:00",
"DurationInMinutes": 45,
"IconTitle": "TRX",
"FileName": "https://s3-ap-southeast-1.amazonaws.com/bucket.creme/icon/W1/trx.jpg",
"ClassInstructor": "Farouk Hashim ",
"Scheduler": "Naomi Bessant "
},
{
"Id": 2881463,
"ClassInstanceTitle": "T3",
"ClassCategoryCode": "GX",
"Colour": "#FCF3CF",
"ClassLayoutTitle": "Simple List 18",
"ClassLocationTitle": "Treads",
"ClubCode": "ECO",
"BitIdentifier": 1,
"LocationClubCode": "Treads, ECO",
"StartTimeDayOfYear": 241,
"DaysAfterInputDate": 0,
"StartHour": 17,
"Description": "Run. Resistance. Row. An interval training class which is designed to keep you moving from the treads to weights to rowing. Be ensured you’ll be working out to 45 minutes of heart stomping, athletic training regime moving to the beat of the hottest tracks!",
"StartTime": "Aug 29 2022 5:30PM",
"StartTimeYYMMDD": "2022-08-29",
"StartTimeYYMMDDTHHmmss": "2022-08-29T17:30:00",
"DurationInMinutes": 45,
"IconTitle": "RFC",
"FileName": "https://s3-ap-southeast-1.amazonaws.com/bucket.creme/icon/W1/RFC-logo-on-black.png",
"ClassInstructor": "William Sutton ",
"Scheduler": "Naomi Bessant "
},
]
In the example above,
Id is a unique identifier for ClassInstance.
ClassInstanceTitle is the title of ClassInstance. Only used by GX events. Blank for ST events.
ClassCategoryCode is can be "GX" (General Exercise) or "ST" (Self Training). In order to display only the GX events as shown in the calendar above, the ST events can be filtered out to show only the GX events.
Colour is the HTML code of this class in hexadecimal colour code.
ClassLayoutTitle=4,4,4,4 meaning the layout consists of 4 columns and 4 rows. A layout of 8,8,8 consists of 8 columns and 3 rows. Some are SimpleList.
ClassLocationTitle indicates where the Class will be held.
ClubCode indicates in which Club the Class will be held
BitIdentifier is a unique number denoting each Club. The section below explains how to use this parameter to filter the calendar according to Club.
LocationClubCode is a concatenation of ClassLocationTitle + ClubCode.
StartOfWeek is the first day of the week in which the class takes place. This is always a Sunday.
StartTimeDayOfYear is the day in the year that the class takes place.
DaysAfterInputDate is an integer value from 0 to 7. 0 denotes the date of the ClassInstance is the same as the InputDate. 1=the day after, 2=2 days after and so on.
StartHour is HH value of the time at which the class begins.
Description is multiline freetext describing the Class.
StartTime is the time when the class begins provided in 3 formats (StartTime, StartTimeYYMMDD, StartTimeYYMMDDTHHmmss)
DurationInMinutes is how long the class will run.
IconTitle is the name of the icon used to describe the class.
FileName is the URL of the icon.
ClassInstructor is the name of the trainer.
Scheduler is the person who created this class instance.
When Populating the Classes, the server response returns the list of classes for all clubs. If the programmer would like to filter this list to display only some clubs, there are two ways to do this:
- filter by ClubCode
- filter by BitIdentifier
Filter by Club Code can be used when the programmer would like to display the classes from one club. He/she simple chooses the ClubCode. This can also be used when the user is given a list of ClubCodes to choose from.
Filter by BitIdentifier is more powerful because it can be used to filter a single club or multiple clubs using bitwise operators. An explanation of bitwise operators can be found at JavaScript Bitwise Operators.
Each Club is assigned a unique BitIdentifier. To obtain the list of Clubs and their BitIdentifiers, the following command is issued:
- Request URI: [CAPI base address] + capi/ReadMatrix
- Body: ChannelKey:CEV75FGS6TA2VMYHF6G9MKV7;MatrixName:Current and Past Clubs (there is no ";" at the end of the request
- Response:
[
{
"Code": "ECO",
"Title": "Eco City Mall",
"BitIdentifier": 1
},
{
"Code": "EXT",
"Title": "External",
"BitIdentifier": 8
},
{
"Code": "NP",
"Title": "Non-Peak",
"BitIdentifier": 4
},
{
"Code": "ONL",
"Title": "Online",
"BitIdentifier": 2
}
]
When the programmer issues the command to populate the calendar, the server returns the classes for all the clubs.
If the programmer would like to display classes from a particular club (single club), he/she can filter the list using the BitIdentifier.
If the programmer would like to display classes from multiple clubs, he/she can total the BitIdentifiers from all the desired clubs and perform an "AND" operation on the list.
For example, if the programmer chooses to display only "ECO" and "NP", he/she totals the BitIdentifiers of these clubs (1+4=5) and performs an "AND" operation on each BitIdentifier. If the result of the "AND" operation is non-zero, that class is displayed. If the result is zero, that class will not be displayed.
When the following "AND" operations are carried out, the result is non-zero.
This means that classes from BitIdentifier=1 and BitIdentifier=4 will appear on the Calendar.
When the following "AND" operations are carried out, the result is zero.
This means that classes from BitIdentifier=2 and BitIdentifier=8 will not appear on the Calendar.