onfido 2.1.0 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0b036d234a60e209cbc230d2c4e59ae7cded8f49f8639b63f3d0589610043fc
4
- data.tar.gz: 736290686f770587e2a270921d34a2a8b78015c2e3539be5a476980318314ad3
3
+ metadata.gz: 601240f564ef7c2e14fa481011fd428d3ee46234e877387f5dee8e369181bde7
4
+ data.tar.gz: 4d6808f5c9ed80267b73f54907619cc548924d8e62cc36909b8eb6acb1e71226
5
5
  SHA512:
6
- metadata.gz: afb5f59c5836aa78326f82adbcf05a3620a4bbce772e8f03a6b5e715550720eeaf511b267a9cbac5c800bec16edad0f7e6eba466d2bfbcd96746d8fc9f00efc2
7
- data.tar.gz: 707e28800455819c2f2a1c1585f68a302d3d8e8e62ccc186838f37fc110345da8dcdd5310857ebe49e9f6ef218ae7122af1a4b9655e6356ace519c5ff42f17fd
6
+ metadata.gz: 458f2220666b891e81034ac34cd49781d950454dbe2ed1e528c5f6a000fa327903cb6b3d49959f0e0c788dfd272770d20a995396b6457c697c04b3f49667f762
7
+ data.tar.gz: 16c4524637abf578ce72cc66a4e94903d945599d5ccfb8bf2aa057a59763c5ad0f2550dc708cdba85092a3b25117dd3107fb7257148f2665590733f9f161d9cc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v2.1.1, 01 February 2022
2
+
3
+ - Send params as json
4
+ - Remove .travis.yml
5
+ - Update README.md link
6
+
1
7
  ## v2.1.0, 23 June 2021
2
8
 
3
9
  - Support Onfido API version 3.2
data/README.md CHANGED
@@ -76,7 +76,7 @@ onfido = Onfido::API.new(
76
76
 
77
77
  ## Verifying webhooks
78
78
 
79
- 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.
79
+ Each webhook endpoint has a secret token, generated automatically and [exposed](https://documentation.onfido.com/#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.
80
80
 
81
81
  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.
82
82
 
@@ -90,7 +90,7 @@ else
90
90
  end
91
91
  ```
92
92
 
93
- Read more at https://onfido.com/documentation#webhook-security
93
+ Read more at https://developers.onfido.com/guide/manual-webhook-signature-verification#webhook-security
94
94
 
95
95
  ## Contributing
96
96
 
@@ -4,6 +4,7 @@ module Onfido
4
4
  class Resource # rubocop:todo Metrics/ClassLength
5
5
  VALID_HTTP_METHODS = %i[get post put delete].freeze
6
6
  REQUEST_TIMEOUT_HTTP_CODE = 408
7
+ ADDITIONAL_HEADERS = { 'Content-Type' => 'application/json; charset=utf-8' }.freeze
7
8
 
8
9
  def initialize(options)
9
10
  @rest_client = options.rest_client
@@ -14,19 +15,22 @@ module Onfido
14
15
  attr_reader :rest_client
15
16
 
16
17
  def get(path:)
17
- handle_request { rest_client[path].get }
18
+ handle_request { rest_client[path].get(ADDITIONAL_HEADERS) }
18
19
  end
19
20
 
20
- def post(path:, payload: nil)
21
- handle_request { rest_client[path].post(payload) }
21
+ def post(path:, payload: nil, send_json: true)
22
+ parsed_payload = send_json ? payload.to_json : payload
23
+ additional_headers = send_json ? ADDITIONAL_HEADERS : {}
24
+
25
+ handle_request { rest_client[path].post(parsed_payload, additional_headers) }
22
26
  end
23
27
 
24
28
  def put(path:, payload: nil)
25
- handle_request { rest_client[path].put(payload) }
29
+ handle_request { rest_client[path].put(payload.to_json, ADDITIONAL_HEADERS) }
26
30
  end
27
31
 
28
32
  def delete(path:)
29
- handle_request { rest_client[path].delete }
33
+ handle_request { rest_client[path].delete(ADDITIONAL_HEADERS) }
30
34
  end
31
35
 
32
36
  def handle_request
@@ -10,7 +10,7 @@ module Onfido
10
10
  payload[:file] = file
11
11
  payload[:type] = type
12
12
 
13
- post(path: 'documents', payload: payload)
13
+ post(path: 'documents', payload: payload, send_json: false)
14
14
  end
15
15
 
16
16
  def find(document_id)
@@ -9,7 +9,7 @@ module Onfido
9
9
  payload[:applicant_id] = applicant_id
10
10
  payload[:file] = file
11
11
 
12
- post(path: 'live_photos', payload: payload)
12
+ post(path: 'live_photos', payload: payload, send_json: false)
13
13
  end
14
14
 
15
15
  def find(live_photo_id)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onfido
4
- VERSION = '2.1.0'
4
+ VERSION = '2.1.1'
5
5
  end
@@ -9,6 +9,16 @@ RSpec.shared_context 'fake onfido api' do
9
9
  end
10
10
 
11
11
  class FakeOnfidoAPI < Sinatra::Base # rubocop:disable Metrics/ClassLength
12
+ before do
13
+ begin
14
+ if request.content_type == "application/json; charset=utf-8"
15
+ body_parameters = JSON.parse(request.body.read)
16
+ params.merge!(body_parameters) if body_parameters
17
+ end
18
+ rescue JSON::ParserError
19
+ end
20
+ end
21
+
12
22
  get '/v3.2/addresses/pick' do
13
23
  json_response(200, 'addresses.json')
14
24
  end
@@ -155,7 +165,6 @@ class FakeOnfidoAPI < Sinatra::Base # rubocop:disable Metrics/ClassLength
155
165
  end
156
166
 
157
167
  delete '/v3.2/webhooks/:id' do
158
- content_type 'application/json; charset=utf-8'
159
168
  status 204
160
169
  end
161
170
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onfido
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Onfido
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-24 00:00:00.000000000 Z
11
+ date: 2022-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -122,7 +122,6 @@ files:
122
122
  - ".gitignore"
123
123
  - ".rspec"
124
124
  - ".rubocop.yml"
125
- - ".travis.yml"
126
125
  - CHANGELOG.md
127
126
  - Gemfile
128
127
  - LICENSE
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
-
4
- rvm:
5
- - 2.4
6
- - 2.5
7
- - 2.6
8
- - 2.7
9
- - 3.0
10
-
11
- script:
12
- - bundle exec rubocop
13
- - bundle exec rspec spec