Tai Lieu Api - Booking
Tai Lieu Api - Booking
List of function:
1. Auth - CreateToken
2. Booking - GetBookingIds
3. Booking - GetBooking
4. Booking - CreateBooking
5. Booking - UpdateBooking
6. Booking - PartialUpdateBooking
7. Booking - DeleteBooking
1. Auth - CreateToken
Creates a new auth token to use for access to the PUT and DELETE /booking
POST: https://restful-booker.herokuapp.com/auth
{
"username" : "admin",
"password" : "password123"
}
Header
Field Type Description
Content-Type required string Sets the format of payload you are sending
Default value: application/json
Request body
Field Type Description
token String
Token to use in future requests
● Response:
HTTP/1.1 200 OK
{
"token": "abc123"
}
GET: https://restful-booker.herokuapp.com/booking
Success 200
Field Type Description
● Response:
HTTP/1.1 200 OK
[
{
"bookingid": 1
},
{
"bookingid": 2
},
{
"bookingid": 3
},
{
"bookingid": 4
}
]
3. A Booking - GetBooking
Returns a specific booking based upon the booking id provided
GET: https://restful-booker.herokuapp.com/booking/id
Header
Field Type Description
Accept required string Sets what format the response body is returned
in. Can be application/json or application/xml
Url Parameter
Field Type Description
Success 200
Field Type Description
● Response:
HTTP/1.1 200 OK
{
"firstname": "Sally",
"lastname": "Brown",
"totalprice": 111,
"depositpaid": true,
"bookingdates": {
"checkin": "2013-02-23",
"checkout": "2014-10-23"
},
"additionalneeds": "Breakfast"
}
4. Booking - CreateBooking
Creates a new booking in the API
POST: https://restful-booker.herokuapp.com/booking
{
"firstname" : "Jim",
"lastname" : "Brown",
"totalprice" : 111,
"depositpaid" : true,
"bookingdates" : {
"checkin" : "2018-01-01",
"checkout" : "2019-01-01"
},
"additionalneeds" : "Breakfast"
}
Header
Field Type Description
Content-Type required string Sets the format of payload you are sending. Can
be application/json or text/xml
Accept required string Sets what format the response body is returned
in. Can be application/json or application/xml
Request body
Field Type Description
firstname required String Firstname for the guest who made the
booking
lastname required String Lastname for the guest who made the
booking
totalprice required Number The total price for the booking
depositpaid required Boolean Whether the deposit has been paid or not
Success 200
Field Type Description
● Response:
HTTP/1.1 200 OK
{
"bookingid": 1,
"booking": {
"firstname": "Jim",
"lastname": "Brown",
"totalprice": 111,
"depositpaid": true,
"bookingdates": {
"checkin": "2018-01-01",
"checkout": "2019-01-01"
},
"additionalneeds": "Breakfast"
}
}
5. Booking - UpdateBooking
Updates a current booking
PUT: https://restful-booker.herokuapp.com/booking/id
{
"firstname" : "James",
"lastname" : "Brown",
"totalprice" : 111,
"depositpaid" : true,
"bookingdates" : {
"checkin" : "2018-01-01",
"checkout" : "2019-01-01"
},
"additionalneeds" : "Breakfast"
}
Header
Field Type Description
Content-Type required string Sets the format of payload you are sending. Can
be application/json or text/xml
Accept required string Sets what format the response body is returned
in. Can be application/json or application/xml
Default value:
token=YWRtaW46cGFzc3dvcmQxMjM
Request body
Field Type Description
firstname required String Firstname for the guest who made the booking
lastname required String Lastname for the guest who made the booking
depositpaid optional Boolean Whether the deposit has been paid or not
Success 200
Field Type Description
firstname String Firstname for the guest who made the
booking
● Response:
HTTP/1.1 200 OK
{
"firstname" : "James",
"lastname" : "Brown",
"totalprice" : 111,
"depositpaid" : true,
"bookingdates" : {
"checkin" : "2018-01-01",
"checkout" : "2019-01-01"
},
"additionalneeds" : "Breakfast"
}
6. Booking - PartialUpdateBooking
Updates a current booking with a partial payload
PATCH: https://restful-booker.herokuapp.com/booking/id
{
"firstname" : "James",
"lastname" : "Brown"
}
Header
Field Type Description
Content-Type required string Sets the format of payload you are sending. Can
be application/json or text/xml
Accept required string Sets what format the response body is returned
in. Can be application/json or application/xml
Request body
Field Type Description
firstname required String Firstname for the guest who made the
booking
lastname required String Lastname for the guest who made the
booking
depositpaid optional Boolean Whether the deposit has been paid or not
Success 200
Field Type Description
firstname String Firstname for the guest who made the
booking
● Response:
HTTP/1.1 200 OK
{
"firstname" : "James",
"lastname" : "Brown",
"totalprice" : 111,
"depositpaid" : true,
"bookingdates" : {
"checkin" : "2018-01-01",
"checkout" : "2019-01-01"
},
"additionalneeds" : "Breakfast"
}
7. Booking - DeleteBooking
Returns the ids of all the bookings that exist within the API. Can take optional query strings
to search and return a subset of booking ids.
DELETE: https://restful-booker.herokuapp.com/booking/id
Header
Field Type Description
Url Parameter
Field Type Description
Success 204
Field Type Description