passfort 0.2.3 → 0.3.0

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +17 -17
  3. data/.rubocop.yml +5 -5
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +33 -28
  6. data/Gemfile +5 -5
  7. data/Gemfile.lock +91 -89
  8. data/LICENCE.txt +22 -22
  9. data/README.md +6 -6
  10. data/lib/passfort.rb +35 -35
  11. data/lib/passfort/client.rb +23 -23
  12. data/lib/passfort/endpoint.rb +10 -10
  13. data/lib/passfort/endpoint/checks.rb +19 -19
  14. data/lib/passfort/endpoint/profiles.rb +46 -46
  15. data/lib/passfort/endpoint/tasks.rb +16 -16
  16. data/lib/passfort/errors.rb +15 -15
  17. data/lib/passfort/errors/api_error.rb +16 -16
  18. data/lib/passfort/errors/chargeable_limit_reached_error.rb +12 -12
  19. data/lib/passfort/errors/invalid_api_key_error.rb +12 -12
  20. data/lib/passfort/errors/invalid_input_data_error.rb +12 -12
  21. data/lib/passfort/errors/request_error.rb +12 -12
  22. data/lib/passfort/errors/timeout_error.rb +12 -12
  23. data/lib/passfort/errors/unknown_api_error.rb +12 -12
  24. data/lib/passfort/errors/unparseable_response_error.rb +11 -11
  25. data/lib/passfort/http.rb +89 -65
  26. data/lib/passfort/resource.rb +12 -12
  27. data/lib/passfort/resource/base.rb +21 -21
  28. data/lib/passfort/resource/check.rb +10 -10
  29. data/lib/passfort/resource/company_data.rb +11 -11
  30. data/lib/passfort/resource/individual_data.rb +11 -11
  31. data/lib/passfort/resource/profile.rb +15 -15
  32. data/lib/passfort/resource/task.rb +9 -9
  33. data/lib/passfort/version.rb +5 -5
  34. data/passfort.gemspec +30 -29
  35. data/spec/fixtures/check.json +67 -67
  36. data/spec/fixtures/collected_data.json +7 -7
  37. data/spec/fixtures/company_ownership_check/check.json +78 -78
  38. data/spec/fixtures/company_ownership_check/collected_data.json +7 -7
  39. data/spec/fixtures/company_ownership_check/collected_data_update_request.json +63 -63
  40. data/spec/fixtures/company_ownership_check/profile.json +128 -128
  41. data/spec/fixtures/profile.json +128 -128
  42. data/spec/fixtures/task.json +6 -6
  43. data/spec/integration/company_ownership_check_spec.rb +74 -74
  44. data/spec/passfort/endpoint/checks_spec.rb +22 -22
  45. data/spec/passfort/endpoint/profiles_spec.rb +79 -79
  46. data/spec/passfort/endpoint/tasks_spec.rb +21 -21
  47. data/spec/passfort/http_spec.rb +130 -95
  48. data/spec/spec_helper.rb +9 -9
  49. metadata +16 -2
@@ -1,128 +1,128 @@
1
- {
2
- "applications": [
3
- {
4
- "approval_blockers": [
5
- {
6
- "blocker_type": "INCOMPLETE_TASK",
7
- "task_type": "COMPANY_VERIFY_IDENTITY"
8
- },
9
- {
10
- "blocker_type": "INCOMPLETE_TASK",
11
- "task_type": "COMPANY_IDENTIFY_AUTHORIZED_PERSONS"
12
- },
13
- {
14
- "blocker_type": "INCOMPLETE_TASK",
15
- "task_type": "COMPANY_IDENTIFY_OFFICERS"
16
- },
17
- {
18
- "blocker_type": "INCOMPLETE_TASK",
19
- "task_type": "COMPANY_IDENTIFY_BENEFICIAL_OWNERS"
20
- },
21
- {
22
- "blocker_type": "INCOMPLETE_TASK",
23
- "task_type": "COMPANY_ASSESS_SANCTIONS_EXPOSURE"
24
- },
25
- {
26
- "blocker_type": "INCOMPLETE_TASK",
27
- "task_type": "COMPANY_REVIEW_FILINGS"
28
- }
29
- ],
30
- "history": [
31
- {
32
- "date": "2018-01-15 11:39:17",
33
- "status": "APPLIED"
34
- }
35
- ],
36
- "id": "b83a64ec-f9e8-11e7-82a7-000000000000",
37
- "product": {
38
- "id": "eb299330-f63a-11e7-bc01-000000000000",
39
- "name": "Mortgage"
40
- },
41
- "status": "APPLIED"
42
- }
43
- ],
44
- "category": "APPLICANT",
45
- "checks": [],
46
- "collected_data": {
47
- "entity_type": "COMPANY",
48
- "metadata": {
49
- "country_of_incorporation": "GBR",
50
- "number": "09565115"
51
- }
52
- },
53
- "collection_steps": [],
54
- "display_name": "PassFort Limited",
55
- "document_images": [],
56
- "events": [],
57
- "has_associates": false,
58
- "has_collection_steps": false,
59
- "id": "b82b0434-f9e8-11e7-8397-000000000000",
60
- "linked_to": [],
61
- "risk": {},
62
- "role": "COMPANY_CUSTOMER",
63
- "status": "NORMAL",
64
- "tags": [],
65
- "task_progress": {
66
- "completed_count": 0,
67
- "total_count": 6
68
- },
69
- "task_types": [
70
- "COMPANY_VERIFY_IDENTITY",
71
- "COMPANY_IDENTIFY_AUTHORIZED_PERSONS",
72
- "COMPANY_IDENTIFY_OFFICERS",
73
- "COMPANY_IDENTIFY_BENEFICIAL_OWNERS",
74
- "COMPANY_ASSESS_SANCTIONS_EXPOSURE",
75
- "COMPANY_REVIEW_FILINGS"
76
- ],
77
- "tasks": [
78
- {
79
- "check_ids": [],
80
- "creation_date": "2018-01-15 11:39:17",
81
- "id": "b83e2d7e-f9e8-11e7-8229-000000000000",
82
- "is_complete": false,
83
- "is_expired": false,
84
- "type": "COMPANY_VERIFY_IDENTITY"
85
- },
86
- {
87
- "check_ids": [],
88
- "creation_date": "2018-01-15 11:39:17",
89
- "id": "b841b73e-f9e8-11e7-b17f-000000000000",
90
- "is_complete": false,
91
- "is_expired": false,
92
- "type": "COMPANY_IDENTIFY_AUTHORIZED_PERSONS"
93
- },
94
- {
95
- "check_ids": [],
96
- "creation_date": "2018-01-15 11:39:17",
97
- "id": "b843d282-f9e8-11e7-b539-000000000000",
98
- "is_complete": false,
99
- "is_expired": false,
100
- "type": "COMPANY_IDENTIFY_OFFICERS"
101
- },
102
- {
103
- "check_ids": [],
104
- "creation_date": "2018-01-15 11:39:17",
105
- "id": "b845e7f4-f9e8-11e7-a4d1-000000000000",
106
- "is_complete": false,
107
- "is_expired": false,
108
- "type": "COMPANY_IDENTIFY_BENEFICIAL_OWNERS"
109
- },
110
- {
111
- "check_ids": [],
112
- "creation_date": "2018-01-15 11:39:17",
113
- "id": "b8485a78-f9e8-11e7-86ee-000000000000",
114
- "is_complete": false,
115
- "is_expired": false,
116
- "type": "COMPANY_ASSESS_SANCTIONS_EXPOSURE"
117
- },
118
- {
119
- "check_ids": [],
120
- "creation_date": "2018-01-15 11:39:17",
121
- "id": "b84ad2de-f9e8-11e7-806b-000000000000",
122
- "is_complete": false,
123
- "is_expired": false,
124
- "type": "COMPANY_REVIEW_FILINGS"
125
- }
126
- ],
127
- "unresolved_event_types": []
128
- }
1
+ {
2
+ "applications": [
3
+ {
4
+ "approval_blockers": [
5
+ {
6
+ "blocker_type": "INCOMPLETE_TASK",
7
+ "task_type": "COMPANY_VERIFY_IDENTITY"
8
+ },
9
+ {
10
+ "blocker_type": "INCOMPLETE_TASK",
11
+ "task_type": "COMPANY_IDENTIFY_AUTHORIZED_PERSONS"
12
+ },
13
+ {
14
+ "blocker_type": "INCOMPLETE_TASK",
15
+ "task_type": "COMPANY_IDENTIFY_OFFICERS"
16
+ },
17
+ {
18
+ "blocker_type": "INCOMPLETE_TASK",
19
+ "task_type": "COMPANY_IDENTIFY_BENEFICIAL_OWNERS"
20
+ },
21
+ {
22
+ "blocker_type": "INCOMPLETE_TASK",
23
+ "task_type": "COMPANY_ASSESS_SANCTIONS_EXPOSURE"
24
+ },
25
+ {
26
+ "blocker_type": "INCOMPLETE_TASK",
27
+ "task_type": "COMPANY_REVIEW_FILINGS"
28
+ }
29
+ ],
30
+ "history": [
31
+ {
32
+ "date": "2018-01-15 11:39:17",
33
+ "status": "APPLIED"
34
+ }
35
+ ],
36
+ "id": "b83a64ec-f9e8-11e7-82a7-000000000000",
37
+ "product": {
38
+ "id": "eb299330-f63a-11e7-bc01-000000000000",
39
+ "name": "Mortgage"
40
+ },
41
+ "status": "APPLIED"
42
+ }
43
+ ],
44
+ "category": "APPLICANT",
45
+ "checks": [],
46
+ "collected_data": {
47
+ "entity_type": "COMPANY",
48
+ "metadata": {
49
+ "country_of_incorporation": "GBR",
50
+ "number": "09565115"
51
+ }
52
+ },
53
+ "collection_steps": [],
54
+ "display_name": "PassFort Limited",
55
+ "document_images": [],
56
+ "events": [],
57
+ "has_associates": false,
58
+ "has_collection_steps": false,
59
+ "id": "b82b0434-f9e8-11e7-8397-000000000000",
60
+ "linked_to": [],
61
+ "risk": {},
62
+ "role": "COMPANY_CUSTOMER",
63
+ "status": "NORMAL",
64
+ "tags": [],
65
+ "task_progress": {
66
+ "completed_count": 0,
67
+ "total_count": 6
68
+ },
69
+ "task_types": [
70
+ "COMPANY_VERIFY_IDENTITY",
71
+ "COMPANY_IDENTIFY_AUTHORIZED_PERSONS",
72
+ "COMPANY_IDENTIFY_OFFICERS",
73
+ "COMPANY_IDENTIFY_BENEFICIAL_OWNERS",
74
+ "COMPANY_ASSESS_SANCTIONS_EXPOSURE",
75
+ "COMPANY_REVIEW_FILINGS"
76
+ ],
77
+ "tasks": [
78
+ {
79
+ "check_ids": [],
80
+ "creation_date": "2018-01-15 11:39:17",
81
+ "id": "b83e2d7e-f9e8-11e7-8229-000000000000",
82
+ "is_complete": false,
83
+ "is_expired": false,
84
+ "type": "COMPANY_VERIFY_IDENTITY"
85
+ },
86
+ {
87
+ "check_ids": [],
88
+ "creation_date": "2018-01-15 11:39:17",
89
+ "id": "b841b73e-f9e8-11e7-b17f-000000000000",
90
+ "is_complete": false,
91
+ "is_expired": false,
92
+ "type": "COMPANY_IDENTIFY_AUTHORIZED_PERSONS"
93
+ },
94
+ {
95
+ "check_ids": [],
96
+ "creation_date": "2018-01-15 11:39:17",
97
+ "id": "b843d282-f9e8-11e7-b539-000000000000",
98
+ "is_complete": false,
99
+ "is_expired": false,
100
+ "type": "COMPANY_IDENTIFY_OFFICERS"
101
+ },
102
+ {
103
+ "check_ids": [],
104
+ "creation_date": "2018-01-15 11:39:17",
105
+ "id": "b845e7f4-f9e8-11e7-a4d1-000000000000",
106
+ "is_complete": false,
107
+ "is_expired": false,
108
+ "type": "COMPANY_IDENTIFY_BENEFICIAL_OWNERS"
109
+ },
110
+ {
111
+ "check_ids": [],
112
+ "creation_date": "2018-01-15 11:39:17",
113
+ "id": "b8485a78-f9e8-11e7-86ee-000000000000",
114
+ "is_complete": false,
115
+ "is_expired": false,
116
+ "type": "COMPANY_ASSESS_SANCTIONS_EXPOSURE"
117
+ },
118
+ {
119
+ "check_ids": [],
120
+ "creation_date": "2018-01-15 11:39:17",
121
+ "id": "b84ad2de-f9e8-11e7-806b-000000000000",
122
+ "is_complete": false,
123
+ "is_expired": false,
124
+ "type": "COMPANY_REVIEW_FILINGS"
125
+ }
126
+ ],
127
+ "unresolved_event_types": []
128
+ }
@@ -1,6 +1,6 @@
1
- {
2
- "type": "INDIVIDUAL_VERIFY_ADDRESS",
3
- "check_ids": [],
4
- "id": "33cdc540-61e0-11e7-b07b-acbc32b67d7b",
5
- "is_complete": false
6
- }
1
+ {
2
+ "type": "INDIVIDUAL_VERIFY_ADDRESS",
3
+ "check_ids": [],
4
+ "id": "33cdc540-61e0-11e7-b07b-acbc32b67d7b",
5
+ "is_complete": false
6
+ }
@@ -1,74 +1,74 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- # https://www.passfort.com/developer/recipes/running-a-company-ownership-check
6
- # rubocop:disable RSpec/DescribeClass
7
- # rubocop:disable RSpec/ExampleLength
8
- RSpec.describe "running a company ownership check" do
9
- let(:api_key) { "api_key" }
10
- let(:client) { Passfort::Client.new(api_key: api_key) }
11
-
12
- let(:profile_fixture) { load_fixture("company_ownership_check/profile.json") }
13
- let(:check_fixture) { load_fixture("company_ownership_check/check.json") }
14
- let(:collected_data_fixture) do
15
- load_fixture("company_ownership_check/collected_data.json")
16
- end
17
- let(:collected_data_update_fixture) do
18
- load_fixture("company_ownership_check/collected_data_update_request.json")
19
- end
20
-
21
- let(:profile_id) { JSON.parse(profile_fixture)["id"] }
22
- let(:create_profile_args) do
23
- {
24
- role: Passfort::Role::COMPANY_CUSTOMER,
25
- collected_data: {
26
- entity_type: Passfort::EntityType::COMPANY,
27
- metadata: {
28
- country_of_incorporation: "GBR",
29
- number: "09565115",
30
- },
31
- },
32
- }
33
- end
34
-
35
- before do
36
- stub_request(:post, %r{/profiles\z}).
37
- with(body: create_profile_args).
38
- to_return(status: 201, body: profile_fixture)
39
- stub_request(:post, %r{/profiles/#{profile_id}/checks\z}).
40
- with(body: { check_type: "COMPANY_OWNERSHIP" }).
41
- to_return(status: 201, body: check_fixture)
42
- stub_request(:get, %r{/profiles/#{profile_id}/collected_data\z}).
43
- to_return(
44
- status: 200,
45
- body: collected_data_fixture,
46
- )
47
- stub_request(:post, %r{/profiles/#{profile_id}/collected_data\z}).
48
- with(body: JSON.parse(collected_data_update_fixture)).
49
- to_return(
50
- status: 200,
51
- body: collected_data_fixture,
52
- )
53
- end
54
-
55
- it "succeeds" do
56
- profile = client.profiles.create(create_profile_args)
57
-
58
- expect(profile.id).to eq(profile_id)
59
-
60
- check = client.checks.create(profile_id: profile.id, check_type: "COMPANY_OWNERSHIP")
61
-
62
- shareholders = check.output_data[:ownership_structure][:shareholders]
63
- beneficial_owners = shareholders.select { |sh| sh[:total_percentage] >= 25 }
64
-
65
- collected_data = client.profiles.collected_data(profile.id).to_h
66
-
67
- collected_data[:ownership_structure] ||= {}
68
- collected_data[:ownership_structure][:shareholders] = beneficial_owners
69
-
70
- client.profiles.update_collected_data(profile.id, collected_data)
71
- end
72
- end
73
- # rubocop:enable RSpec/DescribeClass
74
- # rubocop:enable RSpec/ExampleLength
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ # https://www.passfort.com/developer/recipes/running-a-company-ownership-check
6
+ # rubocop:disable RSpec/DescribeClass
7
+ # rubocop:disable RSpec/ExampleLength
8
+ RSpec.describe "running a company ownership check" do
9
+ let(:api_key) { "api_key" }
10
+ let(:client) { Passfort::Client.new(api_key: api_key) }
11
+
12
+ let(:profile_fixture) { load_fixture("company_ownership_check/profile.json") }
13
+ let(:check_fixture) { load_fixture("company_ownership_check/check.json") }
14
+ let(:collected_data_fixture) do
15
+ load_fixture("company_ownership_check/collected_data.json")
16
+ end
17
+ let(:collected_data_update_fixture) do
18
+ load_fixture("company_ownership_check/collected_data_update_request.json")
19
+ end
20
+
21
+ let(:profile_id) { JSON.parse(profile_fixture)["id"] }
22
+ let(:create_profile_args) do
23
+ {
24
+ role: Passfort::Role::COMPANY_CUSTOMER,
25
+ collected_data: {
26
+ entity_type: Passfort::EntityType::COMPANY,
27
+ metadata: {
28
+ country_of_incorporation: "GBR",
29
+ number: "09565115",
30
+ },
31
+ },
32
+ }
33
+ end
34
+
35
+ before do
36
+ stub_request(:post, %r{/profiles\z}).
37
+ with(body: create_profile_args).
38
+ to_return(status: 201, body: profile_fixture)
39
+ stub_request(:post, %r{/profiles/#{profile_id}/checks\z}).
40
+ with(body: { check_type: "COMPANY_OWNERSHIP" }).
41
+ to_return(status: 201, body: check_fixture)
42
+ stub_request(:get, %r{/profiles/#{profile_id}/collected_data\z}).
43
+ to_return(
44
+ status: 200,
45
+ body: collected_data_fixture,
46
+ )
47
+ stub_request(:post, %r{/profiles/#{profile_id}/collected_data\z}).
48
+ with(body: JSON.parse(collected_data_update_fixture)).
49
+ to_return(
50
+ status: 200,
51
+ body: collected_data_fixture,
52
+ )
53
+ end
54
+
55
+ it "succeeds" do
56
+ profile = client.profiles.create(create_profile_args)
57
+
58
+ expect(profile.id).to eq(profile_id)
59
+
60
+ check = client.checks.create(profile_id: profile.id, check_type: "COMPANY_OWNERSHIP")
61
+
62
+ shareholders = check.output_data[:ownership_structure][:shareholders]
63
+ beneficial_owners = shareholders.select { |sh| sh[:total_percentage] >= 25 }
64
+
65
+ collected_data = client.profiles.collected_data(profile.id).to_h
66
+
67
+ collected_data[:ownership_structure] ||= {}
68
+ collected_data[:ownership_structure][:shareholders] = beneficial_owners
69
+
70
+ client.profiles.update_collected_data(profile.id, collected_data)
71
+ end
72
+ end
73
+ # rubocop:enable RSpec/DescribeClass
74
+ # rubocop:enable RSpec/ExampleLength
@@ -1,22 +1,22 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- RSpec.describe Passfort::Endpoint::Checks do
6
- let(:endpoint) { described_class.new(Passfort::Http.new("api_key")) }
7
-
8
- describe "#create" do
9
- subject { endpoint.create(profile_id: profile_id, check_type: check_type) }
10
-
11
- let(:profile_id) { "a_profile_id" }
12
- let(:check_type) { "a_check_type" }
13
-
14
- before do
15
- stub_request(:post, %r{/profiles/#{profile_id}/checks\z}).
16
- with(body: { check_type: check_type }).
17
- to_return(status: 200, body: load_fixture("check.json"))
18
- end
19
-
20
- it { is_expected.to have_attributes(id: "6c1d594a-496e-11e7-911e-acbc32b67d7b") }
21
- end
22
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe Passfort::Endpoint::Checks do
6
+ let(:endpoint) { described_class.new(Passfort::Http.new("api_key")) }
7
+
8
+ describe "#create" do
9
+ subject { endpoint.create(profile_id: profile_id, check_type: check_type) }
10
+
11
+ let(:profile_id) { "a_profile_id" }
12
+ let(:check_type) { "a_check_type" }
13
+
14
+ before do
15
+ stub_request(:post, %r{/profiles/#{profile_id}/checks\z}).
16
+ with(body: { check_type: check_type }).
17
+ to_return(status: 200, body: load_fixture("check.json"))
18
+ end
19
+
20
+ it { is_expected.to have_attributes(id: "6c1d594a-496e-11e7-911e-acbc32b67d7b") }
21
+ end
22
+ end