GithubHelp home page GithubHelp logo

hanss / google-calendar-javascript-api-promises Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nicolabortignon/google-calendar-javascript-api-promises

0.0 2.0 0.0 5 KB

A promises based wrapper of the Google Calendar API

JavaScript 100.00%

google-calendar-javascript-api-promises's Introduction

Google Calendar Javascript API (Promises)

I'm not a fan of the original Google Calendar Javascript API, they are so 2012 :). I've decided to write my own wrap, exposing every method via promises.

How to use this wrapper

Included the original Google Api and the file calendarAPI.js in your project and reference them as usaul by adding:

<script src="https://apis.google.com/js/client.js"></script>
<script src="calendarAPI.js"></script>

On page loaded you can initialize the wrapper in this way:

var calendarAPI = new calendarAPI(your_google_app_client_id);
calendarAPI.startAuthentication()
	.then( calendarAPI.getCalendars )
	.then( calendarAPI.getEvents );

where your_google_app_client_id is the token generated in your cloud console.

API Overview

considering the initialization done in this way:

var calendarAPI = new calendarAPI(your_google_app_client_id);

Here the API currently supported.

Authentication

isAuthenticated

returns the authentication object if the user is already authenticated, fails the promise otherwise.

calendarAPI.isAuthenticated()
```js

#### startAuthentication
opens the google oAuth2 autentication popup. Request read and write permission 
on the user.
Fullfill the promise when the autentication is confirmed, and returns the authentication object.
Fails otherwise.

```js
calendarAPI.startAuthentication()
```js

### Access personal calendar informations 

#### getMyCalendars
returns an array of all the calendars that belongs to the user. Not to be confused to the list 
of all the calendars that the user has been exposed to (which is available by using getCalendars).

```js
calendarAPI.getMyCalendars()
```js


#### getMyEvents
returns a list of all events that belongs to the users (that has been created by the user on one of his calendar).
Allows to filter by calendar and date.

```js
calendarAPI.getMyEvents()
```js

### Access calendar informations 

#### getCalendars
returns an array of all the calendars the user has been exposed to. It means, all the user calendars plus all the other calendars belonging 
to other users in which there is an event with an invitation to the current user. 

```js
calendarAPI.getCalendars()
```js


#### getEvents
returns a list of all events that involve the curent user. Includes events created by the user as well as events that the user has been invited.

```js
calendarAPI.getEvents()
```js

google-calendar-javascript-api-promises's People

Contributors

nicolabortignon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.