Giter Site home page Giter Site logo

sumsub-ruby-sdk's Introduction

SumSub Ruby SDK

This gem is an unofficial SDK for the SumSub API.

Installation

Add this line to your application's Gemfile:

gem 'sumsub-ruby-sdk', '~> 0.1.3', require: 'sumsub'

And then execute:

$ bundle install

Configuration and Usage

You can configure your credentials using Sumsub::Configure block. There are three keys you can inform: token, secret_key and production. The token and secret key you need to generate from your SumSub account, and production is a boolean value where you specify if you wanna use SumSub production or test environment. To use the test environment, just set production as false.

Sumsub.configure do |config|
  config.token = your_token
  config.secret_key = your_secret_key
  config.production = false # is true by default
end

Use the Sumsub::Request to call the methods that access SumSub API endpoints. Check it out the implemented methods to know what is already available to be used.

For requests where you need to inform full objects in the request's body, Sumsub::Struct have some models you can use to easily fill the necessary data for the request. Check it out the models available here.

Note: To use Sumsub::Struct or not is up to you. A simple ruby hash is a viable option too. Under the hood we call to_json to serialize it, so just ensure that this method is available and does what we expect of him: transform your object in a json string.

Usage example:

An applicant is an user that will go into the KYC process.

  • Create the applicant;
  • Add an ID document to it;
  • Retrieve the current applicant's status.
request = Sumsub::Request.new

# If you didn't set your configurations on Sumsub.configure block,
# you have the option to inform it in the Request constructor, like this:
#
# request = Sumsub::Request.new(
#   token: your_token, 
#   secret_key: your_secret_key,
#   production: false
# )

applicant = Sumsub::Struct::Applicant.new(
  externalUserId: 'appt20', 
  email: '[email protected]'
)

response = request.create_applicant('basic-kyc-level', applicant)

applicant_id = response['id']

metadata = Sumsub::Struct::DocumentMetadata.new(
  idDocType: 'ID_CARD',
  country: 'BRA'
)

request.add_id_doc(
  applicant_id, 
  metadata,
  file_path: 'home/myself/Pictures/id_card.png'
)

request.get_applicant_status(applicant_id)

The return from Sumsub::Request method will always be a ruby hash (in case of success) or an instance of Sumsub::Struct::ErrorResponse (in case error).

Development

Run bin/setup to install dependencies. For an interactive prompt that will allow you to experiment, run bin/console.

Run bundle exec rspec, if none error appears you're ready to go.

License

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

sumsub-ruby-sdk's People

Contributors

norcle avatar rwehresmann avatar ydakuka avatar

Watchers

 avatar

Forkers

bitzlato

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.