Code Monkey home page Code Monkey logo

api-ruby's Introduction

Elvanto API Ruby Library

This library is all set to go with version 1 of the Elvanto API.

Installation

Add this line to your application's Gemfile:

gem 'elvanto-api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install elvanto-api

Authenticating

The Elvanto API supports authentication using either OAuth 2 or an API key.

What is This For?

  • Quick summary This is an API wrapper to use in conjunction with an Elvanto account. This wrapper can be used by developers to develop programs for their own churches, or to design integrations to share to other churches using OAuth authentication.
  • Version 1.0

Using OAuth 2

This library provides functionality to help you obtain an Access Token and Refresh token. The first thing your application should do is redirect your user to the Elvanto authorization URL where they will have the opportunity to approve your application to access their Elvanto account. You can get this authorization URL by using the authorize_url method, like so:

authorize_url = ElvantoAPI.authorize_url(client_id, redirect_uri, scope, state)
// Redirect your users to authorize_url.

If your user approves your application, they will then be redirected to the redirect_uri you specified, which will include a code parameter, and optionally a state parameter in the query string. Your application should implement a handler which can exchange the code passed to it for an access token, using exchange_token like so:

response = ElvantoAPI.exchange_token(client_id, client_secret, code, redirect_uri)

access_token = response[:access_token]
expires_in = response[:expires_in]
refresh_token = response[:refresh_token]
// Save access_token, expires_in and refresh_token.

At this point you have an access token and refresh token for your user which you should store somewhere convenient so that your application can look up these values when your user wants to make future Elvanto API calls.

Once you have an access token and refresh token for your user, you can authenticate and make further API calls like so:

ElvantoAPI.configure({:access_token=>access_token})
all_people = ElvantoAPI.call("people/getAll")

All OAuth tokens have an expiry time, and can be renewed with a corresponding refresh token. If your access token expires when attempting to make an API call, you will receive an error response, so your code should handle this. Here's an example of how you could do this:

result = ElvantoAPI.refresh_token(refresh_token)

Using an API key

ElvantoAPI.configure({:api_key=>api_key})
people = ElvantoAPI.call("people/getAll")

Documentation

Documentation can be found on the Elvanto API website.

Updates

Follow our Twitter to keep up-to-date with changes in the API.

Support

For bugs with the API Ruby Wrapper please use the Issue Tracker.

For suggestions on the API itself, please post in the forum or contact us via our website.

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.