A simple wrapper for the Cronofy API.
The APIs should be one to one with the all of the current methods in Cronofy's documentation. The general pattern is that each method takes an options object and an optional callback. If a callback is not passed in as the second argument the function will act as a promise.
var Cronofy = require('cronofy');
var cronofyClient = new Cronofy({
client_id: 'armzr1h5NPQST93XTFL9iIULXxfdDlmV',
client_secret: 'aPPwd-ASDFAsdfasdfasdfsadfasdfASDFSADF_asdfasdfasdf',
access_token: 'aLUj9bRInSj1n08pHPAo5ru0OOppDaCO',
refresh_token: '5hdSBZHgjA4xcQAelyAYWDfezZv0-9yP',
data_center: 'de'
});
var options = {
code: 'asdkfj213sdf',
redirect_uri: 'https://www.yoursite.com/calendar_redirect_page'
};
cronofyClient.requestAccessToken(options)
.then(function(response){
console.log(response);
});
// Alternatively as a callback
cronofyClient.requestAccessToken(options, function(err, response){
if(err) throw err;
console.log(response);
})
The cronofy client object can be initialized with client and token details. These details will be automatically added to each call that they are needed for, but these values can be replaced by any specified in the method's options
object.
data_center
is the two-letter designation for the data center you want to operate against - for example de
for Germany, or au
for Australia. When omitted, this defaults to the US data center. You can find this value on your app's dashboard under SDK identifier
.
Takes options object and an optional callback, either returning a promise for, or calling the provided callback with an object containing an access and refresh token for you to use with future requests.
Takes an optional callback, either returning a promise for, or calling the provided callback with the new refresh and access token information.
Takes an optional callback, either returning a promise for, or calling the provided callback with an empty object in the success case.
Takes options object and an optional callback, either returning a promise for, or calling the provided callback with an object containing a permissions URL with a token
Takes options object and an optional callback, either returning a promise for, or calling the provided callback with an empty object in the success case.
Takes an optional callback, either returning a promise for, or calling the provided callback with an object containing the account information.
{
"account": {
"account_id": "acc_567236000909002",
"email": "janed@company.com",
"name": "Jane Doe",
"default_tzid": "Europe/London"
}
}
Takes an optional callback, either returning a promise for, or calling the provided callback with an array of the user's calendar profiles.
Takes options object and an optional callback, either returning a promise for, or calling the provided callback with an empty object in the success case.
Takes options object and an optional callback, either returning a promise for, or calling the provided callback with an array of the user's events accross all calendars.
Returns an empty string/promise for an empty string on success.
Returns an empty string/promise for an empty string on success.
Takes options object and an optional callback, either returning a promise for, or calling the provided callback with a list of free/busy information across all calendars.
Allows the editing of external events on accounts which have granted Extended Permissions
See full details in the Update External Event documentation.
Takes options object and an optional callback, either returning a promise for, or calling the provided callback with an empty object in the success case.
Takes an optional callback, either returning a promise for, or calling the provided callback with a list of calendars for the user.
Takes options object and an optional callback, either returning a promise for, or calling the provided callback with an object with the new channel details.
Takes options object and an optional callback, either returning a promise for, or calling the provided callback with an empty object in the success case.
Takes an optional callback, either returning a promise for, or calling the provided callback with a list of notification channels.
Takes options object and an optional callback, either returning a promise or calling the provided callback with the body of the response (or error, if applicable).
See full response details in the List Availability Rules documentation
Takes options object and an optional callback, either returning a promise or calling the provided callback with the body of the response (or error, if applicable).
See the full options in the Upsert Availability Rule documentation
String
representing a known time zone identifier from the IANA Time Zone Database.Array
specifying the calendars that should impact the user’s availability. When provided at least one calendar must be specified.Array
of weekly recurring periods for the availability rule.Takes options object and an optional callback, either returning a promise or calling the provided callback with the body of the response (or error, if applicable).
See full response details in the List Availability Rules documentation
String
that uniquely identifies the availability rule. The first request made for an availability_rule_id will create an available period for the account and subsequent requests will update its details. More info can be found in the Read Availability Rule documentationTakes options object and an optional callback, either returning a promise or calling the provided callback with the body of the response (or error, if applicable).
See full details in the Delete Availability Rule documentation
String
that uniquely identifies the availability rule.Creates or updates an Available Period for the authenticated account. Takes options object and an optional callback, either returning a promise or calling the provided callback with the body of the response (or error, if applicable).
See full details in the Create or Update Available Periods documentation
Lists Available Periods for the authenticated account. Takes options object and an optional callback, either returning a promise or calling the provided callback with the body of the response (or error, if applicable).
See full details in the Read Available Periods documentation
Deletes a single Available Period for the authenticated account, or deletes all Available Periods for the authenticated account.
Provide either:
String
that uniquely identifies the Available Period to delete., or:
true
to bulk delete all Available Periods for the account.Takes options object and an optional callback, either returning a promise or calling the provided callback with the body of the response (or error, if applicable).
See full details in the Real-Time Scheduling documentation
String
of either h
(12-hour format) or H
(24-hour format). If omitted then the hour format to use will be determined by Cronofy.token
will be added to this URL. The token
can be used to retrieve the current status of a Real Time Scheduling link.Duration
describing the frequency that a sequence can start on. More details in the documentation.Duration
. No slots starting before the period described after the current time will be displayed to the user when they select slots.Takes options object and an optional callback, either returning a promise for, or calling the provided callback with a URL to redirect the user towards
Takes options object and an optional callback, either returning a promise or calling the provided callback with the body of the response (or error, if applicable).
See full details in the Batch documentation.
String
for the HTTP method of the individual request. Maps directly from its main documentation.String
for the relative URL (sometimes referred to as the path and query string) of the individual request. Maps directly from its main documentation.Takes options object and an optional callback, either returning a promise or calling the provided callback with the body of the response (or error, if applicable).
"confirmed"
or "cancelled"
.See full details in the Create Bookable Event documentation.
Takes options object and an optional callback, either returning a promise for, or calling the provided callback with an object representing the bookable event.
See full details in the Read Bookable Event documentation.
Takes options object and an optional callback, either returning a promise for, or calling the provided callback with an object representing the bookable event.
"pending"
, "accepted"
, "tentative"
, "declined"
, "removed"
.See full details in the Create or Update Registration documentation.
Takes options object and an optional callback, either returning a promise for, or calling the provided callback with an object representing the bookable event.
See full details in the Delete Registration documentation.
We add features to this SDK as they are requested, to focus on developing the Cronofy API.
If you're comfortable contributing support for an endpoint or attribute, then we love to receive pull requests! Please create a PR mentioning the feature/API endpoint you’ve added and we’ll review it as soon as we can.
If you would like to request a feature is added by our team then please let us know by getting in touch via support@cronofy.com.