Periods

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

Get the periods

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

To get the periods, use the following function:

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

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


<periods>
	<period>
		<id>1</id>
		<seasonID>1</seasonID>
		<seasonLabel>Low Season</seasonLabel>
		<start>2019-02-01</start>
		<end>2019-03-31</end>
		<minimumStay>1</minimumStay>
	</period>
	<period>
		<id>3</id>
		<seasonID>1</seasonID>
		<seasonLabel>Low Season</seasonLabel>
		<start>2019-11-01</start>
		<end>2019-12-20</end>
		<minimumStay>1</minimumStay>
	</period>
	<period>
		<id>2</id>
		<seasonID>2</seasonID>
		<seasonLabel>High Season</seasonLabel>
		<start>2019-06-01</start>
		<end>2019-08-31</end>
		<minimumStay>3</minimumStay>
	</period>
<periods>
Please, note that each season can have more periods. Rates refer to seasons, not periods, so all the periods belonging to a season have the same rates.

Create new periods

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

To create a new period, use the following function:

CreatePeriods(user, password, token, propertyID, periods)

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

How to correctly encode the periods

Given a multi-dimensional array of periods, that your system will produce, you must include the following parameters: where season is the season identifier (to which the period belongs), periodStart is the starting date of the current period, periodEnd is the ending date of the current period, stay is the minimum stay allowed for the current period.


  $periods[0][season]=1;
  $periods[0][periodStart]="2019-01-01";
  $periods[0][periodEnd]="2019-03-31";
  $periods[0][stay]=2;
  $periods[1][season]=2;
  $periods[1][periodStart]="2019-04-01";
  $periods[1][periodEnd]="2019-05-31";
  $periods[1][stay]=3;
  $periods[2][season]=1;
  $periods[2][periodStart]="2019-10-01";
  $periods[2][periodEnd]="2019-12-31";
  $periods[2][stay]=2;

Your periods string must look like this:


[period]
	[season]1[/season]
	[periodStart]2019-01-01[/periodStart]
	[periodEnd]2019-03-31[/periodEnd]
	[stay]2[/stay]
[/period]
[period]
	[season]2[/season]
	[periodStart]2019-04-01[/periodStart]
	[periodEnd]2019-05-31[/periodEnd]
	[stay]2[/stay]
[/period]
[period]
	[season]1[/season]
	[periodStart]2019-10-01[/periodStart]
	[periodEnd]2019-12-31[/periodEnd]
	[stay]2[/stay]
[/period]

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

Update periods

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

To update periods, use the following function:

UpdatePeriods(user, password, token, propertyID, periods)

Here is an example of how your code should be:


/** java /*	
public String UpdatePeriods(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(periods);
  Object[] objects = (Object[]) xmlRpcClient.execute(config, "UpdatePeriods", 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($periods, 'string')
);
$message = new xmlrpcmsg('xrws.UpdatePeriods', $args);
$result = $server->send($message);
$struct = $result->value();
?>

How to correctly encode the periods

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

  • periodStart is the starting date of the current period
  • periodEnd is the ending date of the current period
  • newSeason is the season identifier (to which you want the period to belong)
  • newPeriodStart is the new starting date of the current period
  • newPeriodEnd is the new ending date of the current period
  • newStay is the new minimum stay allowed for the current period


  $periods[0][periodStart]="2019-01-01";
  $periods[0][periodEnd]="2019-03-31";
  $periods[0][newSeason]=1;
  $periods[0][newPeriodStart]="2019-01-01";
  $periods[0][newPeriodEnd]="2019-01-31";
  $periods[0][newStay]=3;
  
  $periods[1][periodStart]="2019-04-01";
  $periods[1][periodEnd]="2019-05-31";
  $periods[1][newSeason]=2;
  $periods[1][newPeriodStart]="2019-04-15";
  $periods[1][newPeriodEnd]="2019-05-31";
  $periods[1][newStay]=3;
  
  $periods[2][periodStart]="2019-10-01";
  $periods[2][periodEnd]="2019-12-31";
  $periods[2][newSeason]=1;
  $periods[2][newPeriodStart]="2019-10-01";
  $periods[2][newPeriodEnd]="2019-11-30";
  $periods[2][newStay]=3;

Your periods string must look like this:


[period]
	[periodStart]2019-01-01[/periodStart]
	[periodEnd]2019-03-31[/periodEnd]
	[newSeason]1[/newSeason]
	[newPeriodStart]2019-01-01[/newPeriodStart]
	[newPeriodEnd]2019-01-31[/newPeriodEnd]
	[newStay]3[/newStay]
[/period]
[period]
	[periodStart]2019-04-01[/periodStart]
	[periodEnd]2019-05-31[/periodEnd]
	[newSeason]1[/newSeason]
	[newPeriodStart]2019-04-15[/newPeriodStart]
	[newPeriodEnd]2019-05-31/newPeriodEnd]
	[newStay]3[/newStay]
[/period]
[period]
	[periodStart]2019-10-01[/periodStart]
	[periodEnd]2019-12-31[/periodEnd]
	[newSeason]1[/newSeason]
	[newPeriodStart]2019-10-01[/newPeriodStart]
	[newPeriodEnd]2019-11-30[/newPeriodEnd]
	[newStay]3[/newStay]
[/period]

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