Booking invitation functions

Invitations is a part of the booking module that handles invitations and sign-ups to bookings of type activity. These functions resides in the namespace Boka.booking.invitations and should be prefixed as such.

getAll()

Description The getAll() function fetches all invitations for a specific booking.

URL:

[GET] https://api.boka.se/rest/booking/<booking_id>/invitation

Response:

Returns an array of invitation objects.

Usage:

Boka.booking.invitations.getAll(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 return callback parameter containing an array with the invitation data.

Example:

Boka.booking.invitations.getAll({
    bookingId: 'xxz223',
    }, function (invitationData) {
        if (invitationData.success) 
            console.log(invitationData.result[0].name);
    }
);

addNewUser()

Description The addNewUser() function adds a user as an invitee to the specified booking. If the user information cannot be matched to an existing Boka user account, it will be created.

URL:

[PUT] https://api.boka.se/rest/booking/<booking_id>/invitation

Response:

Returns the newly created invitation object.

Usage:

Boka.booking.invitations.addNewUser(params, callback);

params is an object containing the following properties.

Key Value
bookingId A unique identifier for the booking.
name Name of the user.
email The user's e-mail address.
mobile The user's mobile number.

callback is a function called with a parameter containing the invitation data. Upon success, the result field will contain the data for the newly created invitation. This is used for further actions regarding the specific invitation.

Example:

Boka.booking.invitations.addNewUser({
    bookingId: 'xxz223',
    name: 'John Doe',
    email: 'johndoe@boka.se',
    phone: '+46 12345678',
    }, function (invitationData) {
        if (invitationData.success) 
            console.log('Created invitation ' + invitationData.result.id);
    }
);

delete()

Description The delete() function removes an invitation to a specified booking.

URL:

[DELETE] https://api.boka.se/rest/booking/<booking_id>/invitation/<invitation_id>

Response:

Returns the newly deleted invitation object.

Usage:

Boka.booking.invitations.delete(params, callback);

params is an object containing the following properties.

Key Value
bookingId A unique identifier for the booking.
invitationId A unique identifier for the invitation. Obtained when creating the invitation.

callback is a function called with a parameter containing the invitation data.

Example:

Boka.booking.invitations.delete({
    bookingId: 'xxz223',
    invitationId: 'yyy335',
    }, function (invitationData) {
        if (invitationData.success) 
            console.log('Invitation successfully removed.');
    }
);

setStatus()

Description The setStatus() function sets the status of a specific invitation. The status can be either attend to indicate accept of the invitation, unattend to decline the invitation or clear to remove any previous status.

URL:

[POST] https://api.boka.se/rest/booking/<booking_id>/invitation/<invitation_id>/<status>

Response:

Returns the newly updated invitation object.

Usage:

Boka.booking.invitations.setStatus(params, callback);

params is an object containing the following properties.

Key Value
invitationId A unique identifier for the invitation. Obtained when creating the invitation.
status On of the following values: attend, unattend or clear.

callback is a function called with a parameter containing the invitation data.

Example:

Boka.booking.invitations.setStatus({    
    invitationId: 'yyy335',
    status: 'attend',
    }, function (statusData) {
        if (statusData.success) 
            console.log('Status successfully set.');
    }
);