onfido 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3159a3e9bff94cd01155eabee9d77b7785c3eab
4
- data.tar.gz: a67a5dd889545159c742a15fe12ac89630fb31a1
3
+ metadata.gz: f5ff31b07bd57afd22994fbf3cdca9b87a445f48
4
+ data.tar.gz: 725b94b57bb42062a18dc181996275b5e70c511a
5
5
  SHA512:
6
- metadata.gz: 8577a2bc2a1f1b176f3a487f6ae16a8a9ea3dfeff4db962f63475e5c5a1942bb92c80f076d7e2a78f2551b36208a905e3e6406f094be7df8660f03f287f864fc
7
- data.tar.gz: 6eccfff6eb4d0b663420680d60034afbf9346559c74eea5a7f0cd059c458f320e7bb639f45456103f666bf1fb64800a91b27891863168659667b6eb848f2c583
6
+ metadata.gz: 86a378c7321ddedea578b7576dbff36af63bcf6ec00bce990fd17dd3c52661aa07ec5a66584185b9617eab4517310244b398d4c0ec3f7cf7d767d7cb852de60b
7
+ data.tar.gz: 5845d5e243a8d759d4651e9b13325155ac515ba7097fbc7d77182c945c5533808372ed8c613d4ed1026afdc091b5aeb7d3027df561b41fb7b2444b52edc34a8e
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ## v0.2.0, 9 February 2015
1
+ ## v0.3.0, 16 March 2016
2
+
3
+ - Add support for `Onfido::Webhook` resource
4
+
5
+ ## v0.2.0, 9 February 2016
2
6
 
3
7
  - BREAKING: adds `Onfido::ServerError`, which is raised whenever Onfido responds
4
8
  with a 5xx code. Previously `Onfido::RequestError` would have been raised, but
data/lib/onfido.rb CHANGED
@@ -16,6 +16,7 @@ require 'onfido/applicant'
16
16
  require 'onfido/document'
17
17
  require 'onfido/check'
18
18
  require 'onfido/report'
19
+ require 'onfido/webhook'
19
20
  require 'onfido/api'
20
21
 
21
22
  module Onfido
@@ -1,3 +1,3 @@
1
1
  module Onfido
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
@@ -0,0 +1,18 @@
1
+ module Onfido
2
+ class Webhook < Resource
3
+ def create(payload)
4
+ post(
5
+ url: url_for('webhooks'),
6
+ payload: payload
7
+ )
8
+ end
9
+
10
+ def all
11
+ get(
12
+ url: url_for("webhooks"),
13
+ payload: {}
14
+ )
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,40 @@
1
+ describe Onfido::Webhook do
2
+ subject(:webhook) { described_class.new }
3
+ let(:params) do
4
+ {
5
+ "url" => "https://webhookendpoint.url",
6
+ "enabled" => true,
7
+ "events" => [
8
+ "report completion",
9
+ "report withdrawal",
10
+ "check completion",
11
+ "check in progress"
12
+ ]
13
+ }
14
+ end
15
+
16
+ describe "#create" do
17
+ it "cretes the webhook" do
18
+ response = webhook.create(params)
19
+ expect(response['id']).to_not be_nil
20
+ end
21
+
22
+ it "responds with the right url" do
23
+ response = webhook.create(params)
24
+ expect(response["url"]).to eq params["url"]
25
+ end
26
+ end
27
+
28
+ describe "#all" do
29
+ it "returns all the registered webhooks" do
30
+ response = webhook.all
31
+ expect(response["webhooks"].count).to eq 2
32
+ end
33
+
34
+ it "returns with id" do
35
+ response = webhook.all
36
+ expect(response["webhooks"][0]["id"]).to_not be_nil
37
+ expect(response["webhooks"][1]["id"]).to_not be_nil
38
+ end
39
+ end
40
+ end
@@ -43,6 +43,15 @@ class FakeOnfidoAPI < Sinatra::Base
43
43
  json_response(200, 'report.json')
44
44
  end
45
45
 
46
+ post '/v1/webhooks' do
47
+ json_response(201, 'webhook.json')
48
+ end
49
+
50
+ get '/v1/webhooks' do
51
+ json_response(200, 'webhooks.json')
52
+ end
53
+
54
+
46
55
  get '/v1/4xx_response' do
47
56
  json_response(422, '4xx_response.json')
48
57
  end
@@ -0,0 +1,13 @@
1
+ {
2
+ "id": "fcb73186-0733-4f6f-9c57-d9d5ef979443",
3
+ "url": "https://webhookendpoint.url",
4
+ "token": "yV85IsmuYwmjQGlZ",
5
+ "enabled": true,
6
+ "href": "/v1/webhooks/fcb73186-0733-4f6f-9c57-d9d5ef979443",
7
+ "events": [
8
+ "report completion",
9
+ "report withdrawal",
10
+ "check completion",
11
+ "check in progress"
12
+ ]
13
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "webhooks": [
3
+ {
4
+ "id": "dd0a89e4-d44e-417a-aec4-01137d01ae59",
5
+ "url": "https://demo.com","enabled":false,
6
+ "href": "/v1/webhooks/dd0a89e4-d44e-417a-aec4-01137d01ae59",
7
+ "events":
8
+ [
9
+ "check in progress"
10
+ ]
11
+ },
12
+ {
13
+ "id": "bfc727a8-f7bf-4073-b123-ed70a70f58e5",
14
+ "url": "https://demo2.com",
15
+ "enabled": true,
16
+ "href": "/v1/webhooks/bfc727a8-f7bf-4073-b123-ed70a70f58e5",
17
+ "events":
18
+ [
19
+ "report completion",
20
+ "report withdrawal",
21
+ "check in progress",
22
+ "check completion"
23
+ ]
24
+ }
25
+ ]
26
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onfido
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pericles Theodorou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-09 00:00:00.000000000 Z
12
+ date: 2016-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -155,6 +155,7 @@ files:
155
155
  - lib/onfido/report.rb
156
156
  - lib/onfido/resource.rb
157
157
  - lib/onfido/version.rb
158
+ - lib/onfido/webhook.rb
158
159
  - onfido.gemspec
159
160
  - spec/integrations/address_spec.rb
160
161
  - spec/integrations/applicant_spec.rb
@@ -162,6 +163,7 @@ files:
162
163
  - spec/integrations/document_spec.rb
163
164
  - spec/integrations/exceptions_spec.rb
164
165
  - spec/integrations/report_spec.rb
166
+ - spec/integrations/webhook_spec.rb
165
167
  - spec/onfido/connection_error_spec.rb
166
168
  - spec/onfido/request_error_spec.rb
167
169
  - spec/onfido/resource_spec.rb
@@ -178,6 +180,8 @@ files:
178
180
  - spec/support/fixtures/report.json
179
181
  - spec/support/fixtures/reports.json
180
182
  - spec/support/fixtures/unexpected_error_format.json
183
+ - spec/support/fixtures/webhook.json
184
+ - spec/support/fixtures/webhooks.json
181
185
  homepage: http://github.com/hvssle/onfido
182
186
  licenses:
183
187
  - MIT
@@ -209,6 +213,7 @@ test_files:
209
213
  - spec/integrations/document_spec.rb
210
214
  - spec/integrations/exceptions_spec.rb
211
215
  - spec/integrations/report_spec.rb
216
+ - spec/integrations/webhook_spec.rb
212
217
  - spec/onfido/connection_error_spec.rb
213
218
  - spec/onfido/request_error_spec.rb
214
219
  - spec/onfido/resource_spec.rb
@@ -225,3 +230,5 @@ test_files:
225
230
  - spec/support/fixtures/report.json
226
231
  - spec/support/fixtures/reports.json
227
232
  - spec/support/fixtures/unexpected_error_format.json
233
+ - spec/support/fixtures/webhook.json
234
+ - spec/support/fixtures/webhooks.json