nylas
Version:
A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.
99 lines (98 loc) • 2.88 kB
JavaScript
import { Resource } from './resource.js';
import { makePathParams } from '../utils.js';
/**
* Nylas Calendar API
*
* The Nylas calendar API allows you to create new calendars or manage existing ones.
* A calendar can be accessed by one, or several people, and can contain events.
*/
export class Calendars extends Resource {
/**
* Return all Calendars
* @return A list of calendars
*/
list({ identifier, queryParams, overrides, }) {
return super._list({
queryParams,
overrides,
path: makePathParams('/v3/grants/{identifier}/calendars', { identifier }),
});
}
/**
* Return a Calendar
* @return The calendar
*/
find({ identifier, calendarId, overrides, }) {
return super._find({
path: makePathParams('/v3/grants/{identifier}/calendars/{calendarId}', {
identifier,
calendarId,
}),
overrides,
});
}
/**
* Create a Calendar
* @return The created calendar
*/
create({ identifier, requestBody, overrides, }) {
return super._create({
path: makePathParams('/v3/grants/{identifier}/calendars', { identifier }),
requestBody,
overrides,
});
}
/**
* Update a Calendar
* @return The updated Calendar
*/
update({ calendarId, identifier, requestBody, overrides, }) {
return super._update({
path: makePathParams('/v3/grants/{identifier}/calendars/{calendarId}', {
identifier,
calendarId,
}),
requestBody,
overrides,
});
}
/**
* Delete a Calendar
* @return The deleted Calendar
*/
destroy({ identifier, calendarId, overrides, }) {
return super._destroy({
path: makePathParams('/v3/grants/{identifier}/calendars/{calendarId}', {
identifier,
calendarId,
}),
overrides,
});
}
/**
* Get Availability for a given account / accounts
* @return The availability response
*/
getAvailability({ requestBody, overrides, }) {
return this.apiClient.request({
method: 'POST',
path: makePathParams('/v3/calendars/availability', {}),
body: requestBody,
overrides,
});
}
/**
* Get the free/busy schedule for a list of email addresses
* @return The free/busy response
*/
getFreeBusy({ identifier, requestBody, overrides, }) {
return this.apiClient.request({
method: 'POST',
path: makePathParams('/v3/grants/{identifier}/calendars/free-busy', {
identifier,
}),
body: requestBody,
overrides,
});
}
}