Bookings

In this section we will see how to manage the bookings of your properties.

Get the bookings

URL: https://api.bookingbnb.com/xrws/GetBookings/

To get the bookings, use the following function:

GetBookings(user, password, token, propertyID)

The arguments user and password are the credentials that a partner uses to enter the BookingBnb Control Panel. The argument token is the one our partners acquire when they register to our system. The argument propertyID is the identification number of the current property. To retrieve this ID, use the BookingBnb function GetProperties.

Here is an example of how your code should be:


/** java /*	
public String GetBookings(String username, String password, String token, Int propertyID) throws Exception {
  Vector params = new Vector();
  params.addElement(username);
  params.addElement(password);
  params.addElement(token);
  params.addElement(propertyID);
  Object[] objects = (Object[]) xmlRpcClient.execute(config, "GetBookings", params);
  return (String) objects[1];
}

/* php */
<?php
include("xmlrpc.inc");
$server = new xmlrpc_client($url);
$args = array(
	new xmlrpcval($user, 'string'), 
	new xmlrpcval($pass, 'string'), 
	new xmlrpcval($token, 'string'), 
	new xmlrpcval($propertyID, 'int')
);
$message = new xmlrpcmsg('xrws.GetBookings', $args);
$result = $server->send($message);
$struct = $result->value();
?>

This function returns the list of bookings, identified by a ID. The bookings are represented by a <tag>value</tag> structure. This is an example:


<bookings>
	<booking>
		<id>19348378</id>
		<status>confirmed</status>
		<start>2019-08-03</start>
		<end>2019-08-10</end>
		<condCancel>d15,%30;d7,%70</condCancel>
		<condPay>tp,%100;</condPay>
		<adults>4</adults>
		<children>0</children>
		<price>700</price>
		<confirmationDate format="Y-m-d H:i:s e">2019-02-23 18:06:01 UTC</confirmationDate>
		<board>Breakfast</board>
		<unit>
			<id>1</id>
			<name>Ocean Villa</name>
		</unit>
		<booker>
			<name>John</name>
			<surname>Doe</surname>
			<address>14 Even Rd., Norwalk, CT 06850, United States</address>
			<city>Norwalk</city>
			<country>USA</country>
			<email>doe@example.com</email>
			<tel>+123456789</tel>
		</booker>
	</booking>
<bookings>

Create new bookings

URL: https://api.bookingbnb.com/xrws/CreateBookings/

To create a new booking, use the following function:

CreateBookings(user, password, token, propertyID, bookings)

The parameter bookings must be a string encoded in a precise format (in the next paragraph you will see how). Here are examples of how your code should be:


/** java /*	
public String CreateBookings(String username, String password, String token, Int propertyID, String bookings) throws Exception {
  Vector params = new Vector();
  params.addElement(username);
  params.addElement(password);
  params.addElement(token);
  params.addElement(propertyID);
  params.addElement(bookings);
  Object[] objects = (Object[]) xmlRpcClient.execute(config, "CreateBookings", params);
  return (String) objects[1];
}

/* php */
<?php
include("xmlrpc.inc");
$server = new xmlrpc_client($url);
$args = array(
	new xmlrpcval($user, 'string'), 
	new xmlrpcval($pass, 'string'), 
	new xmlrpcval($token, 'string'), 
	new xmlrpcval($propertyID, 'int'),
	new xmlrpcval($bookings, 'string')
);
$message = new xmlrpcmsg('xrws.CreateBookings', $args);
$result = $server->send($message);
$struct = $result->value();
?>

How to correctly encode the bookings

Given a multi-dimensional array of bookings, that your system will produce, you must include the following parameters:

  • status is the status of the current booking, it can be confirmed || cancelled || pending || awaiting payment
  • unitID is the identifier of the booked unit
  • start is the staring date of the current booking
  • end is the ending date of the current booking
  • condCancel is the string referring to the cancellation conditions applied at the moment of booking (see Cancellation Conditions)
  • condPay is the string referring to the payment conditions applied at the moment of booking (see Payment Conditions)
  • adults is the number of adults
  • children is the number of children
  • price is the accommodation price
  • price is the accommodation price
  • services is the string referring to the serviceID and the number of services chosen for the current booking
  • channel is the channel where the booking has been confirmed
  • confirmationDate is the confirmation date declared in the format "Y-m-d H:i:s e"
  • board is the kind of board, it can be Room || Breakfast || Half Board || Full Board

Your bookings string must look like this:


[booking]
	[status]confirmed[/status]
	[unitID]2[/unitID]
	[start]2019-01-01[/start]
	[end]2019-03-31[/end]
	[condCancel]d15,%30;d7,%70[/condCancel]
	[condPay]tp,%100;[/condPay]
	[adults]4[/adults]
	[children]0[/children]
	[price]700[/price]
	[services]137630:1-[/services]
	[channel]Official Website[/channel]
	[confirmationDate]2019-02-23 18:06:01 UTC[/confirmationDate]
	[board]Breakfast[/board]
	[bookerName]John[/bookerName]
	[bookerSurname]Doe[/bookerSurname]
	[bookerAddress]14 Even Rd., Norwalk, CT 06850, United States[/bookerAddress]
	[bookerCity]Norwalk[/bookerCity]
	[bookerCountry]USA[/bookerCountry]
	[bookerEmail]doe@example.com[/bookerEmail]
	[bookerTel]+123456789[/bookerTel]
[/booking]
[booking]
	...
[/booking]

The function returns a status code, it can be ok or ko.

Update bookings

URL: https://api.bookingbnb.com/xrws/UpdateBookings/

To update bookings, use the following function:

UpdateBookings(user, password, token, propertyID, bookings)

Here is an example of how your code should be:


/** java /*	
public String UpdateBookings(String username, String password, String token, Int propertyID, Int seasonID, String label) throws Exception {
  Vector params = new Vector();
  params.addElement(username);
  params.addElement(password);
  params.addElement(token);
  params.addElement(propertyID);
  params.addElement(bookings);
  Object[] objects = (Object[]) xmlRpcClient.execute(config, "UpdateBookings", params);
  return (String) objects[1];
}

/* php */
<?php
include("xmlrpc.inc");
$server = new xmlrpc_client($url);
$args = array(
	new xmlrpcval($user, 'string'), 
	new xmlrpcval($pass, 'string'), 
	new xmlrpcval($token, 'string'), 
	new xmlrpcval($propertyID, 'int'),
	new xmlrpcval($bookings, 'string')
);
$message = new xmlrpcmsg('xrws.UpdateBookings', $args);
$result = $server->send($message);
$struct = $result->value();
?>

How to correctly encode the bookings

To update a booking, encode it with the same parameters you use to create one and add the id parameter that refers to the booking you want to update.

The function returns a status code, it can be ok or ko.