Booking functions

The booking module is handles all functionality regarding bookings in the Boka Connect SDK. These functions resides in the namespace Boka.booking and should be prefixed as such.

get() *

Description:

The get() command is used to retrieve detailed information about a specific booking.

Note: A public variant of this command is available.

URL:

[GET] https://api.boka.se/rest/booking/<booking_id>
[GET] https://api.boka.se/rest/system/<system_id>/calendar/<calendar_id>/booking/<booking_id>

Public URL:

[GET] https://api.boka.se/rest/public/booking/<booking_id>
[GET] https://api.boka.se/rest/public/system/<system_id>/calendar/<calendar_id>/booking/<booking_id>

Response:

Returns a booking object.

Usage:

Boka.booking.get(params, callback);

params is an object containing the following properties.

Key Value
bookingId A unique identifier for the booking.
[asPublic] Boolean indicating if the public data should be retrieved.

callback is a function called with a return callback parameter containing the booking.

Example:

Boka.booking.get({
    bookingId: 'xxz223',    
    }, function (bookingData) {
        if (bookingData.success) 
            console.log(bookingData.result);
    }
);

getForCalendar() *

Description:

The getForCalendar() command is used to retrieve all bookings in a calendar between a supplied interval.

Note: A public variant of this command is available.

URL:

[GET] https://api.boka.se/rest/system/<system_id>/calendar/<calendar_id>/booking?start=<iso8601>&end=<iso8601>

Public URL:

[GET] https://api.boka.se/rest/public/system/<system_id>/calendar/<calendar_id>/booking?start=<iso8601>&end=<iso8601>

Response:

Returns a booking object.

Usage:

Boka.booking.getForCalendar(params, callback);

params is an object containing the following properties.

Key Value
systemId A unique identifier for the system in which the calendar and bookings reside.
calendarId A unique identifier for the calendar in which the bookings reside.
start Start of interval in ISO 8601 format, without timezone.
end End of interval in ISO 8601 format, without timezone.
[asPublic] Boolean indicating if the public data should be retrieved.

callback is a function called with a return callback parameter containing an array with the bookings.

Example:

Boka.booking.getForCalendar({    
    systemId: 'xxc664',
    calendarId: 'yyz112',
    start: '2017-01-01 10:00',
    end: '2017-01-05 15:00'    
    }, function (bookingData) {
        if (bookingData.success) 
            console.log(bookingData.result);
    }
);

persist()

Description:

The persist() command is used to store information about a booking in a calendar. This command is used to both create and update existing bookings.

URL:

[POST] https://api.boka.se/rest/system/<system_id>/calendar/<calendar_id>/booking
[PUT] https://api.boka.se/rest/system/<system_id>/calendar/<calendar_id>/booking/<booking_id>

Response:

Returns the persisted booking object.

Usage:

Boka.booking.persist(booking, callback);

callback is a function called with a parameter containing the booking data. The result will contain the persisted booking object.

Example:

Boka.booking.persist({        
    systemId: 'xxc664',
    calendarId: 'yyz112',
    bookingType: Boka.booking.bookingType.activity,
    start: '2017-12-31 18:00',
    end: '2018-01-01 03:00',
    subject: 'Party',
    metadata: {
        'hats': true,
        'balloons': true,
        'max_guests': 24
    }}, function (bookingData) {
        if (bookingData.success) 
            console.log(bookingData.result.id);
    }
);

delete()

Description:

The delete() command is used to completely remove a booking in a calendar.

URL:

[DELETE] https://api.boka.se/rest/system/<system_id>/calendar/<calendar_id>/booking/<booking_id>
[DELETE] https://api.boka.se/rest/booking/<booking_id>

Response:

Returns the deleted booking object.

Usage:

Boka.booking.delete(params, callback);

params is an object containing the following properties.

Key Value
bookingId A unique identifier for the booking.

callback is a function called with a parameter containing the booking data. The result will contain the deleted booking.

Example:

Boka.booking.delete({    
    bookingId: 'xxz223',
    function (bookingData) {
        if (bookingData.success) 
            console.log('Booking successfully removed.');
    }
);

deleteMultiple()

Description:

The deleteMultiple() command is used to completely remove multiple bookings at once.

URL:

[DELETE] https://api.boka.se/rest/booking/multiple

Response:

Returns a response whether the deletion succeded or not.

Usage:

Boka.booking.deleteMultiple(params, callback);

params is an object containing the following properties.

Key Value
bookingIds An array of unique identifier for the bookings.

callback is a function called with a parameter containing a response of success or failure.

Example:

Boka.booking.deleteMultiple({    
    bookingIds: ['xxz223', 'abc123'],
    function (data) {
        if (data.success) 
            console.log('Bookings successfully removed.');
    }
);