GithubHelp home page GithubHelp logo

todddickerson / cronofy-ruby Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cronofy/cronofy-ruby

0.0 0.0 0.0 492 KB

Cronofy Ruby Gem

Home Page: https://docs.cronofy.com/developers

License: MIT License

Shell 0.77% Ruby 99.23%

cronofy-ruby's Introduction

Cronofy

ruby CI Gem Version

Cronofy - the scheduling platform for business

Installation

Add this line to your application's Gemfile:

gem 'cronofy'

And then at your command prompt run:

bundle install

Usage

In order to use the Cronofy API you will need to create a developer account.

From there you can create an OAuth application to obtain an OAuth client_id and client_secret to be able to use the full API.

Creating a client

To make calls to the Cronofy API you must create a Cronofy::Client. This takes five keyword arguments, all of which are optional:

cronofy = Cronofy::Client.new(
  client_id:     'CLIENT_ID',
  client_secret: 'CLIENT_SECRET',
  access_token:  'ACCESS_TOKEN',
  refresh_token: 'REFRESH_TOKEN',
  data_center:   :de
)

When using a personal access token you only need to provide the access_token argument.

When working against your own OAuth application you will need to provide the client_id and client_secret when going through the authorization process for a user, and when refreshing an access token.

If client_id and client_secret are not specified explicitly the values from the environment variables CRONOFY_CLIENT_ID and CRONOFY_CLIENT_SECRET will be used if present.

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.

Authorization

API documentation

Generate a link for a user to grant access to their calendars:

authorization_url = cronofy.user_auth_link('http://yoursite.dev/oauth2/callback')

The callback URL is a page on your website that will handle the OAuth 2.0 callback and receive a code parameter. You can then use that code to retrieve an OAuth token granting access to the user's Cronofy account:

response = cronofy.get_token_from_code(code, 'http://yoursite.dev/oauth2/callback')

You should save the response's access_token and refresh_token for later use.

Note that the exact same callback URL must be passed to both methods for access to be granted.

If you use the omniauth gem, you can use our omniauth-cronofy strategy gem to perform this process.

List calendars

API documentation

Get a list of all the user's calendars:

calendars = cronofy.list_calendars

Read events

API documentation

Get a list of events from the user's calendars:

events = cronofy.read_events

Note that the gem handles iterating through the pages on your behalf.

Create or update events

API documentation

To create/update an event in the user's calendar:

event_data = {
  event_id: 'uniq-id',
  summary: 'Event summary',
  description: 'Event description',
  start: Time.now + 60 * 60 * 24,
  end: Time.now + 60 * 60 * 25,
  location: {
    description: "Meeting room"
  }
}

cronofy.upsert_event(calendar_id, event_data)

Delete events

API documentation

To delete an event from user's calendar:

cronofy.delete_event(calendar_id, 'uniq-id')

A feature I want is not in the SDK, how do I get it?

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 [email protected].

Links

cronofy-ruby's People

Contributors

adambird avatar adamwhittingham avatar agustin-peluffo avatar andrewseward avatar colbeanz avatar dinclas avatar eparreno avatar gitter-badger avatar grajo avatar gshutler avatar haziba avatar heel avatar jeopard avatar jeremyw avatar jonniecache avatar jstenhouse avatar kostissky avatar kr-mykyta avatar madhermit avatar nevett avatar stephenbinns avatar todddickerson avatar victor-cronofy 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.