passfort 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +17 -0
  3. data/.rubocop.yml +2 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +13 -0
  6. data/Gemfile +5 -0
  7. data/Gemfile.lock +89 -0
  8. data/LICENCE.txt +22 -0
  9. data/README.md +6 -0
  10. data/lib/passfort.rb +35 -0
  11. data/lib/passfort/client.rb +23 -0
  12. data/lib/passfort/endpoint.rb +10 -0
  13. data/lib/passfort/endpoint/checks.rb +19 -0
  14. data/lib/passfort/endpoint/profiles.rb +46 -0
  15. data/lib/passfort/endpoint/tasks.rb +16 -0
  16. data/lib/passfort/errors.rb +12 -0
  17. data/lib/passfort/errors/api_error.rb +15 -0
  18. data/lib/passfort/errors/chargeable_limit_reached_error.rb +12 -0
  19. data/lib/passfort/errors/invalid_api_key_error.rb +12 -0
  20. data/lib/passfort/errors/invalid_input_data_error.rb +12 -0
  21. data/lib/passfort/errors/request_error.rb +12 -0
  22. data/lib/passfort/http.rb +60 -0
  23. data/lib/passfort/resource.rb +12 -0
  24. data/lib/passfort/resource/base.rb +21 -0
  25. data/lib/passfort/resource/check.rb +10 -0
  26. data/lib/passfort/resource/company_data.rb +11 -0
  27. data/lib/passfort/resource/individual_data.rb +11 -0
  28. data/lib/passfort/resource/profile.rb +15 -0
  29. data/lib/passfort/resource/task.rb +9 -0
  30. data/lib/passfort/version.rb +5 -0
  31. data/passfort.gemspec +29 -0
  32. data/spec/fixtures/check.json +67 -0
  33. data/spec/fixtures/collected_data.json +7 -0
  34. data/spec/fixtures/company_ownership_check/check.json +78 -0
  35. data/spec/fixtures/company_ownership_check/collected_data.json +7 -0
  36. data/spec/fixtures/company_ownership_check/collected_data_update_request.json +63 -0
  37. data/spec/fixtures/company_ownership_check/profile.json +128 -0
  38. data/spec/fixtures/profile.json +128 -0
  39. data/spec/fixtures/task.json +6 -0
  40. data/spec/integration/company_ownership_check_spec.rb +74 -0
  41. data/spec/passfort/endpoint/checks_spec.rb +22 -0
  42. data/spec/passfort/endpoint/profiles_spec.rb +79 -0
  43. data/spec/passfort/endpoint/tasks_spec.rb +21 -0
  44. data/spec/passfort/http_spec.rb +91 -0
  45. data/spec/spec_helper.rb +9 -0
  46. metadata +200 -0
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "passfort/resource/base"
4
+ require "passfort/resource/profile"
5
+ require "passfort/resource/company_data"
6
+ require "passfort/resource/task"
7
+ require "passfort/resource/check"
8
+
9
+ module Passfort
10
+ module Resource
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/hash"
4
+
5
+ module Passfort
6
+ module Resource
7
+ class Base
8
+ def self.attributes(*keys)
9
+ keys.each { |key| define_method(key) { @attributes[key] } }
10
+ end
11
+
12
+ def initialize(attributes)
13
+ @attributes = attributes.with_indifferent_access
14
+ end
15
+
16
+ def to_h
17
+ @attributes
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Passfort
4
+ module Resource
5
+ class Check < Base
6
+ attributes :id, :check_type, :state, :input_data, :output_data, :result,
7
+ :performed_on, :errors, :task_ids, :instructed_externally
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Passfort
4
+ module Resource
5
+ class CompanyData < Base
6
+ attributes :entity_type, :metadata, :authorized_persons,
7
+ :unauthorized_persons, :ownership_structure, :officers,
8
+ :filings, :customer_ref, :external_refs
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Passfort
4
+ module Resource
5
+ class IndividualData < Base
6
+ attributes :entity_type, :personal_details, :address_history,
7
+ :contact_details, :phone_number, :email, :ip_location,
8
+ :documents
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "passfort/resource/task"
4
+
5
+ module Passfort
6
+ module Resource
7
+ class Profile < Base
8
+ attributes :id, :role, :collected_data, :verified_data, :checks,
9
+ :collection_steps, :display_name, :applications, :task_types,
10
+ :tasks, :events, :category, :status, :document_images, :tags,
11
+ :risk, :unresolved_event_types, :task_progress,
12
+ :has_associates, :has_collection_steps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Passfort
4
+ module Resource
5
+ class Task < Base
6
+ attributes :id, :type, :is_complete, :is_expired, :check_ids
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Passfort
4
+ VERSION = "0.2.0"
5
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require "passfort/version"
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "passfort"
10
+ spec.version = Passfort::VERSION
11
+ spec.summary = "Client for the PassFort API"
12
+ spec.authors = %w[GoCardless]
13
+ spec.homepage = "https://github.com/gocardless/passfort"
14
+ spec.email = %w[developers@gocardless.com]
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.test_files = spec.files.grep(%r{^spec/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "activesupport", "~> 5.0"
22
+ spec.add_dependency "excon", "~> 0.60"
23
+
24
+ spec.add_development_dependency "gc_ruboconfig", "~> 2.3"
25
+ spec.add_development_dependency "pry", "~> 0.10"
26
+ spec.add_development_dependency "rspec", "~> 3.2"
27
+ spec.add_development_dependency "rspec_junit_formatter", "~> 0.3"
28
+ spec.add_development_dependency "webmock", "~> 3.3"
29
+ end
@@ -0,0 +1,67 @@
1
+ {
2
+ "check_type": "IDENTITY_CHECK",
3
+ "errors": [],
4
+ "id": "6c1d594a-496e-11e7-911e-acbc32b67d7b",
5
+ "input_data": {
6
+ "address_history": [
7
+ {
8
+ "address": {
9
+ "country": "Southend-on-Sea",
10
+ "locality": "Southend-on-Sea",
11
+ "postal_code": "1",
12
+ "postal_town": "Leigh-on-Sea",
13
+ "route": "The Fairway",
14
+ "state_province": "England",
15
+ "street_number": "106",
16
+ "type": "STRUCTURED"
17
+ },
18
+ "end_date": "2017-05",
19
+ "start_date": "2017-01"
20
+ }
21
+ ],
22
+ "entity_type": "INDIVIDUAL",
23
+ "personal_details": {
24
+ "dob": "1987-01-01",
25
+ "name": {
26
+ "family_name": "Smith",
27
+ "given_names": [
28
+ "Thomas"
29
+ ]
30
+ }
31
+ }
32
+ },
33
+ "output_data": {
34
+ "credit_ref": {
35
+ "exact": {
36
+ "count": 8,
37
+ "match": true
38
+ },
39
+ "exact_dob": {
40
+ "count": 8,
41
+ "match": true
42
+ },
43
+ "partial": {
44
+ "count": 8,
45
+ "match": true
46
+ }
47
+ },
48
+ "db_matches": {
49
+ "electoral_exact": {
50
+ "count": 1,
51
+ "match": true
52
+ },
53
+ "electoral_exact_dob": {
54
+ "count": 0,
55
+ "match": false
56
+ },
57
+ "electoral_partial": {
58
+ "count": 1,
59
+ "match": true
60
+ }
61
+ },
62
+ "entity_type": "INDIVIDUAL"
63
+ },
64
+ "result": "2+2",
65
+ "state": "COMPLETE",
66
+ "task_ids": []
67
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "entity_type": "COMPANY",
3
+ "metadata": {
4
+ "country_of_incorporation": "GBR",
5
+ "number": "09565115"
6
+ }
7
+ }
@@ -0,0 +1,78 @@
1
+ {
2
+ "check_type": "COMPANY_OWNERSHIP",
3
+ "errors": [],
4
+ "id": "30e4ea06-0519-11e8-000000000000",
5
+ "input_data": {
6
+ "entity_type": "COMPANY",
7
+ "metadata": {
8
+ "country_of_incorporation": "GBR",
9
+ "number": "09565115"
10
+ }
11
+ },
12
+ "output_data": {
13
+ "entity_type": "COMPANY",
14
+ "metadata": {},
15
+ "ownership_structure": {
16
+ "shareholders": [
17
+ {
18
+ "entity_type": "INDIVIDUAL",
19
+ "immediate_data": {
20
+ "address_history": [],
21
+ "entity_type": "INDIVIDUAL",
22
+ "personal_details": {
23
+ "name": {
24
+ "family_name": "Gillies",
25
+ "given_names": [
26
+ "Donald"
27
+ ]
28
+ }
29
+ }
30
+ },
31
+ "provider_name": "DueDil",
32
+ "resolver_id": "322d0f54-0519-11e8-914c-000000000000",
33
+ "shareholdings": [
34
+ {
35
+ "amount": 100,
36
+ "currency": "GBP",
37
+ "percentage": 50,
38
+ "share_class": "Ordinary"
39
+ }
40
+ ],
41
+ "total_percentage": 50
42
+ },
43
+ {
44
+ "entity_type": "INDIVIDUAL",
45
+ "immediate_data": {
46
+ "address_history": [],
47
+ "entity_type": "INDIVIDUAL",
48
+ "personal_details": {
49
+ "name": {
50
+ "family_name": "Irish",
51
+ "given_names": [
52
+ "Henry"
53
+ ]
54
+ }
55
+ }
56
+ },
57
+ "provider_name": "DueDil",
58
+ "resolver_id": "322d1f9e-0519-11e8-b046-000000000000",
59
+ "shareholdings": [
60
+ {
61
+ "amount": 100,
62
+ "currency": "GBP",
63
+ "percentage": 50,
64
+ "share_class": "Ordinary"
65
+ }
66
+ ],
67
+ "total_percentage": 50
68
+ }
69
+ ]
70
+ }
71
+ },
72
+ "performed_on": "2018-01-29 17:24:01",
73
+ "result": "Pass",
74
+ "state": "COMPLETE",
75
+ "task_ids": [
76
+ "b845e7f4-f9e8-11e7-a4d1-000000000000"
77
+ ]
78
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "entity_type": "COMPANY",
3
+ "metadata": {
4
+ "country_of_incorporation": "GBR",
5
+ "number": "09565115"
6
+ }
7
+ }
@@ -0,0 +1,63 @@
1
+ {
2
+ "entity_type": "COMPANY",
3
+ "metadata": {
4
+ "country_of_incorporation": "GBR",
5
+ "number": "09565115"
6
+ },
7
+ "ownership_structure": {
8
+ "shareholders": [
9
+ {
10
+ "entity_type": "INDIVIDUAL",
11
+ "immediate_data": {
12
+ "address_history": [],
13
+ "entity_type": "INDIVIDUAL",
14
+ "personal_details": {
15
+ "name": {
16
+ "family_name": "Gillies",
17
+ "given_names": [
18
+ "Donald"
19
+ ]
20
+ }
21
+ }
22
+ },
23
+ "provider_name": "DueDil",
24
+ "resolver_id": "322d0f54-0519-11e8-914c-000000000000",
25
+ "shareholdings": [
26
+ {
27
+ "amount": 100,
28
+ "currency": "GBP",
29
+ "percentage": 50,
30
+ "share_class": "Ordinary"
31
+ }
32
+ ],
33
+ "total_percentage": 50
34
+ },
35
+ {
36
+ "entity_type": "INDIVIDUAL",
37
+ "immediate_data": {
38
+ "address_history": [],
39
+ "entity_type": "INDIVIDUAL",
40
+ "personal_details": {
41
+ "name": {
42
+ "family_name": "Irish",
43
+ "given_names": [
44
+ "Henry"
45
+ ]
46
+ }
47
+ }
48
+ },
49
+ "provider_name": "DueDil",
50
+ "resolver_id": "322d1f9e-0519-11e8-b046-000000000000",
51
+ "shareholdings": [
52
+ {
53
+ "amount": 100,
54
+ "currency": "GBP",
55
+ "percentage": 50,
56
+ "share_class": "Ordinary"
57
+ }
58
+ ],
59
+ "total_percentage": 50
60
+ }
61
+ ]
62
+ }
63
+ }
@@ -0,0 +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
+ }