Coupons

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

Get the coupons

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

To get the coupons, use the following function:

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

This function returns the list of all the active coupons for the current property. The offers are represented by a <tag>value</tag> structure. This is an example:


<cupons>
	<cupon>
		<code>2019ADVENTURE</code>
		<unitID>1</unitID>
		<discount>20</discount>
		<condcancel>1379</condcancel>
		<start>2019-06-01</start>
		<end>2019-09-01</end>
	</coupon>
	<cupon>
		<code>SPRING2019SUITE</code>
		<unitID>4</unitID>
		<discount>10</discount>
		<condcancel>1380</condcancel>
		<start>2019-04-01</start>
		<end>2019-06-01</end>
	</coupon>
</cupons>

Create new coupons

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

To create new boards, use the following function:

CreateCoupons(user, password, token, propertyID, coupons)

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

How to correctly encode the coupons

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

  • code is the code of the current coupon
  • unitID is the unit identifier (to which the boards refer)
  • discount is the discount percentage
  • condCancel is the cancellation condition identifier
  • start is the starting date of the current coupon
  • end is the ending date of the current coupon

Your offers string must look like this:


[coupons]
	[coupon]
		[code]2019ADVENTURE[/code]
		[unitID]1[/unitID]
		[discount]20[/discount]
		[condcancel]1379[/condcancel]
		[start]2019-06-01[/start]
		[end]2019-09-01[/end]
	[/coupon]
	[coupon]
		[code]SPRING2019SUITE[/code]
		[unitID]4[/unitID]
		[discount]10[/discount]
		[condcancel]1380[/condcancel]
		[start]2019-04-01[/start]
		[end]2019-06-01[/end]
	[/coupon]
[/coupons]

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

Update coupons

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

To update coupons, use the following function:

UpdateCoupons(user, password, token, propertyID, coupons)

Here is an example of how your code should be:


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

How to correctly encode the coupons

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

  • code is the code of the current coupon
  • unitID is the unit identifier (to which the boards refer)
  • discount is the new discount percentage
  • condCancel is the new cancellation condition identifier
  • start is the new starting date of the current coupon
  • end is the new ending date of the current coupon

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