google-calendar-helpers

0.2.1 • Public • Published

Convenience functions for simple Google Calendar usage for NodeJS

Based on google-calendar

To install:

npm install google-calendar-helpers

Usage

Initialize API:

var accessToken = '--- your access token ---'
  , clientId = '--- client ID ---'
  , clientSecret = '--- client secret ---'
  , calendarId = '--- Google Calendar Id ---'
  , CalendarClient = require('google-calendar-helpers');
  , calendarClient = new CalendarClient(accessToken, clientId, clientSecret, calendarId);

Access tokens and stuff explained here and a node module for obtaining access token and refresh token here.

Methods

calendarClient.getEvents(timeMin, timeMax, callback)

Returns a list of events from timeMin to timeMax (RFC 3339 formatted strings)

NB: Makes multiple requests when necessary (if there are more than one page of events)

calendarClient.getPastEvents(options, callback) calendarClient.getFutureEvents(options, callback)

Returns a list of past or future events, respectively.

By default, getPastEvents returns events whose start time is past even if their end time is still in the future. You can override by setting endTimePast to true in options. Then, only events which have ended, will be returned.

All day events which have started today or earlier, will always be returned.

Options object (optional) can have property 'dayRange' specifying how many days into the past or future to extend the query. Defaults to 30.

calendarClient.submitNewEvent(event, callback)

Adds new event to calendar. event must be a Google event resource object

Callback is called with error and event which is the newly created event.

calendarClient.submitModifiedEvent(event, callback)

Updates an event. event must be an event resource object with property id of an existing event.

Callback is called with error and event which is the modified event as returned by Google.

calendarClient.deleteEvent(eventId, callback)

Deletes an event. Argument eventId (string) is the id of an existing event.

Callback is called with error as only argument.

Testing

Run grunt jasmine_node to test. Add your access tokens etc. in test/config.json for the tests to work. NB! Tests erase existing event in the calendar, so create a specific test calendar for testing!

Readme

Keywords

Package Sidebar

Install

npm i google-calendar-helpers

Weekly Downloads

1

Version

0.2.1

License

MIT

Last publish

Collaborators

  • espesen