Ruby Client for the Identity API

A Ruby client for the Identity >= v2 API.

Installation

Add this line to your application's Gemfile:

gem 'identity_crm'

And then load it into your application:

require 'identity_crm'

Initialising the client

The client is initialised with a user, a token and the url of the Identity server.

@client = IdentityCRM::Client.new(
  user: ENV["IDENTITY_API_USER"],
  token: ENV["IDENTITY_API_TOKEN"],
  url: 'http://localhost:5000'
)

GET requests

You can get details about one or many resources in the API by calling the #get method.

Getting a single resource

To request a single resource, use the #get method:

@client.members.get(member_id)

A call to get returns an instance of the resource:

@client.members.get(member_id).first_name

Some resources can also be requested with alternative parameters

@client.members.get(params: { guid: 'abc123' })
@client.members.get(params: { email: '[email protected]' })

POST requests

Resources are created in the API by calling the #create method with the body passed through params key.

Creating a single resource

@client.members.create(params: {
  email: '[email protected]',
  first_name: 'Yoelo',
  last_name: 'Svenslol',
})

Request options

The options hash can be passed with options for the request. Currently supported settings are: timeout.

@client.members.get(
  params: { guid: 'abc123' },
  options: { timeout: 0.5 }
)