Pricing Plan

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

Get the rates

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

To get the rates, use the following function:

GetRates(user, password, token, propertyID, dateStart, dateEnd)

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

This function returns the list of rates belonging to a unit, identified by a date. The rates are represented by a <tag>value</tag> structure. This is an example:


<units>
	<unit>
		<id>1</id>
		<title>Standard Room</title>
		<currency>EUR</currency>
		<rateBox>
			<date>2017-01-01</date>
			<rate>
				<amount guests="1">70.00</amount>
				<amount guests="2">80.00</amount>
			</rate>
		</rateBox>
		<rateBox>
			<date>2017-01-02</date>
			<rate>
				<amount guests="1">70.00</amount>
				<amount guests="2">80.00</amount>
			</rate>
		</rateBox>
	</unit>
	
	<unit>
		<id>2</id>
		<title>Superior Room</title>
		<currency>EUR</currency>
		<rateBox>
			<date>2017-01-01</date>
			<rate>
				<amount guests="1">80.00</amount>
				<amount guests="2">90.00</amount>
				<amount guests="3">100.00</amount>
				<amount guests="4">110.00</amount>
			</rate>
		</rateBox>
		<rateBox>
			<date>2017-01-02</date>
			<rate>
				<amount guests="1">80.00</amount>
				<amount guests="2">90.00</amount>
				<amount guests="3">100.00</amount>
				<amount guests="4">110.00</amount>
			</rate>
		</rateBox>
	</unit>
</units>

Create new rates

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

To create new rates, use the following function:

CreateRates(user, password, token, propertyID, rates)

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

How to correctly encode the rates

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

  • periodID is the period identifier (to which the rates refer)
  • unitID is the unit identifier (to which the rates refer)
  • guests is the progressive number of guests declaration
  • rates is the progressive amount in the preferred currency
  • ratesChannels is the progressive amount in the preferred currency, visible to other channels only


  $rates[0][periodID]=1;
  $rates[0][unitID]=1;
  $rates[0][guests]="0;1;2";
  $rates[0][rates]="0;70;80";
  $rates[0][ratesChannels]="0;100;110";
  
  $rates[1][periodID]=2;
  $rates[1][unitID]=1;
  $rates[1][guests]="0;1;2";
  $rates[1][rates]="0;100;120";
  $rates[1][ratesChannels]="0;130;150";

Your rates string must look like this:


[rate]
	[periodID]1[/periodID]
	[unitID]1[/unitID]
	[guests]0;1;2[/guests]
	[rates]0;70;80[/rates]
	[ratesChannels]0;100;110[/ratesChannels]
[/rate]
[rate]
	[periodID]2[/periodID]
	[unitID]1[/unitID]
	[guests]0;1;2[/guests]
	[rates]0;100;120[/rates]
	[ratesChannels]0;130;150[/ratesChannels]
[/rate]

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

Update rates

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

To update rates, use the following function:

UpdateRates(user, password, token, propertyID, rates)

Here is an example of how your code should be:


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

How to correctly encode the rates

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

  • periodID is the period identifier (to which the rates refer)
  • newPeriodID is the new period identifier (to which the rates refer)
  • unitID is the unit identifier (to which the rates refer)
  • newUnitID is the new unit identifier (to which the rates refer)
  • newGuests is the progressive number of guests declaration
  • newRates is the progressive amount in the preferred currency
  • newRatesChannels is the progressive amount in the preferred currency, visible to other channels only


  $rates[0][periodID]=1;
  $rates[0][newPeriodID]=1;
  $rates[0][unitID]=1;
  $rates[0][newUnitID]=1;
  $rates[0][guests]="0;1;2;3";
  $rates[0][rates]="0;70;80;100";
  $rates[0][ratesChannels]="0;100;110;130";
  
  $rates[1][periodID]=2;
  $rates[1][newPeriodID]=3;
  $rates[1][unitID]=1;
  $rates[1][newUnitID]=1;
  $rates[1][guests]="0;1;2;3";
  $rates[1][rates]="0;100;120;150;";
  $rates[1][ratesChannels]="0;130;150;180";

Your rates string must look like this:


[rate]
	[periodID]1[/periodID]
	[newPeriodID]1[/newPeriodID]
	[unitID]1[/unitID]
	[newUnitID]1[/newUnitID]
	[guests]0;1;2;3[/guests]
	[rates]0;70;80;100[/rates]
	[ratesChannels]0;100;110;130[/ratesChannels]
[/rate]
[rate]
	[periodID]2[/periodID]
	[newPeriodID]3[/newPeriodID]
	[unitID]1[/unitID]
	[newUnitID]1[/newUnitID]
	[guests]0;1;2;3[/guests]
	[rates]0;100;120;150[/rates]
	[ratesChannels]0;130;150;180[/ratesChannels]
[/rate]

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