onfido 0.14.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.rubocop.yml +4 -0
 - data/.travis.yml +3 -7
 - data/CHANGELOG.md +21 -0
 - data/LICENSE +2 -1
 - data/README.md +59 -73
 - data/lib/onfido.rb +1 -1
 - data/lib/onfido/api.rb +4 -4
 - data/lib/onfido/configuration.rb +4 -4
 - data/lib/onfido/resource.rb +3 -6
 - data/lib/onfido/resources/address.rb +1 -4
 - data/lib/onfido/resources/applicant.rb +6 -6
 - data/lib/onfido/resources/check.rb +10 -14
 - data/lib/onfido/resources/document.rb +11 -11
 - data/lib/onfido/resources/extraction.rb +9 -0
 - data/lib/onfido/resources/live_photo.rb +9 -14
 - data/lib/onfido/resources/live_video.rb +5 -8
 - data/lib/onfido/resources/report.rb +8 -9
 - data/lib/onfido/resources/sdk_token.rb +3 -5
 - data/lib/onfido/resources/webhook.rb +11 -9
 - data/lib/onfido/version.rb +1 -1
 - data/onfido.gemspec +6 -7
 - data/spec/integrations/address_spec.rb +1 -0
 - data/spec/integrations/applicant_spec.rb +21 -37
 - data/spec/integrations/check_spec.rb +13 -23
 - data/spec/integrations/document_spec.rb +16 -17
 - data/spec/integrations/exceptions_spec.rb +12 -14
 - data/spec/integrations/extraction_spec.rb +19 -0
 - data/spec/integrations/live_photo_spec.rb +12 -13
 - data/spec/integrations/live_video_spec.rb +7 -10
 - data/spec/integrations/report_spec.rb +11 -13
 - data/spec/integrations/sdk_token_spec.rb +5 -5
 - data/spec/integrations/webhook_spec.rb +35 -20
 - data/spec/onfido/resource_spec.rb +10 -14
 - data/spec/onfido_spec.rb +9 -10
 - data/spec/support/fake_onfido_api.rb +53 -78
 - data/spec/support/fixtures/applicant.json +21 -42
 - data/spec/support/fixtures/check.json +4 -4
 - data/spec/support/fixtures/checks.json +4 -4
 - data/spec/support/fixtures/document.json +2 -2
 - data/spec/support/fixtures/documents.json +8 -8
 - data/spec/support/fixtures/extraction.json +23 -0
 - data/spec/support/fixtures/live_photo.json +3 -3
 - data/spec/support/fixtures/live_photos.json +6 -6
 - data/spec/support/fixtures/live_video.json +3 -3
 - data/spec/support/fixtures/live_videos.json +4 -4
 - data/spec/support/fixtures/not_scheduled_for_deletion_error.json +7 -0
 - data/spec/support/fixtures/report.json +4 -4
 - data/spec/support/fixtures/reports.json +8 -8
 - data/spec/support/fixtures/webhook.json +6 -5
 - data/spec/support/fixtures/webhooks.json +17 -12
 - metadata +19 -40
 - data/lib/onfido/resources/report_type_group.rb +0 -11
 - data/spec/integrations/report_type_group_spec.rb +0 -19
 - data/spec/support/fixtures/check_with_expanded_reports.json +0 -30
 - data/spec/support/fixtures/checks_with_expanded_reports.json +0 -34
 - data/spec/support/fixtures/report_type_group.json +0 -25
 - data/spec/support/fixtures/report_type_groups.json +0 -30
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5402f96702de9c0251f8c92ac14739b1cf54ad9a5336cf63c7088e4cc45dc0ae
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 89c7091cf1059f7eb4db9d96ae6c8ace2ca7176961524ba886b12ba3969cf462
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 6dce59eeee514ce3371b8c03367f7e2c772d26dfe57231b4f49c13a3073ca233b4089798ee7e3a7e451b2e0b7e64d035f7ee4307bb902876b160053107652664
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 92dd31829e491e612556caaf098dba388d701dfade3e755625e2199d2fbb58eaa5f621f1bdc9b8a8c95adf4753b22bb740430933e7c6b4789ed9ff8388485d44
         
     | 
    
        data/.rubocop.yml
    CHANGED
    
    
    
        data/.travis.yml
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,3 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## v1.1.1, 12 March 2021
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            - Send the postcode in the query string for the address picker endpoint
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## v1.1.0, 14 Aug 2020
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            - Add User-Agent header
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Add support for CA region
         
     | 
| 
      
 9 
     | 
    
         
            +
            - Add extractions endpoint
         
     | 
| 
      
 10 
     | 
    
         
            +
            - Add webhook deletion endpoint
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            ## v1.0.0, 13 Jan 2020
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            - Support Onfido API version 3
         
     | 
| 
      
 15 
     | 
    
         
            +
            - Drop support for Onfido API version 2
         
     | 
| 
      
 16 
     | 
    
         
            +
            - To upgrade from 0.15.0 see the v2 to v3 migration [guide](https://developers.onfido.com/guide/v2-to-v3-migration-guide)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            ## v0.15.0, 4 Feb 2019
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            - Add Check#find_by_url method (@ctrlaltdylan)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       1 
22 
     | 
    
         
             
            ## v0.14.0, 28 Jan 2019
         
     | 
| 
       2 
23 
     | 
    
         | 
| 
       3 
24 
     | 
    
         
             
            - Add support for applicant deletion and restore endpoints
         
     | 
    
        data/LICENSE
    CHANGED
    
    | 
         @@ -1,6 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            The MIT License (MIT)
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            Copyright (c) 2015 Hassle
         
     | 
| 
      
 3 
     | 
    
         
            +
            Original work Copyright (c) 2015 Hassle
         
     | 
| 
      
 4 
     | 
    
         
            +
            Modified work Copyright 2019 Onfido
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
6 
     | 
    
         
             
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
       6 
7 
     | 
    
         
             
            of this software and associated documentation files (the "Software"), to deal
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -3,28 +3,29 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            A thin wrapper for Onfido's API.
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            [](http://badge.fury.io/rb/onfido)
         
     | 
| 
       6 
     | 
    
         
            -
            [](https://travis-ci.org/onfido/onfido-ruby)
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            This gem supports  
     | 
| 
      
 8 
     | 
    
         
            +
            This gem supports only `v3` of Onfido's API from version `1.0.0` onwards. The latest version that supports `v2` of Onfido's API is `0.15.0`. `v1` of Onfido's API is deprecated.
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            The gem is compatible with Ruby 2.2.0 and onwards. Earlier versions of Ruby have [reached end-of-life](https://www.ruby-lang.org/en/news/2017/04/01/support-of-ruby-2-1-has-ended/), are no longer supported and no longer receive security fixes.
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            Refer to Onfido's [API documentation](https://documentation.onfido.com) for details of the expected requests and responses.
         
     | 
| 
       9 
13 
     | 
    
         | 
| 
       10 
14 
     | 
    
         
             
            ## Installation
         
     | 
| 
       11 
15 
     | 
    
         | 
| 
       12 
16 
     | 
    
         
             
            Add this line to your application's Gemfile:
         
     | 
| 
       13 
17 
     | 
    
         | 
| 
       14 
18 
     | 
    
         
             
            ```ruby
         
     | 
| 
       15 
     | 
    
         
            -
            gem 'onfido', '~>  
     | 
| 
      
 19 
     | 
    
         
            +
            gem 'onfido', '~> 1.1.1'
         
     | 
| 
       16 
20 
     | 
    
         
             
            ```
         
     | 
| 
       17 
21 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            The gem is compatible with Ruby 2.2.0 and onwards. Earlier versions of Ruby have [reached end-of-life](https://www.ruby-lang.org/en/news/2017/04/01/support-of-ruby-2-1-has-ended/), are no longer supported and no longer receive security fixes.
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
22 
     | 
    
         
             
            ## Configuration
         
     | 
| 
       21 
23 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
            There are  
     | 
| 
      
 24 
     | 
    
         
            +
            There are 5 configuration options:
         
     | 
| 
       23 
25 
     | 
    
         | 
| 
       24 
26 
     | 
    
         
             
            ```ruby
         
     | 
| 
       25 
27 
     | 
    
         
             
            Onfido.configure do |config|
         
     | 
| 
       26 
     | 
    
         
            -
              config.api_key = ' 
     | 
| 
       27 
     | 
    
         
            -
              config.api_version = 'v2'
         
     | 
| 
      
 28 
     | 
    
         
            +
              config.api_key = '<YOUR_API_KEY>'
         
     | 
| 
       28 
29 
     | 
    
         
             
              config.logger = Logger.new(STDOUT)
         
     | 
| 
       29 
30 
     | 
    
         
             
              config.open_timeout = 30
         
     | 
| 
       30 
31 
     | 
    
         
             
              config.read_timeout = 80
         
     | 
| 
         @@ -39,6 +40,9 @@ The gem will use the default region if no region is specified. 
     | 
|
| 
       39 
40 
     | 
    
         
             
            To specify the US region do:
         
     | 
| 
       40 
41 
     | 
    
         
             
            `config.region = :us`
         
     | 
| 
       41 
42 
     | 
    
         | 
| 
      
 43 
     | 
    
         
            +
            To specify the CA region do:
         
     | 
| 
      
 44 
     | 
    
         
            +
            `config.region = :ca`
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
       42 
46 
     | 
    
         
             
            See https://documentation.onfido.com/#regions for supported regions.
         
     | 
| 
       43 
47 
     | 
    
         | 
| 
       44 
48 
     | 
    
         
             
            ## Usage
         
     | 
| 
         @@ -46,46 +50,46 @@ See https://documentation.onfido.com/#regions for supported regions. 
     | 
|
| 
       46 
50 
     | 
    
         
             
            You can make API calls by using an instance of the `API` class:
         
     | 
| 
       47 
51 
     | 
    
         | 
| 
       48 
52 
     | 
    
         
             
            ```ruby
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
      
 53 
     | 
    
         
            +
            onfido = Onfido::API.new
         
     | 
| 
       50 
54 
     | 
    
         
             
            ```
         
     | 
| 
       51 
55 
     | 
    
         | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
      
 56 
     | 
    
         
            +
            You can also set an API key as follows, instead of in the initializer configuration:
         
     | 
| 
       53 
57 
     | 
    
         | 
| 
       54 
58 
     | 
    
         
             
            ```ruby
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
      
 59 
     | 
    
         
            +
            onfido = Onfido::API.new(api_key: '<YOUR_API_KEY>')
         
     | 
| 
       56 
60 
     | 
    
         
             
            ```
         
     | 
| 
       57 
61 
     | 
    
         | 
| 
       58 
62 
     | 
    
         
             
            ### Resources
         
     | 
| 
       59 
63 
     | 
    
         | 
| 
       60 
64 
     | 
    
         
             
            All resources share the same interface when making API calls. Use `.create` to create a resource, `.find` to find one, and `.all` to fetch all resources.
         
     | 
| 
       61 
65 
     | 
    
         | 
| 
       62 
     | 
    
         
            -
            **Note:** *All param keys should be  
     | 
| 
      
 66 
     | 
    
         
            +
            **Note:** *All param keys should be symbols e.g. `{ report_names: ['document'] }`*
         
     | 
| 
       63 
67 
     | 
    
         | 
| 
       64 
68 
     | 
    
         
             
            #### Applicants
         
     | 
| 
       65 
69 
     | 
    
         | 
| 
       66 
70 
     | 
    
         
             
            Applicants are the object upon which Onfido checks are performed.
         
     | 
| 
       67 
71 
     | 
    
         | 
| 
       68 
72 
     | 
    
         
             
            ```ruby
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
      
 73 
     | 
    
         
            +
            onfido.applicant.create(params)                  # => Creates an applicant
         
     | 
| 
      
 74 
     | 
    
         
            +
            onfido.applicant.update('<APPLICANT_ID>', params)  # => Updates an applicant
         
     | 
| 
      
 75 
     | 
    
         
            +
            onfido.applicant.destroy('<APPLICANT_ID>')         # => Schedule an applicant for deletion
         
     | 
| 
      
 76 
     | 
    
         
            +
            onfido.applicant.restore('<APPLICANT_ID>')         # => Restore an applicant scheduled for deletion
         
     | 
| 
      
 77 
     | 
    
         
            +
            onfido.applicant.find('<APPLICANT_ID>')            # => Finds a single applicant
         
     | 
| 
      
 78 
     | 
    
         
            +
            onfido.applicant.all                             # => Returns all applicants
         
     | 
| 
       75 
79 
     | 
    
         
             
            ```
         
     | 
| 
       76 
80 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
            **Note:** Calling  
     | 
| 
      
 81 
     | 
    
         
            +
            **Note:** Calling `onfido.applicant.destroy` adds the applicant and all associated documents, photos, videos, checks, and reports to the deletion queue. They will be deleted 20 days after the request is made. An applicant that is scheduled for deletion can be restored but applicants that have been permanently deleted cannot.
         
     | 
| 
       78 
82 
     | 
    
         
             
            See https://documentation.onfido.com/#delete-applicant for more information.
         
     | 
| 
       79 
83 
     | 
    
         | 
| 
       80 
84 
     | 
    
         
             
            #### Documents
         
     | 
| 
       81 
85 
     | 
    
         | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
      
 86 
     | 
    
         
            +
            Some report types require identity documents (passport, driving licence etc.) in order to be processed.
         
     | 
| 
       83 
87 
     | 
    
         | 
| 
       84 
88 
     | 
    
         
             
            ```ruby
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
      
 89 
     | 
    
         
            +
            onfido.document.create(applicant_id: '<APPLICANT_ID>', file: <FILE>, type: 'passport') # => Creates a document
         
     | 
| 
      
 90 
     | 
    
         
            +
            onfido.document.find('<DOCUMENT_ID>')      # => Finds a document
         
     | 
| 
      
 91 
     | 
    
         
            +
            onfido.document.download('<DOCUMENT_ID>')  # => Downloads a document as a binary data
         
     | 
| 
      
 92 
     | 
    
         
            +
            onfido.document.all('<APPLICANT_ID>')      # => Returns all documents belonging to an applicant
         
     | 
| 
       89 
93 
     | 
    
         
             
            ```
         
     | 
| 
       90 
94 
     | 
    
         | 
| 
       91 
95 
     | 
    
         
             
            **Note:** The file parameter must be a `File`-like object which responds to `#read` and `#path`.
         
     | 
| 
         @@ -93,15 +97,17 @@ Previous versions of this gem supported providing a URL to a file accessible ove 
     | 
|
| 
       93 
97 
     | 
    
         
             
            to a file in the local filesystem. You should instead load the file yourself and then pass it in
         
     | 
| 
       94 
98 
     | 
    
         
             
            to `#create`.
         
     | 
| 
       95 
99 
     | 
    
         | 
| 
      
 100 
     | 
    
         
            +
            See https://documentation.onfido.com/#document-types for example document types.
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
       96 
102 
     | 
    
         
             
            #### Live Photos
         
     | 
| 
       97 
103 
     | 
    
         | 
| 
       98 
     | 
    
         
            -
            Live  
     | 
| 
      
 104 
     | 
    
         
            +
            Live photos are images of the applicant’s face, typically taken at the same time as documents are provided. These photos are used to perform Facial Similarity Photo reports on the applicant.
         
     | 
| 
       99 
105 
     | 
    
         | 
| 
       100 
106 
     | 
    
         
             
            ```ruby
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
      
 107 
     | 
    
         
            +
            onfido.live_photo.create(applicant_id: '<APPLICANT_ID>', file: <FILE>) # => Creates a live photo
         
     | 
| 
      
 108 
     | 
    
         
            +
            onfido.live_photo.find('<LIVE_PHOTO_ID>')      # => Finds a live photo
         
     | 
| 
      
 109 
     | 
    
         
            +
            onfido.live_photo.download('<LIVE_PHOTO_ID>')  # => Downloads a live photo as binary data
         
     | 
| 
      
 110 
     | 
    
         
            +
            onfido.live_photo.all('<APPLICANT_ID>')        # => Returns all live photos belonging to an applicant
         
     | 
| 
       105 
111 
     | 
    
         
             
            ```
         
     | 
| 
       106 
112 
     | 
    
         | 
| 
       107 
113 
     | 
    
         
             
            **Note:** The file parameter must be a `File`-like object which responds to `#read` and `#path`.
         
     | 
| 
         @@ -111,48 +117,37 @@ to `#create`. 
     | 
|
| 
       111 
117 
     | 
    
         | 
| 
       112 
118 
     | 
    
         
             
            #### Checks
         
     | 
| 
       113 
119 
     | 
    
         | 
| 
       114 
     | 
    
         
            -
            Checks are  
     | 
| 
       115 
     | 
    
         
            -
            more "reports" on them.
         
     | 
| 
      
 120 
     | 
    
         
            +
            Checks are performed on an applicant. Depending on the type of check you wish to perform, different information will be required when you create an applicant. A check consists of one or more reports.
         
     | 
| 
       116 
121 
     | 
    
         | 
| 
       117 
122 
     | 
    
         
             
            ```ruby
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
      
 123 
     | 
    
         
            +
            onfido.check.create(applicant_id: '<APPLICANT_ID>', report_names: ['document', 'facial_similarity_photo']) # => Creates a check
         
     | 
| 
      
 124 
     | 
    
         
            +
            onfido.check.find('<CHECK_ID>')    # => Finds a check
         
     | 
| 
      
 125 
     | 
    
         
            +
            onfido.check.resume('<CHECK_ID>')  # => Resumes a paused check
         
     | 
| 
      
 126 
     | 
    
         
            +
            onfido.check.all('<APPLICANT_ID>') # => Returns all an applicant's checks
         
     | 
| 
       122 
127 
     | 
    
         
             
            ```
         
     | 
| 
       123 
128 
     | 
    
         | 
| 
       124 
129 
     | 
    
         
             
            #### Reports
         
     | 
| 
       125 
130 
     | 
    
         | 
| 
       126 
     | 
    
         
            -
            Reports provide details of the results of some part of a  
     | 
| 
      
 131 
     | 
    
         
            +
            Reports provide details of the results of some part of a check. They are
         
     | 
| 
       127 
132 
     | 
    
         
             
            created when a check is created, so the Onfido API only provides support for
         
     | 
| 
       128 
133 
     | 
    
         
             
            finding and listing them. For paused reports specifically, additional support for resuming and
         
     | 
| 
       129 
134 
     | 
    
         
             
             cancelling reports is also available.
         
     | 
| 
       130 
135 
     | 
    
         | 
| 
       131 
136 
     | 
    
         
             
            ```ruby
         
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
            ```
         
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
            #### Report Type Groups
         
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
            Report type groups provide a convenient way to group and organize different types of reports.
         
     | 
| 
       141 
     | 
    
         
            -
             The Onfido API only provides support for finding and listing them.
         
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       144 
     | 
    
         
            -
            api.report_type_group.find('report_type_group_id')
         
     | 
| 
       145 
     | 
    
         
            -
            api.report_type_group.all()
         
     | 
| 
      
 137 
     | 
    
         
            +
            onfido.report.find('<REPORT_ID>')    # => Finds a report
         
     | 
| 
      
 138 
     | 
    
         
            +
            onfido.report.all('<CHECK_ID>')      # => Returns all the reports in a check
         
     | 
| 
      
 139 
     | 
    
         
            +
            onfido.report.resume('<REPORT_ID>')  # => Resumes a paused report
         
     | 
| 
      
 140 
     | 
    
         
            +
            onfido.report.cancel('<REPORT_ID>')  # => Cancels a paused report
         
     | 
| 
       146 
141 
     | 
    
         
             
            ```
         
     | 
| 
       147 
142 
     | 
    
         | 
| 
       148 
143 
     | 
    
         
             
            #### Address Lookups
         
     | 
| 
       149 
144 
     | 
    
         | 
| 
       150 
145 
     | 
    
         
             
            Onfido provides an address lookup service, to help ensure well-formatted
         
     | 
| 
       151 
     | 
    
         
            -
            addresses are provided when creating  
     | 
| 
      
 146 
     | 
    
         
            +
            addresses are provided when creating applicants. To search for addresses
         
     | 
| 
       152 
147 
     | 
    
         
             
            by postcode, use:
         
     | 
| 
       153 
148 
     | 
    
         | 
| 
       154 
149 
     | 
    
         
             
            ```ruby
         
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
      
 150 
     | 
    
         
            +
            onfido.address.all('SE1 4NG') # => Returns all addresses in a given postcode
         
     | 
| 
       156 
151 
     | 
    
         
             
            ```
         
     | 
| 
       157 
152 
     | 
    
         | 
| 
       158 
153 
     | 
    
         
             
            #### Webhook Endpoints
         
     | 
| 
         @@ -161,9 +156,9 @@ Onfido allows you to set up and view your webhook endpoints via the API, as well 
     | 
|
| 
       161 
156 
     | 
    
         
             
            as through the dashboard.
         
     | 
| 
       162 
157 
     | 
    
         | 
| 
       163 
158 
     | 
    
         
             
            ```ruby
         
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
      
 159 
     | 
    
         
            +
            onfido.webhook.create(url: "https://webhook.url", events: ['report.completed', 'check.completed']) # => Registers a webhook endpoint
         
     | 
| 
      
 160 
     | 
    
         
            +
            onfido.webhook.find('<WEBHOOK_ID>')  # => Finds a single webhook endpoint
         
     | 
| 
      
 161 
     | 
    
         
            +
            onfido.webhook.all                 # => Returns all webhook endpoints
         
     | 
| 
       167 
162 
     | 
    
         
             
            ```
         
     | 
| 
       168 
163 
     | 
    
         | 
| 
       169 
164 
     | 
    
         
             
            #### SDK Tokens
         
     | 
| 
         @@ -172,26 +167,21 @@ Onfido allows you to generate JSON Web Tokens via the API in order to authentica 
     | 
|
| 
       172 
167 
     | 
    
         
             
            with Onfido's [JavaScript SDK](https://github.com/onfido/onfido-sdk-ui).
         
     | 
| 
       173 
168 
     | 
    
         | 
| 
       174 
169 
     | 
    
         
             
            ```ruby
         
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
      
 170 
     | 
    
         
            +
            onfido.sdk_token.create(applicant_id: 'applicant_id', referrer: 'referrer') # => Creates a JWT
         
     | 
| 
       176 
171 
     | 
    
         
             
            ```
         
     | 
| 
       177 
172 
     | 
    
         | 
| 
       178 
     | 
    
         
            -
            ### Pagination
         
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
       180 
     | 
    
         
            -
            All resources that support an `all` method also support pagination. By default,
         
     | 
| 
       181 
     | 
    
         
            -
            the first 20 records are fetched.
         
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
       183 
173 
     | 
    
         
             
            ### Error Handling
         
     | 
| 
       184 
174 
     | 
    
         | 
| 
       185 
     | 
    
         
            -
            There are  
     | 
| 
      
 175 
     | 
    
         
            +
            There are 3 classes of errors raised by the library, all of which subclass `Onfido::OnfidoError`:
         
     | 
| 
       186 
176 
     | 
    
         
             
            - `Onfido::ServerError` is raised whenever Onfido returns a `5xx` response
         
     | 
| 
       187 
177 
     | 
    
         
             
            - `Onfido::RequestError` is raised whenever Onfido returns any other kind of error
         
     | 
| 
       188 
178 
     | 
    
         
             
            - `Onfido::ConnectionError` is raised whenever a network error occurs (e.g., a timeout)
         
     | 
| 
       189 
179 
     | 
    
         | 
| 
       190 
     | 
    
         
            -
            All  
     | 
| 
      
 180 
     | 
    
         
            +
            All 3 error classes provide the `response_code`, `response_body`, `json_body`, `type` and `fields` of the error (although for `Onfido::ServerError` and `Onfido::ConnectionError` the last 3 are likely to be `nil`).
         
     | 
| 
       191 
181 
     | 
    
         | 
| 
       192 
182 
     | 
    
         
             
            ```ruby
         
     | 
| 
       193 
183 
     | 
    
         
             
            def create_applicant
         
     | 
| 
       194 
     | 
    
         
            -
               
     | 
| 
      
 184 
     | 
    
         
            +
              onfido.applicant.create(params)
         
     | 
| 
       195 
185 
     | 
    
         
             
            rescue Onfido::RequestError => e
         
     | 
| 
       196 
186 
     | 
    
         
             
              e.type          # => 'validation_error'
         
     | 
| 
       197 
187 
     | 
    
         
             
              e.fields        # => { "email": { "messages": ["invalid format"] } }
         
     | 
| 
         @@ -201,13 +191,13 @@ end 
     | 
|
| 
       201 
191 
     | 
    
         | 
| 
       202 
192 
     | 
    
         
             
            ## Webhooks
         
     | 
| 
       203 
193 
     | 
    
         | 
| 
       204 
     | 
    
         
            -
            Each webhook endpoint has a secret token, generated automatically and [exposed](https://onfido.com/documentation#register-webhook) in the API. When sending a request, Onfido includes a signature computed using the request body and this token in the `X-Signature` header.
         
     | 
| 
      
 194 
     | 
    
         
            +
            Each webhook endpoint has a secret token, generated automatically and [exposed](https://onfido.com/documentation#register-webhook) in the API. When sending a request, Onfido includes a signature computed using the request body and this token in the `X-SHA2-Signature` header.
         
     | 
| 
       205 
195 
     | 
    
         | 
| 
       206 
     | 
    
         
            -
             
     | 
| 
      
 196 
     | 
    
         
            +
            You should compare this provided signature to one you generate yourself with the token to verify that a webhook is a genuine request from Onfido.
         
     | 
| 
       207 
197 
     | 
    
         | 
| 
       208 
198 
     | 
    
         
             
            ```ruby
         
     | 
| 
       209 
199 
     | 
    
         
             
            if Onfido::Webhook.valid?(request.raw_post,
         
     | 
| 
       210 
     | 
    
         
            -
                                      request.headers["X-Signature"],
         
     | 
| 
      
 200 
     | 
    
         
            +
                                      request.headers["X-SHA2-Signature"],
         
     | 
| 
       211 
201 
     | 
    
         
             
                                      ENV['ONFIDO_WEBHOOK_TOKEN'])
         
     | 
| 
       212 
202 
     | 
    
         
             
              process_webhook
         
     | 
| 
       213 
203 
     | 
    
         
             
            else
         
     | 
| 
         @@ -215,15 +205,11 @@ else 
     | 
|
| 
       215 
205 
     | 
    
         
             
            end
         
     | 
| 
       216 
206 
     | 
    
         
             
            ```
         
     | 
| 
       217 
207 
     | 
    
         | 
| 
       218 
     | 
    
         
            -
             
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
       220 
     | 
    
         
            -
            - Improve test coverage with more scenarios
         
     | 
| 
       221 
     | 
    
         
            -
            - Add custom errors based on the response code
         
     | 
| 
       222 
     | 
    
         
            -
            - Improve pagination handling (use information passed in link header)
         
     | 
| 
      
 208 
     | 
    
         
            +
            Read more at https://onfido.com/documentation#webhook-security
         
     | 
| 
       223 
209 
     | 
    
         | 
| 
       224 
210 
     | 
    
         
             
            ## Contributing
         
     | 
| 
       225 
211 
     | 
    
         | 
| 
       226 
     | 
    
         
            -
            1. Fork it ( https://github.com/ 
     | 
| 
      
 212 
     | 
    
         
            +
            1. Fork it ( https://github.com/onfido/onfido-ruby/fork )
         
     | 
| 
       227 
213 
     | 
    
         
             
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
       228 
214 
     | 
    
         
             
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
       229 
215 
     | 
    
         
             
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
    
        data/lib/onfido.rb
    CHANGED
    
    | 
         @@ -16,10 +16,10 @@ require 'onfido/resources/address' 
     | 
|
| 
       16 
16 
     | 
    
         
             
            require 'onfido/resources/applicant'
         
     | 
| 
       17 
17 
     | 
    
         
             
            require 'onfido/resources/check'
         
     | 
| 
       18 
18 
     | 
    
         
             
            require 'onfido/resources/document'
         
     | 
| 
      
 19 
     | 
    
         
            +
            require 'onfido/resources/extraction'
         
     | 
| 
       19 
20 
     | 
    
         
             
            require 'onfido/resources/live_photo'
         
     | 
| 
       20 
21 
     | 
    
         
             
            require 'onfido/resources/live_video'
         
     | 
| 
       21 
22 
     | 
    
         
             
            require 'onfido/resources/report'
         
     | 
| 
       22 
     | 
    
         
            -
            require 'onfido/resources/report_type_group'
         
     | 
| 
       23 
23 
     | 
    
         
             
            require 'onfido/resources/sdk_token'
         
     | 
| 
       24 
24 
     | 
    
         
             
            require 'onfido/resources/webhook'
         
     | 
| 
       25 
25 
     | 
    
         | 
    
        data/lib/onfido/api.rb
    CHANGED
    
    | 
         @@ -28,10 +28,6 @@ module Onfido 
     | 
|
| 
       28 
28 
     | 
    
         
             
                  Onfido::Report.new(@api_key)
         
     | 
| 
       29 
29 
     | 
    
         
             
                end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                def report_type_group
         
     | 
| 
       32 
     | 
    
         
            -
                  Onfido::ReportTypeGroup.new(@api_key)
         
     | 
| 
       33 
     | 
    
         
            -
                end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
31 
     | 
    
         
             
                def sdk_token
         
     | 
| 
       36 
32 
     | 
    
         
             
                  Onfido::SdkToken.new(@api_key)
         
     | 
| 
       37 
33 
     | 
    
         
             
                end
         
     | 
| 
         @@ -43,5 +39,9 @@ module Onfido 
     | 
|
| 
       43 
39 
     | 
    
         
             
                def address
         
     | 
| 
       44 
40 
     | 
    
         
             
                  Onfido::Address.new(@api_key)
         
     | 
| 
       45 
41 
     | 
    
         
             
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                def extraction
         
     | 
| 
      
 44 
     | 
    
         
            +
                  Onfido::Extraction.new(@api_key)
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
       46 
46 
     | 
    
         
             
              end
         
     | 
| 
       47 
47 
     | 
    
         
             
            end
         
     | 
    
        data/lib/onfido/configuration.rb
    CHANGED
    
    | 
         @@ -1,10 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Onfido
         
     | 
| 
       2 
2 
     | 
    
         
             
              module Configuration
         
     | 
| 
       3 
3 
     | 
    
         
             
                REGION_HOSTS = {
         
     | 
| 
       4 
     | 
    
         
            -
                  us: "api.us.onfido.com"
         
     | 
| 
      
 4 
     | 
    
         
            +
                  us: "api.us.onfido.com",
         
     | 
| 
      
 5 
     | 
    
         
            +
                  ca: "api.ca.onfido.com"
         
     | 
| 
       5 
6 
     | 
    
         
             
                }.freeze
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
                attr_accessor :api_key, :region, :open_timeout, :read_timeout 
     | 
| 
      
 8 
     | 
    
         
            +
                attr_accessor :api_key, :region, :open_timeout, :read_timeout
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
10 
     | 
    
         
             
                def self.extended(base)
         
     | 
| 
       10 
11 
     | 
    
         
             
                  base.reset
         
     | 
| 
         @@ -19,7 +20,6 @@ module Onfido 
     | 
|
| 
       19 
20 
     | 
    
         
             
                  self.region = nil
         
     | 
| 
       20 
21 
     | 
    
         
             
                  self.open_timeout = 30
         
     | 
| 
       21 
22 
     | 
    
         
             
                  self.read_timeout = 80
         
     | 
| 
       22 
     | 
    
         
            -
                  self.api_version = 'v2'
         
     | 
| 
       23 
23 
     | 
    
         
             
                  RestClient.log = nil
         
     | 
| 
       24 
24 
     | 
    
         
             
                end
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
         @@ -41,7 +41,7 @@ module Onfido 
     | 
|
| 
       41 
41 
     | 
    
         
             
                    raise "The region \"#{region.downcase}\" is not currently supported"
         
     | 
| 
       42 
42 
     | 
    
         
             
                  end
         
     | 
| 
       43 
43 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
                  "https://#{region_host} 
     | 
| 
      
 44 
     | 
    
         
            +
                  "https://#{region_host}/v3/"
         
     | 
| 
       45 
45 
     | 
    
         
             
                end
         
     | 
| 
       46 
46 
     | 
    
         
             
              end
         
     | 
| 
       47 
47 
     | 
    
         
             
            end
         
     | 
    
        data/lib/onfido/resource.rb
    CHANGED
    
    | 
         @@ -7,15 +7,11 @@ module Onfido 
     | 
|
| 
       7 
7 
     | 
    
         
             
                  @api_key = api_key || Onfido.api_key
         
     | 
| 
       8 
8 
     | 
    
         
             
                end
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
                def url_for(path)
         
     | 
| 
       11 
     | 
    
         
            -
                  Onfido.endpoint + path
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
10 
     | 
    
         
             
                VALID_HTTP_METHODS.each do |method|
         
     | 
| 
       15 
11 
     | 
    
         
             
                  define_method method do |*args|
         
     | 
| 
       16 
12 
     | 
    
         
             
                    make_request(
         
     | 
| 
       17 
13 
     | 
    
         
             
                      method: method.to_sym,
         
     | 
| 
       18 
     | 
    
         
            -
                      url: args.first.fetch(: 
     | 
| 
      
 14 
     | 
    
         
            +
                      url: Onfido.endpoint + args.first.fetch(:path),
         
     | 
| 
       19 
15 
     | 
    
         
             
                      payload: build_query(args.first.fetch(:payload, {}))
         
     | 
| 
       20 
16 
     | 
    
         
             
                    )
         
     | 
| 
       21 
17 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -69,7 +65,8 @@ module Onfido 
     | 
|
| 
       69 
65 
     | 
    
         
             
                def headers
         
     | 
| 
       70 
66 
     | 
    
         
             
                  {
         
     | 
| 
       71 
67 
     | 
    
         
             
                    'Authorization' => "Token token=#{@api_key}",
         
     | 
| 
       72 
     | 
    
         
            -
                    'Accept' => "application/json"
         
     | 
| 
      
 68 
     | 
    
         
            +
                    'Accept' => "application/json",
         
     | 
| 
      
 69 
     | 
    
         
            +
                    'User-Agent' => "onfido-ruby/#{Onfido::VERSION}"
         
     | 
| 
       73 
70 
     | 
    
         
             
                  }
         
     | 
| 
       74 
71 
     | 
    
         
             
                end
         
     | 
| 
       75 
72 
     | 
    
         |