metaxy / api-ruby

The Elvanto API in Ruby

Home Page:https://www.elvanto.com/api/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

The Elvanto API in Ruby

https://www.elvanto.com/api/

License:MIT License


Languages

Language:Ruby 100.0%