Ruby client for BlockScore Cognito API
Clone or download
Latest commit 10df45b Apr 14, 2017

README.md

Cognito Client CircleCI

Unofficial Ruby client for the BlockScore Cognito API. This library was designed using a command-query separation principle.

Installation

Add this line to your application's Gemfile:

gem 'cognito-client'

And then execute:

$ bundle

In your code or in IRB you can include the library with:

require 'cognito/client'

Usage

Creating a client

client = Cognito::Client.create(
  api_key:     'your-api-key',
  api_secret:  'your-api-secret',
  uri:         'https://sandbox.cognitohq.com',
  api_version: '2016-09-01'
)

Creating a profile

profile = client.create_profile

Create an identity search with phone and name

search = client.create_identity_search(
  profile_id:   profile.data.id,
  phone_number: '+14151231234',
  name: { # optional
    first: 'Leslie',
    last:  'Knope'
  }
)

Creating an identity assessment for the search

assessment = search.create_assessment(
  phone_number: '+14151231234',
  name: {
    first: 'Leslie',
    last:  'Doe'
  }
)

Traversing the data

The client automatically links the resource relationships allowing you to make calls like:

search.data.identity_records.first.names.map(&:attributes)

# [
#   { :first=>"LESLIE", :middle=>"BARBARA", :last=>"KNOPE" },
#   {:first=>"LESLIE", :middle=>nil, :last=>"KNOPE-WYATT" }
# ]

Running the test suite

bundle exec rspec

Running the CI tasks

bundle exec rake ci

License

The gem is available as open source under the terms of the MIT License.