Skip to content

Bookings Create

Brad Ploeger edited this page Apr 3, 2019 · 5 revisions

Services \ Bookings \ Create

Purpose

Create a new booking.

Basic Usage:

$rezdyApi->bookings->create($request);

Required Parameters

Optional Parameters

  • none

Returns

Throws (with errors)

Code Example

use Rezdy\RezdyAPI;
use Rezdy\Requests\Booking;
use Rezdy\Requests\Customer;
use Rezdy\Requests\Objects\BookingItem;
use Rezdy\Requests\Objects\BookingItemQuantity;

// Initialize the API
$rezdyAPI = new RezdyAPI('your api key');

$bookingParams = [	
   'comments' => 'Created From API',
   'internalNotes' => 'Created From API' ];
		
$customerParams =[
   'firstName' => 'John',
   'lastName' => 'Doe',
   'email' => 'john.doe@email.com' ];

$itemParams = [	
   'productCode' => 'P12345',
   'startTimeLocal' => '2019-03-27 17:00:00' ];

$quantityParams = [
   'optionLabel' => 'Quantity',
   'value' => 5 ];

// Create the Booking request
$booking = new Booking($bookingParams);  

// Create a Customer request
$customer = new Customer($customerParams); 

// Create a BookingItem request
$item = new BookingItem($itemParams); 

// Create the BookingItemQuantity request
$quantity = new BookingItemQuantity($quantityParams);  	   

// Attach the BookingItemQuantity request to the BookingItem request
$item->attach($quantity); 

// Attach the BookingItem request to the Booking request
$booking->attach($item); 

// Attach the Customer request to the Booking request
$booking->attach($customer);  

// Turn off customer notifications
$booking->set(['sendNotifications' => false]);  

// Send the Booking request to the API
$response = $rezdyAPI->bookings->create($booking);

// View the response
echo $response;

Clone this wiki locally