JuulLabs / cognito

Ruby client for BlockScore Cognito API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Ruby client for BlockScore Cognito API

License:MIT License


Languages

Language:Ruby 98.7%Language:Shell 1.3%