Skip to content

Instantly share code, notes, and snippets.

@joninvski
Last active June 25, 2019 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joninvski/96d8fa70cc6eea59ad536505a943ad4f to your computer and use it in GitHub Desktop.
Save joninvski/96d8fa70cc6eea59ad536505a943ad4f to your computer and use it in GitHub Desktop.

Ruby Example

Read csv

require 'csv'
 
data = CSV.read('suspects.csv')
 
data.each { |r|
  print("Line -> #{r}\n")
}

Create applicant

require 'rest-client'
require 'json'
 
headers = {
        'Authorization' => "Token token=#{token}",
        'Content-Type' => "application/json",
      }
 
applicant = RestClient.post('https://api.onfido.com/v2/applicants',
                {first_name:'John', last_name:'Smith', email:'abcd@abc.pt'}.to_json,
                headers=headers,
                )
print(applicant)

Submit document

require 'rest-client'
require 'json'
 
headers = {
        'Authorization' => "Token token=#{token}",
      }
 
RestClient.post(
  "https://api.onfido.com/v2/applicants/#{applicant_id}/documents",
  {  
    file: File.new('path_to_image/image.png'),
    type:'passport', multipart: true, side: 'front'
  },
  headers=headers
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment