Availability

In this section we will see how to push and pull the availability of your properties.

Get the availability

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

To get the availability, use the following function:

GetAvailability(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 GetAvailability(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, "GetAvailability", 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.GetAvailability', $args);
$result = $server->send($message);
$struct = $result->value();
?>

This function returns the list of your units, each with a list of days starting from the current date. The availability is represented by a <tag>value</tag> structure. This is an example:


<units>
	<unit>
		<id>1</id>
		<title>Standard Room</title>
		<sell>1</sell>
		<availability>
			<date>2019-06-10</date>
			<busy>1</busy>
		</availability>
		<availability>
			<date>2019-06-11</date>
			<busy>0</busy>
		</availability>
		<availability>
			<date>2019-06-12</date>
			<busy>1</busy>
		</availability>
	<unit>
	<unit>
		<id>2</id>
		<title>Superior Room</title>
		<sell>3</sell>
		<availability>
			<date>2019-06-10</date>
			<busy>2</busy>
		</availability>
		<availability>
			<date>2019-06-11</date>
			<busy>2</busy>
		</availability>
		<availability>
			<date>2019-06-12</date>
			<busy>1</busy>
		</availability>
	<unit>
<units>
If busy=0 no rooms are booked; if busy>0 the value indicates the number of booked units.
Please, note that the parameter sell indicates the maximum number of units for a category, so the busy value should never exceed it.

Update the availability

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

To update the availability, use the following function:

UpdateAvailability(user, password, token, propertyID, availability)

Here is an example of how your code should be:


/** java /*	
public String UpdateAvailability(String username, String password, String token, Int propertyID, String availability) throws Exception {
  Vector params = new Vector();
  params.addElement(username);
  params.addElement(password);
  params.addElement(token);
  params.addElement(propertyID);
  params.addElement(availability);
  Object[] objects = (Object[]) xmlRpcClient.execute(config, "UpdateAvailability", 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($availability, 'string')
);
$message = new xmlrpcmsg('xrws.UpdateAvailability', $args);
$result = $server->send($message);
$struct = $result->value();
?>

How to correctly encode the availability

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

  • id is the unit identifier (to which the availability refers)
  • date
  • busy is the number of booked units for that date


  $units[0][id]=1;
  $units[0][date]="2019-06-01";
  $units[0][busy]=2;
  
  $units[1][id]=1;
  $units[1][date]="2019-06-02";
  $units[1][busy]=3;
  
  $units[2][id]=1;
  $units[2][date]="2019-06-03";
  $units[2][busy]=3;

Your availability string must look like this:


[unit]
	[id]1[/id]
	[day]2019-06-01[/day]
	[busy]2[/busy]
[/unit]
[unit]
	[id]1[/id]
	[day]2019-06-02[/day]
	[busy]3[/busy]
[/unit]
[unit]
	[id]1[/id]
	[day]2019-06-03[/day]
	[busy]3[/busy]
[/unit]

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