BTU.JS is a javascript library that interacts with BTU Protocol. It allows any developer to build a booking application or a widget.
This is the documentation for the activities module. Click here to go back to the global documentation.
npm install btujs --save
const btujs = require('btujs');
const myBtujs = new btujs();
Search for resources regardless of their availabilities.
myBtujs.resources.searchResources(String resourceType, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'activity'.
-
body:
parameter mandatory description options.categoryIds true
Array
ids of wanted activtiesoptions.maxCount false
(default = 5)Array
max results count -
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.resources.searchResources('activity', body).then(res => {...})
{
activities: [
activity_object, // Activity matching the requested categoryIds
activity_object,
...
]
}
Query resource by its ID to get its details.
myBtujs.resources.getResource(String resourceType, String resourceId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'activity'.
-
resourceId: resource unique identifier.
-
body: none.
-
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.resources.getResource('activity', body).then(res => {...})
activity_object //The requested activity
Query resource by its ID and its sub-item ID to get sub-item details.
myBtujs.resource.getResourceItem(String resourceType, String resourceId, String itemId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'activity'.
-
resourceId: resource unique identifier.
-
itemId: item unique identifier.
-
body: none.
-
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.resources.getResourceItem('activity', 'ABCDEF', body).then(res => {...})
Search for availables resources only.
myBtujs.availabilities.searchAvailableResources(String resourceType, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'activity'.
-
body:
parameter mandatory description options.query true
String
search query (ex: activity name)options.categoryId false
String
filter with a category idoptions.fromDate false
String
filter from start dateoptions.partipantsNumber false
Number
filter with participant a count -
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.availabilities.searchAvailableResources('activity', body).then(res => {...})
{
count: 5, // Results count
activities: [
activity_object, // Activity matching the request
activity_object,
...
]
}
Query a resource by its ID and get its availabilities.
myBtujs.availabilities.getResourceAvailabilities(String resourceType, String resourceId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'activity'.
-
resourceId: resource unique identifier.
-
body:
parameter mandatory description fromDate true
Date
search after this datepartipantsNumber true
Number
participaant count -
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.availabilities.getResourceAvailabilities('activity', 'ABCDEF', body).then(res => {...})
{
sessionId: "skdfhqwuifq;wuefqweoifqwuiefgqwueif", // Required later for booking
availabilities: [
availabilities_object, // Availability matching the request
availabilities_object,
...
]
}
Check if a resource is available under different conditions.
myBtujs.availabilities.isResourceAvailable(String resourceType, String resourceId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'activity'.
-
resourceId: resource unique identifier.
-
body:
parameter mandatory description sessionId true
String
session id from a previous gerResourceAvailability calldepartureDate true
String
chosen date (format : AAAA-MM-DD)fares true
Object
chosen availabilities -
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.availabilities.isResourceAvailable('activity', 'ABCDEF', body).then(res => {...})
{
isAvailable: true // or false
}
Book a resource availability.
myBtujs.availabilities.bookResource(String resourceType, String resourceId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'activity'.
-
resourceId: resource unique identifier.
-
body:
parameter mandatory description checkout true
Object
payment informationsbookActivity true
Object
reservation informationspersonalInformations true
Object
booker personal informationspiuckup false
Object
activity pickup informations -
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.availabilities.bookResource('activity', 'ABCDEF', body).then(res => {...})
Get informations about a booking you made.
myBtujs.availabilities.getBookingDetails(String resourceType, String bookingId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'activity'.
-
bookingId: resource unique identifier.
-
body: none.
-
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.availabilities.getBookingDetails('activity', 'ABCDEF', body).then(res => {...})
Cancel a reservation you booked through the bookResource method.
myBtujs.availabilities.cancelBooking(String resourceType, String bookingId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'activity'.
-
bookingId: resource unique identifier.
-
body: none.
-
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.availabilities.cancelBooking('activity', 'ABCDEF', body).then(res => {...})
parameter | mandatory | description |
---|---|---|
id | true |
String activity id |
fromPrice | true |
Number cheapest price this year |
language | true |
Array supported languages for this activity |
pickupRequired | true |
Boolean is pickup information required for booking |
cheapest | true |
Object currency and cheappest price for the activity |
paxNamesRequired | true |
Boolean are pax informations required for booking |
pickup | true |
Object information about start and end of the activity |
cityCode | true |
String activity city code |
categoryCode | true |
String activity category code |
name | true |
String activity name |
descriptions | true |
Object multiple activity descriptions |
destination | true |
String activity location |
cityName | true |
String activity city |
highlights | true |
Array activity highlights |
keywords | true |
Array activity keywords |
images | true |
Object thumbnail and array of more images |
shortDescription | true |
String activity description |
tourId | true |
String another activity id |
duration | true |
String activity duration |
startPoint | true |
Object activity start point informations |
endPoint | true |
Object activity end point informations |
parameter | mandatory | description |
---|---|---|
idFare | true |
Number id of the selected availability |
timeFare | true |
String 'HH:MM' selected time |
langFare | true |
String selected language |
participants | true |
Array array of participants objects |
parameter | mandatory | description |
---|---|---|
codePers | true |
string kind of person 'ADT', 'CHD' or 'BAB' |
firstName | true |
String person's first name |
lastName | true |
String person's last name |
title | true |
String 'Mr' or 'Mrs' |
parameter | mandatory | description |
---|---|---|
cardNo | true |
String card number |
amount | true |
Number amount to pay |
expMonth | true |
String expiration month |
expYear | true |
String expiration year |
cvc | true |
String cvc |
parameter | mandatory | description |
---|---|---|
sessionId | true |
String session id |
departureDate | true |
String AAAA-MM-DD departure date |
cityCode | true |
String city code |
fares | true |
Array array of fares |
parameter | mandatory | description |
---|---|---|
title | true |
String 'Mr' or 'Mrs' |
true |
String email |
|
firstname | true |
String first name |
lastname | true |
String last name |
phoneAreaCode | true |
String phone area code e.g. +33 |
phoneNumber | true |
String phone number |
parameter | mandatory | description |
---|---|---|
address | true |
String hotel address |
name | true |
String hotel name |