Aug
Integrate API for Restaurants Booking : Book A Table
Book a table is a third-party API with soap requests/responses. That is used for restaurant booking. Before booking a restaurant, booking a table API checks the availability of the restaurant by providing the time and session of the user. Book a table and provide all the details of a restaurant with special offers.
Below are the following steps of API integration services with the restaurant booking process in cakePHP.
Book A Table API Integration:
For integrating Book a table api with php, create a class for WSDL request /response with Languages, Partner Code.
$SoapClient = new SoapClient("https://book.livebookings.net/webservices/external/service.asmx?WSDL", array("trace" => 1, "exception" => 0, "Languages"=>”en-GB” ,"PartnerCode"=>”YOUR PARTNER CODE”,"CountryCode"=>"GBR"));
Listing of Restaurants:
For getting the list of all restaurants Bookatable provides getRestaurants api.
$requestObject = array( "RegionCode " => “GBR”, "MaximumResults " => “1000” ); $SoapClient ->GetRestaurants($requestObject); Getting Details For Getting detailed information of a single restaurant bookatable provide GetRestaurantDetail. $requestObject = array( “Id” =>”BookTableId” ); $SoapClient ->GetRestaurantDetail( $requestObject);
Restaurant Booking
Before booking any restaurant, book a table check the table availability of the table with the given details (number of people, date, time and session).
a) Search Availability
To check the table availability, we use Search Availability API.
$requestObject = array( "SessionId" => Session, "DiningDateAndTime" => DateTime, "Size" => PartySize, "RestaurantInternalIds" => BookTableID, "ReturnPromotions" => true, ); $SoapClient -> SearchAvailability( $requestObject);
Search availability api provides two types of responses one is called non – Promotions, and the second is Promotions.
Non – Promotions: – Non – Promotions are normal availability of a restaurant.
Promotions:- Restaurant availability with special offers. We get an available time by the given promotion id.
b) Prepare Book Reservation
Make a reservation for an available time returned by SearchAvailability and prepare by calling PrepareBookReservation. Before BookReservation, PrepareBookReservation should be called to validate that the selected time is still valid.
$prepareBookRequest = array( "SessionId" => Session, "DiningDateAndTime" => DateTime, "Size" => (int) PartySize, "RestaurantLocationId" => (int) BookTableID, "CorrelationData" => cdata, ); $SoapClient ->PrepareBookReservation( $prepareBookRequest);
If the User checks PrepareBookReservation for any promotional offers, then we pass PromotionId in the request array.
C) Book Reservation
Book reservation is the final step for booking any restaurant using the Book a table API. This is a request array that is used to book a restaurant.
$bookReservationRequest = array( "SessionId" =>Session, "DiningDateAndTime" =>DateTime, "Size" => (int) PartySize, "RestaurantLocationId" => (int) $ BookTableID, "CorrelationData" => Date, "Booker" => $booker, "CancelLink" => "cancel-reservation", "SuppressCustomerConfirmations" => false, "SuppressRestaurantConfirmations" => true, // "SpecialRequests"=> if restaurant allows special requests, seen when preparing booking, this can be added here "GuestAcceptsEmailMarketingFromRestaurant" => false, ); Array $booker is hold all information about the use likes as: $booker = array( "UserWithoutALogin" => array( "FirstName" => “FirstName”, "LastName" =>”LastName”, "EMail" => “example@gmail.com”, "MobilePhoneNumber" =>” MobilePhoneNumber”, "Title" =>” Title”, ), ); $SoapClient ->BookReservation ($bookReservationRequest);
After completing the booking, book a table and provide ReservationId, transaction_id and AllowedToCancelOnline.
D) Cancel Reservation
For cancelling any restaurant booking, we user the Cancel Reservation API.
$requestObject = array( "ReservationId" => “ReservationId” "SuppressCustomerConfirmations" => false, "SuppressRestaurantConfirmations" => true, ); $SoapClient ->CancelReservation($bookReservationRequest);
That’s all about a complete reservation system by bookatable API in cakePHP 3.0. Contact us if you want to implement a restaurant booking API in your application. API integration service providers like Ficode are helping businesses with custom API integrations and third-party API development, ensuring seamless connectivity and enhanced functionality for their applications. If you are looking for an API integration management platform that offers enterprise-level capabilities, you can connect with us.