Project

alloy-api

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A wrapper for the Alloy.co API. Helps to build KYC policy support into applications.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 0.18
 Project Readme

⚠️ This codebase is no longer maintained! ⚠️ The alloy-api gem is still available from RubyGems.org, but is no longer maintained and will not receive updates or bugfixes.

Alloy API

A simple gem to wrap Alloy.co's API for doing KYC in ruby applications.

Installation

Add this line to your application's Gemfile:

gem 'alloy-api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install alloy-api

Usage

Start by requiring the api:

require 'alloy-api'

Then set the token and secret for the workflow to use:

Alloy::Api.api_token = 'provided by the workflow'
Alloy::Api.api_secret = 'provided by the workflow'

If using Rails, this can be done in either the environment files or an initializer, but remember not to include the raw keys in repositories!

Also, if using a sandbox, set the uri:

Alloy::Api.api_uri = 'https://sandbox.alloy.co/' # Be sure to include the trailing slash!

The API supports multiple endpoints as well. The default endpoint is called :main, but additional endpoints can be added:

Alloy::Api.set_endpoint(:other_endpoint, '<api_token>', '<api_secret', '<api_uri>(optional - use for sandbox)')

The Alloy.co api methods are implemented by the Api class. Most take a set of options, including headers and body:

Alloy::Api.parameters(method: 'get') # The default method is 'post' - this method will get required/optional parameters for running evaluations
Alloy::Api.evaluations(body: { first_name: 'John', last_name: 'Smith' }, headers: { 'Alloy-Refresh-Cache': 'true' }) # Runs an evaluation. Headers can be set as well, but the Content-Type and Authorization are automatic
Alloy::Api.parameters(method: 'get', endpoint: :other_endpoint) # use a different endpoint - allowing for multiple workflows to be used
Alloy::Api.some_method(body: "hello world", body_encoding: :to_s) # use to_s on the body object instead of to_json. Important for non-json uploads

License

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