CAPI - PT2U Booking
This document guides the developer on how to use CAPI services
to perform a PT2U Booking. The reader is advised to familiarise
himself/herself with the PT2U Booking process by reading
Mobile PT2U Booking
before this.
This use case begins by displaying the list of trainers. This list is not
the complete list of trainers but the trainers of the PT2U packages this
person has purchased. the trainer calendar. This is achieved by calling
the following command:
-
Request URI: [base address] + v2/TrainerCalendar/PT/GetPersonalTrainers
-
Body:
ChannelKey:UW7JV6YGBKGZ3EZ9EJQBKNTZ;SessionKey:GVBWTUPXFTGXMJZ45LW2KERG;PTtype:PT2U
(there is no ";" at the end of the body)
- Response:
{
"Code": "86.104.0",
"Description": "Single Personal Trainer found in PCRPT",
"Payload": "1",
"SerializedData":
"{\"BufferAfterTrainingEnds\":0,\"BufferBeforeTrainingBegins\":0,\"Days\":[],\"EmailAddressTrainer\":\"instructor4@bizt.my\",\"GivenNameTrainer\":\"Guru
\",\"Location\":null,\"PersonCreditId\":0,\"PersonIdTrainer\":0,\"PersonalTrainers\":[],\"SurnameTrainer\":\"Ampat
\",\"TrainingIntervalInMinutes\":0}"
If the above information were to be deserialised, it would be as follows.
The important information required from this response is
"EmailAddressTrainer", "GivenNameTrainer" and "SurnameTrainer". The other
fields can be ignored.
{
BufferAfterTrainingEnds:0,
BufferBeforeTrainingBegins:0,
Days:
[
],
EmailAddressTrainer:instructor4@bizt.my,
GivenNameTrainer:Guru,
Location:null,
PersonCreditId:0,
PersonIdTrainer:0,
PersonalTrainers:[],
SurnameTrainer:Ampat,
TrainingIntervalInMinutes:0
}
The above response contains only one trainer. If there is more than one
trainer, you will want to allow the user to choose which trainer he/she
wants to book a PT session with.
In this case, since there is only one trainer, we can make the choice for
the user and proceed to get the trainer calendar showing the calendar
gaps.
-
Request URI: [base address] + v2/TrainerCalendar/PT/GetCalendar
-
Body:
ChannelKey:UW7JV6YGBKGZ3EZ9EJQBKNTZ;SessionKey:37C5LUBCZBBDXFW4H8BTMWGW;EmailAddressTrainer:instructor4@bizt.my;InputDate:2021-8-31;PTtype:PT2U
(there is no ";" at the end of the body)
- Response:
}
If one were to deserialise the data, it would as follows:
{
Code: null,
Description: Calendar successfully read,
Payload: 4,
SerializedData:
{
BufferAfterTrainingEnds:60,
BufferBeforeTrainingBegins:60,
Days:
[
{
Date:2021-08-31T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-01T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-02T00:00:00,
Gaps:
[
{
Type:gap,
StartTime:2021-09-02T07:00:00,
EndTime:2021-09-02T14:00:00,
IntervalInMinutes:420,
DaysAfterStartOfWeek:2,
WeeksAfterStartDate:0
}
]
},
{
Date:2021-09-03T00:00:00,
Gaps:
[
{
Type:gap,
StartTime:2021-09-03T06:00:00,
EndTime:2021-09-03T10:00:00,
IntervalInMinutes:240,
DaysAfterStartOfWeek:3,
WeeksAfterStartDate:0
},
{
Type:gap,
StartTime:2021-09-03T12:00:00,
EndTime:2021-09-03T16:00:00,
IntervalInMinutes:240,
DaysAfterStartOfWeek:3,
WeeksAfterStartDate:0
}
]
},
{
Date:2021-09-04T00:00:00,
Gaps:
[
{
Type:gap,
StartTime:2021-09-04T11:00:00,
EndTime:2021-09-04T19:00:00,
IntervalInMinutes:480,
DaysAfterStartOfWeek:4,
WeeksAfterStartDate:0
}
]
},
{
Date:2021-09-05T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-06T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-07T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-08T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-09T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-10T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-11T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-12T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-13T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-14T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-15T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-16T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-17T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-18T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-19T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-20T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-21T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-22T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-23T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-24T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-25T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-26T00:00:00,
Gaps:
[
]
},
{
Date:2021-09-27T00:00:00,
Gaps:
[
]
}
],
EmailAddressTrainer:null,
GivenNameTrainer:Guru ,
Location:The Cruise, Bandar Puteri, Puchong,
PersonCreditId:2084431,
PersonIdTrainer:20481,
PersonalTrainers:[],
SurnameTrainer:Ampat ,
TrainingIntervalInMinutes:45
}
This section explains the important parts of the Response.
Description should be "Calendar successfully read". Any other
description indicates an error.
Payload indicates how many gaps are present in the Trainer
calendar
Because the training is conducted outside of the club, some time is
allocated for the trainer to travel to and from the training address.
There are two buffers for this purpose.
BufferBeforeTrainingBegins is the buffer before training
begins.BufferAfterTrainingEnds is the buffer after the training
ends.
The Trainer calendar consists of an array ofDays. Each day has
a unique Date value and an array of Gaps. Each day
can have zero gaps, 1 gap or multiple gaps.
Now we explain the attributes of each gap. The StartTime and
EndTime indicated the beginning and the conclusion of the gap.
The interval between these two points appears as
IntervalInMinutes. WeeksAfterStartDate is zero
during the first week of the calendar, one during the second week etc. The
Sunday of each week has DaysAfterStartOfWeek equals to zero,
Monday=1, Tuesday=2 and so on. Saturday=6.
After the user selects a gap, he/she is given a list of possible start
times. The earliest start time for a training session cannot be earlier
than [StartOfGap]+[BufferBeforeTrainingBegins]. For example, if a gap
starts at 06:00 and the buffer is 60 minutes, the earliest start time to
offer the user is 07:00.
Also, a training session cannot end later than [EndOfGap] minus
[BufferAfterTrainingEnds]. This means if the gap ends at 12:00, the latest
training session that can be scheduled is 13:00.
In the mobile app, the suggested start times are displayed in 15 minute
increments. This is not a rule. The developer is free to choose his/her
own interval such as every 5 minutes (07:00, 07:05, 07:10 etc) or every 30
minutes (07:00, 07:30, 08:00 etc).
Toward the end of the Response, some more attributes are found.
The important ones are Location (The Cruise, Bandar Puteri, Puchong,),
PersonCreditId (2084431), PersonIdTrainer (20481),
TrainingIntervalInMinutes (45). Location will not be required
by CReME™ in future but is provided here so the user can be reminded
where the training will be conducted.
After the user selects the start time, the next screen in the mobile app
displays the session information. When the user clicks the "Confirm"
button, the following request is made:
-
Request URI: [base address] + v2/TrainerCalendar/PT/CreateSession
-
Body:
ChannelKey:UW7JV6YGBKGZ3EZ9EJQBKNTZ;SessionKey:DWLMEVYWPPCADH7F5GPADW8K;PersonCreditId:2084431;ClubCode:
;StartTime:20210902T081500;PersonIdTrainer:20481 (there is no ";" at the
end of the body)
- Response:
{
"Code":"",
"Description":"Personal Training successfully created",
"Payload":"Sep 2 2021 8:15AM",
"SerializedData":null
}