Units

In this section we will see how to add, remove, update and get information about the units (rooms) of your property.

Get the list of a property units

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

To retrieve the list of your units, use the following function:

GetUnits(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 GetUnits(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, "GetUnits", 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($unitID, 'int')
);
$message=new xmlrpcmsg('xrws.GetUnits', $args);
$result=$server->send($message);
$struct = $result->value();
?>

This function returns a list of properties, each one being represented by a <tag>value</tag> structure. This is an example:


<units>
	<unit>
		<id>1</id>
		<status>active</status>
		<name>Standard Room</name>
		<type>roo</type>
		<descrEN>Exquisitely prepared bed linen, an interior bathed in warm light, and a relaxing bathtub in a sparkling clean bathroom. In this atmosphere, guests are sure to feel the detailed attentiveness that is the foundation of our hotel service.</descrEN>
		<total>4</total>
		<capacity>2</capacity>
		<instant>ok</instant>
	</unit>
	<unit>
		<id>2</id>
		<status>active</status>
		<name>Superior Room</name>
		<type>roo</type>
		<descrEN>Guests have the exclusive choice of a bed that suits their preferences. Guests are invited to enjoy room service or a drink from the mini-bar while relaxing on the room’s color accented sofa.</descrEN>
		<total>2</total>
		<capacity>3</capacity>
		<instant>ok</instant>
	</unit>
</units>

Create new units

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

As a partner, you can add new units to a property in the BookingBnb system. To create new units, use the following function:

CreateUnits(user, password, token, propertyID, units)

How to correctly encode the units

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

Key Type Value
status string The status of the unit: active || deactivated
name string The name of the unit
type string The type of unit: room || apartment || villa || house
total int The total number of units for this category
capacity int The total number of guests for each unit of this category
instant string Controls if the instant booking is active or not: ok (if it's active) or ko (if it's not active)
condCancelID int The ID of the cancellation condition. The default value is 1, with these conditions: d14,%30;d3,%70 (see the CreateCondCancel function).
descrEN string A complete description of the property in English

Your units string must look like this:


[units]
	[unit]
		[status]active[/status]
		[name]Standard[/name]
		[type]room[/type]
		[total]10[/total]
		[capacity]2[/capacity]
		[instant]ok[/instant]
		[condCancelID]1234[/condCancelID]
		[descrEN]A complete description of the property in English[/descrEN]
	[/unit]
[/units]

We also support optional parameters:

Key Type Value
damage (NULL) double The damage deposit amount, applicable to each unit
nameIT (NULL) string The name of the unit in Italian
nameFR (NULL) string The name of the unit in French
nameDE (NULL) string The name of the unit in German
nameES (NULL) string The name of the unit in Spanish
namePT (NULL) string The name of the unit in Portuguese
nameJP (NULL) string The name of the unit in Japanese
nameCN (NULL) string The name of the unit in Simplified Chinese
descrIT (NULL) string A complete description of the property in Italian
descrFR (NULL) string A complete description of the property in French
descrDE (NULL) string A complete description of the property in German
descrES (NULL) string A complete description of the property in Spanish
descrPT (NULL) string A complete description of the property in Portuguese
descrJP (NULL) string A complete description of the property in Japanese
descrCN (NULL) string A complete description of the property in Simplified Chinese

Update units

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

To update data about units, please, launch the following function:

UpdateUnits(user, password, token, propertyID, units)

Here is an example of how your code should be:


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

How to correctly encode the units

Given an array of data about units of a property, that your system will produce, you can include the same parameters used to create units.
This is an example:


  $units[0][id]=2;
  $units[0][total]=12;
  $units[0][capacity]=3;
  $units[0][instant]="ok";
  
  $units[1][id]=3;
  $units[1][instant]="ko";

Your units string must look like this:


[units]
	[unit]
		[id]2[/id]
		[total]12[/total]
		[capacity]3[/capacity]
		[instant]ok[/instant]
	[/unit]
	[unit]
		[id]3[/id]
		[instant]ko[/instant]
	[/unit]
[/units]

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