sumsub-ruby-sdk 0.1.3 → 0.2.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
  SHA256:
3
- metadata.gz: 2316babc5fae1767d363f5bdc9dd89ec16741743187846b60fa376b5cc61edf9
4
- data.tar.gz: ff476fc28ee64b1f5e768e0d26841b4f6b9e734e47d6da65b7083632ef314f63
3
+ metadata.gz: 9413196d575bbddc26d58047d48137b768f70aa7b257187073338b468c109068
4
+ data.tar.gz: 6a291133d2e3a5417ec4f83ca3f30f24130d2e2018f3d768e068345ecf20198d
5
5
  SHA512:
6
- metadata.gz: ce98bc1ce4ea71fae0465919d2a82c6ce3b692162575366c31fba2ef90291efad7a6a11b994bed63ff7bfebfd6e41f0250fa47bf1738200ffe1d2135f26c7008
7
- data.tar.gz: 520a68ba81554dd3258cc6ff9417b892137a48ed4e350ed283ac89f2decbc11add45f4d2aa258a531bec83177c4577e734ef99307b73c79c259c32353ef2a931
6
+ metadata.gz: bda4bb1f88238b57859559b6fcf740550b92225a0290b764a6c29560e6567da41fc5b994b9caac0ec5d273304108abc800d8da2fb5a4d536c2cf2553a75beebd
7
+ data.tar.gz: f36d963aae4ef9416227e85893fcb58369d40a9302916ddd74eeca8e2c532ada9608ac12296a7625525b8123f70f8607812ae8b54829ac9b63df63d08620bacc
data/.gitignore CHANGED
@@ -1,3 +1,13 @@
1
+ # See https://help.github.com/articles/ignoring-files
2
+ # for more about ignoring files.
3
+ #
4
+ # If you find yourself ignoring temporary files generated by your text editor
5
+ # or operating system, you probably want to add a global ignore instead:
6
+ # git config --global core.excludesfile '~/.gitignore_global'
7
+
8
+ *.gem
9
+ *.rbc
10
+
1
11
  /.bundle/
2
12
  /.yardoc
3
13
  /_yardoc/
@@ -10,4 +20,18 @@
10
20
  # rspec failure tracking
11
21
  .rspec_status
12
22
 
23
+ # Other
13
24
  test_script
25
+
26
+ # Environment normalization:
27
+ /.bundle/
28
+ /vendor/bundle/*
29
+ !/vendor/bundle/.keep
30
+
31
+ # For a library or gem, you might want to ignore these files since the code is
32
+ # intended to run in multiple environments; otherwise, check them in:
33
+ /.ruby-version
34
+ /.ruby-gemset
35
+
36
+ # Unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
37
+ /.rvmrc
data/CHANGELOG.md CHANGED
@@ -3,3 +3,10 @@
3
3
 
4
4
  ### 0.1.3
5
5
  - Require level name as argument in `get_access_token` of `Sumsub::Request`. This change makes the method compatible with the [recent updates in the Sumsub SDK](https://developers.sumsub.com/migrations/sdk.html#sdk-migration-guide).
6
+
7
+ ### 0.2.0
8
+ - General minor fixes (don't require dev gems in the production build, add extra ignored files in `.gitignore`, etc);
9
+ - Move the `require 'dry-struct'` to the `lib/sumsub.rb`, so we don't need to always require it in our structs;
10
+ - Add [`generate_external_link`](https://developers.sumsub.com/api-reference/additional-methods.html#generating-websdk-external-link-for-particular-user);
11
+ - Updated structs with new fields;
12
+ - Add `WebhookSender` with `get_payload` class method to format the payload before informing it to the `verify_webhook_sender` method (those strange string transformations are necessary in order to receive the right answer from Sumsub).
data/Gemfile.lock CHANGED
@@ -1,36 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sumsub-ruby-sdk (0.1.2)
5
- dry-struct (~> 1.4.0)
6
- http (~> 5.0.0)
7
- mime-types (~> 3.3.1)
8
- pry (~> 0.14.1)
9
- rspec (~> 3.10.0)
10
- timecop (~> 0.9.4)
11
- webmock (~> 3.13.0)
4
+ sumsub-ruby-sdk (0.1.3)
5
+ dry-struct (~> 1.4)
6
+ http (>= 4.0)
7
+ mime-types (~> 3.3)
12
8
 
13
9
  GEM
14
10
  remote: https://rubygems.org/
15
11
  specs:
16
- addressable (2.7.0)
12
+ addressable (2.8.0)
17
13
  public_suffix (>= 2.0.2, < 5.0)
18
14
  coderay (1.1.3)
19
- concurrent-ruby (1.1.8)
15
+ concurrent-ruby (1.1.9)
20
16
  crack (0.4.5)
21
17
  rexml
22
18
  diff-lcs (1.4.4)
23
19
  domain_name (0.5.20190701)
24
20
  unf (>= 0.0.5, < 1.0.0)
25
- dry-configurable (0.12.1)
21
+ dry-configurable (0.13.0)
26
22
  concurrent-ruby (~> 1.0)
27
- dry-core (~> 0.5, >= 0.5.0)
28
- dry-container (0.7.2)
23
+ dry-core (~> 0.6)
24
+ dry-container (0.9.0)
29
25
  concurrent-ruby (~> 1.0)
30
- dry-configurable (~> 0.1, >= 0.1.3)
31
- dry-core (0.5.0)
26
+ dry-configurable (~> 0.13, >= 0.13.0)
27
+ dry-core (0.7.1)
32
28
  concurrent-ruby (~> 1.0)
33
- dry-inflector (0.2.0)
29
+ dry-inflector (0.2.1)
34
30
  dry-logic (1.2.0)
35
31
  concurrent-ruby (~> 1.0)
36
32
  dry-core (~> 0.5, >= 0.5)
@@ -44,7 +40,7 @@ GEM
44
40
  dry-core (~> 0.5, >= 0.5)
45
41
  dry-inflector (~> 0.1, >= 0.1.2)
46
42
  dry-logic (~> 1.0, >= 1.0.2)
47
- ffi (1.15.0)
43
+ ffi (1.15.4)
48
44
  ffi-compiler (1.0.1)
49
45
  ffi (>= 1.0.0)
50
46
  rake
@@ -54,7 +50,7 @@ GEM
54
50
  http-cookie (~> 1.0)
55
51
  http-form_data (~> 2.2)
56
52
  llhttp-ffi (~> 0.0.1)
57
- http-cookie (1.0.3)
53
+ http-cookie (1.0.4)
58
54
  domain_name (~> 0.5)
59
55
  http-form_data (2.3.0)
60
56
  ice_nine (0.11.2)
@@ -62,14 +58,14 @@ GEM
62
58
  ffi-compiler (~> 1.0)
63
59
  rake (~> 13.0)
64
60
  method_source (1.0.0)
65
- mime-types (3.3.1)
61
+ mime-types (3.4.1)
66
62
  mime-types-data (~> 3.2015)
67
- mime-types-data (3.2021.0225)
63
+ mime-types-data (3.2021.1115)
68
64
  pry (0.14.1)
69
65
  coderay (~> 1.1)
70
66
  method_source (~> 1.0)
71
67
  public_suffix (4.0.6)
72
- rake (13.0.3)
68
+ rake (13.0.6)
73
69
  rexml (3.2.5)
74
70
  rspec (3.10.0)
75
71
  rspec-core (~> 3.10.0)
@@ -83,13 +79,13 @@ GEM
83
79
  rspec-mocks (3.10.2)
84
80
  diff-lcs (>= 1.2.0, < 2.0)
85
81
  rspec-support (~> 3.10.0)
86
- rspec-support (3.10.2)
82
+ rspec-support (3.10.3)
87
83
  timecop (0.9.4)
88
84
  unf (0.1.4)
89
85
  unf_ext
90
- unf_ext (0.0.7.7)
91
- webmock (3.13.0)
92
- addressable (>= 2.3.6)
86
+ unf_ext (0.0.8)
87
+ webmock (3.14.0)
88
+ addressable (>= 2.8.0)
93
89
  crack (>= 0.3.2)
94
90
  hashdiff (>= 0.4.0, < 2.0.0)
95
91
 
@@ -98,9 +94,12 @@ PLATFORMS
98
94
  x86_64-linux
99
95
 
100
96
  DEPENDENCIES
97
+ pry (~> 0.14)
101
98
  rake (~> 13.0)
102
99
  rspec (~> 3.0)
103
100
  sumsub-ruby-sdk!
101
+ timecop (~> 0.9)
102
+ webmock (~> 3.13)
104
103
 
105
104
  BUNDLED WITH
106
- 2.2.17
105
+ 2.2.32
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # SumSub Ruby SDK
2
2
 
3
- This gem is an unnoficial SDK for the [SumSub API](https://developers.sumsub.com/api-reference/).
3
+ This gem is an unofficial SDK for the [SumSub API](https://developers.sumsub.com/api-reference/).
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'sumsub-ruby-sdk', '~> 0.1.2', require: 'sumsub'
10
+ gem 'sumsub-ruby-sdk', '~> 0.1.3', require: 'sumsub'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -16,7 +16,7 @@ And then execute:
16
16
 
17
17
  ## Configuration and Usage
18
18
 
19
- You can configure your credentials using `Sumsub::Configure` block. There are three keys you can inform: *token*, *secret_key* and *production*. The token and secret key you need to generate from your SumSub account, and *production* is a boolean value where you specify if you wanna use SumSub production or test environtment. To use the test environment, just set production as `false`.
19
+ You can configure your credentials using `Sumsub::Configure` block. There are three keys you can inform: *token*, *secret_key* and *production*. The token and secret key you need to generate from your SumSub account, and *production* is a boolean value where you specify if you wanna use SumSub production or test environment. To use the test environment, just set production as `false`.
20
20
 
21
21
  ```ruby
22
22
  Sumsub.configure do |config|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sumsub
2
4
  class Configuration
3
5
  attr_accessor :token, :secret_key, :production
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sumsub
2
4
  # https://developers.sumsub.com/api-reference/#signing-a-request
3
5
  class MessageSigner
data/lib/sumsub/parser.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sumsub
2
4
  class Parser
3
5
  def self.parse(json_payload)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sumsub
2
4
  class Request
3
5
  PRODUCTION_URL = "https://api.sumsub.com"
@@ -17,8 +19,8 @@ module Sumsub
17
19
 
18
20
  # API docs: https://developers.sumsub.com/api-reference/#creating-an-applicant
19
21
  # Sumsub::Struct::Applicant can be used as applicant.
20
- def create_applicant(lvl_name, applicant)
21
- resource = "applicants?levelName=#{lvl_name}"
22
+ def create_applicant(level_name, applicant)
23
+ resource = "applicants?levelName=#{level_name}"
22
24
  headers = build_header(resource, body: applicant.to_json)
23
25
  response = HTTP.headers(headers)
24
26
  .post("#{@url}/resources/#{resource}", json: applicant)
@@ -140,8 +142,8 @@ module Sumsub
140
142
  end
141
143
 
142
144
  # API docs: https://developers.sumsub.com/api-reference/#access-tokens-for-sdks
143
- def get_access_token(user_id, levelName, ttl_in_seconds: nil, external_action_id: nil)
144
- resource = "accessTokens?userId=#{user_id}&levelName=#{levelName}&ttlInSecs=#{ttl_in_seconds}&external_action_id=#{external_action_id}"
145
+ def get_access_token(user_id, level_name, ttl_in_seconds: nil, external_action_id: nil)
146
+ resource = "accessTokens?userId=#{user_id}&levelName=#{level_name}&ttlInSecs=#{ttl_in_seconds}&external_action_id=#{external_action_id}"
145
147
  headers = build_header(resource, method: 'POST')
146
148
  response = HTTP.headers(headers)
147
149
  .post("#{@url}/resources/#{resource}")
@@ -149,6 +151,17 @@ module Sumsub
149
151
  parse_response(response)
150
152
  end
151
153
 
154
+ # API docs: https://developers.sumsub.com/api-reference/#testing-on-the-test-environment
155
+ # Sumsub::Struct::Applicant can be used as review_result.
156
+ def testing_on_test_environment(applicant_id, review_result)
157
+ resource = "applicants/#{applicant_id}/status/testCompleted"
158
+ headers = build_header(resource, body: review_result.to_json)
159
+ response = HTTP.headers(headers)
160
+ .post("#{@url}/resources/#{resource}", json: review_result)
161
+
162
+ parse_response(response)
163
+ end
164
+
152
165
  # API docs: https://developers.sumsub.com/api-reference/#verifying-webhook-sender
153
166
  # Your payload need to be informed as a string.
154
167
  def verify_webhook_sender(webhook_secret_key, payload)
@@ -167,6 +180,18 @@ module Sumsub
167
180
  parse_response(response)
168
181
  end
169
182
 
183
+ # API docs: https://developers.sumsub.com/api-reference/additional-methods.html#generating-websdk-external-link-for-particular-user
184
+ # Sumsub::Struct::Applicant can be used as body.
185
+ def generate_external_link(level_name, ttl_in_seconds, external_user_id, locale: nil, body: {})
186
+ resource = "sdkIntegrations/levels/#{level_name}/websdkLink?ttlInSecs=#{ttl_in_seconds}&externalUserId=#{external_user_id}&lang=#{locale}"
187
+ headers = build_header(resource, method: 'POST', body: body.to_json)
188
+
189
+ response = HTTP.headers(headers)
190
+ .post("#{@url}/resources/#{resource}", json: body)
191
+
192
+ parse_response(response)
193
+ end
194
+
170
195
  private
171
196
 
172
197
  # More infos about the required header and the signing strategy:
@@ -184,6 +209,7 @@ module Sumsub
184
209
  resource: resource,
185
210
  body: body,
186
211
  method: method,
212
+ secret_key: @secret_key,
187
213
  )
188
214
 
189
215
  {
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sumsub
2
4
  module Struct
3
5
  # https://developers.sumsub.com/api-reference/#addresses-elements-fields
4
6
  class Address < BaseStruct
5
- include Types
6
-
7
7
  attribute? :country, Types::String
8
8
  attribute? :postCode, Types::String
9
9
  attribute? :town, Types::String
@@ -1,12 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sumsub
2
4
  module Struct
3
5
  # https://developers.sumsub.com/api-reference/#request-body
4
6
  class Applicant < BaseStruct
5
- include Types
6
-
7
7
  attribute :externalUserId, Types::Coercible::String
8
8
  attribute? :sourceKey, Types::String
9
9
  attribute? :email, Types::String
10
+ attribute? :phone, Types::String
10
11
  attribute? :lang, Types::String
11
12
  attribute? :metadata, Types::Array.of(Types::Hash)
12
13
  attribute? :info, Types::Instance(Sumsub::Struct::Info)
@@ -1,16 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sumsub
2
4
  module Struct
3
5
  # https://developers.sumsub.com/api-reference/#request-body-2
4
6
  class ApplicantUpdate < BaseStruct
5
- include Types
6
-
7
7
  attribute :id, Types::String
8
8
  attribute? :externalUserId, Types::String
9
- attribute? :sourceKey, Types::String
10
9
  attribute? :email, Types::String
10
+ attribute? :phone, Types::String
11
+ attribute? :sourceKey, Types::String
12
+ attribute? :type, Types::String
11
13
  attribute? :lang, Types::String
14
+ attribute? :questionnaires, Types::Array.of(Types::Hash)
12
15
  attribute? :metadata, Types::Array.of(Types::Hash)
13
- attribute? :type, Types::String
16
+ attribute? :deleted, Types::Bool
14
17
  end
15
18
  end
16
19
  end
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sumsub
4
+ include Types
5
+
2
6
  module Struct
3
7
  class BaseStruct < Dry::Struct
4
- include Types
5
8
 
6
9
  def to_json
7
10
  attributes.to_json
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sumsub
2
4
  module Struct
3
5
  # https://developers.sumsub.com/api-reference/#request-metadata-body-part-fields
4
6
  class DocumentMetadata < BaseStruct
5
- include Types
6
-
7
7
  attribute :idDocType, Types::IdDocTypes
8
- attribute? :idDocSubType, Types::IdDocSubType
8
+ attribute? :idDocSubType, Types::IdDocSubTypes
9
9
  attribute :country, Types::String # https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
10
10
  attribute? :firstName, Types::String
11
11
  attribute? :middleName, Types::String
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sumsub
2
4
  module Struct
3
5
  # https://developers.sumsub.com/api-reference/#response-body
4
6
  class ErrorResponse < BaseStruct
5
- include Types
6
-
7
7
  attribute :description, Types::String.optional
8
8
  attribute :code, Types::Coercible::String.optional
9
9
  attribute :correlation_id, Types::Coercible::String.optional
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sumsub
2
4
  module Struct
3
5
  # https://developers.sumsub.com/api-reference/#fixedinfo-and-info-attributes
4
6
  class Info < BaseStruct
5
- include Types
6
-
7
7
  attribute? :firstName, Types::String
8
8
  attribute? :lastName, Types::String
9
9
  attribute? :middleName, Types::String
@@ -18,7 +18,6 @@ module Sumsub
18
18
  attribute? :stateOfBirth, Types::String
19
19
  attribute? :country, Types::String
20
20
  attribute? :nationality, Types::String
21
- attribute? :phone, Types::String
22
21
  attribute? :addresses, Types::Array.of(Sumsub::Struct::Address)
23
22
  end
24
23
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sumsub
4
+ module Struct
5
+ # https://developers.sumsub.com/api-reference/#request-body-4
6
+ class ReviewResult < BaseStruct
7
+ attribute :reviewAnswer, Types::ReviewAnswers
8
+ attribute? :rejectLabels, Types::Array.of(Types::RejectLabels)
9
+ attribute? :reviewRejectType, Types::ReviewRejectTypes
10
+ attribute? :clientComment, Types::String
11
+ attribute? :moderationComment, Types::String
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sumsub
4
+ module Struct
5
+ # https://developers.sumsub.com/api-reference/#webhook-payload-attributes
6
+ class WebhookPayload < BaseStruct
7
+ attribute :applicantId, Types::String
8
+ attribute :inspectionId, Types::String
9
+ attribute :correlationId, Types::String
10
+ attribute :externalUserId, Types::String
11
+ attribute :type, Types::String
12
+ attribute :reviewStatus, Types::String
13
+ attribute :createdAt, Types::String
14
+ attribute? :applicantType, Types::String
15
+ attribute? :reviewResult, Types::Instance(Sumsub::Struct::ReviewResult)
16
+ attribute? :applicantMemberOf, Types::Array.of(Types::Hash)
17
+ attribute? :videoIdentReviewStatus, Types::String
18
+ attribute? :applicantActionId, Types::String
19
+ attribute? :externalApplicantActionId, Types::String
20
+ attribute :clientId, Types::String
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,137 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sumsub
4
+ module Types
5
+ include Dry.Types()
6
+
7
+ # https://developers.sumsub.com/api-reference/#supported-document-types
8
+ IdDocTypes = Types::Strict::Symbol
9
+ .constructor(&:to_sym)
10
+ .enum(
11
+ :ID_CARD,
12
+ :PASSPORT,
13
+ :DRIVERS, # Driving license
14
+ :RESIDENCE_PERMIT,
15
+ :UTILITY_BILL,
16
+ :SELFIE,
17
+ :VIDEO_SELFIE,
18
+ :PROFILE_IMAGE,
19
+ :ID_DOC_PHOTO,
20
+ :AGREEMENT,
21
+ :CONTRACT,
22
+ :DRIVERS_TRANSLATION,
23
+ :INVESTOR_DOC,
24
+ :VEHICLE_REGISTRATION_CERTIFICATE,
25
+ :INCOME_SOURCE, # Proof of income
26
+ :PAYMENT_METHOD,
27
+ :BANK_CARD,
28
+ :COVID_VACCINATION_FORM,
29
+ :OTHER,
30
+ nil,
31
+ )
32
+
33
+ # https://developers.sumsub.com/api-reference/#request-metadata-body-part-fields
34
+ IdDocSubTypes = Types::Strict::Symbol
35
+ .constructor(&:to_sym)
36
+ .enum(
37
+ :FRONT_SIDE,
38
+ :BACK_SIDE,
39
+ nil,
40
+ )
41
+
42
+ # https://developers.sumsub.com/api-reference/#getting-verification-results
43
+ ReviewAnswers = Types::Strict::Symbol
44
+ .constructor(&:to_sym)
45
+ .enum(
46
+ :GREEN,
47
+ :RED,
48
+ )
49
+
50
+ # https://developers.sumsub.com/api-reference/#getting-verification-results
51
+ RejectLabels = Types::Strict::Symbol
52
+ .constructor(&:to_sym)
53
+ .enum(
54
+ :FORGERY,
55
+ :DOCUMENT_TEMPLATE,
56
+ :LOW_QUALITY,
57
+ :SPAM,
58
+ :NOT_DOCUMENT,
59
+ :SELFIE_MISMATCH,
60
+ :ID_INVALID,
61
+ :FOREIGNER,
62
+ :DUPLICATE,
63
+ :BAD_AVATAR,
64
+ :WRONG_USER_REGION,
65
+ :INCOMPLETE_DOCUMENT,
66
+ :BLACKLIST,
67
+ :UNSATISFACTORY_PHOTOS,
68
+ :DOCUMENT_PAGE_MISSING,
69
+ :DOCUMENT_DAMAGED,
70
+ :REGULATIONS_VIOLATIONS,
71
+ :INCONSISTENT_PROFILE,
72
+ :PROBLEMATIC_APPLICANT_DATA,
73
+ :ADDITIONAL_DOCUMENT_REQUIRED,
74
+ :AGE_REQUIREMENT_MISMATCH,
75
+ :EXPERIENCE_REQUIREMENT_MISMATCH,
76
+ :CRIMINAL,
77
+ :WRONG_ADDRESS,
78
+ :GRAPHIC_EDITOR,
79
+ :DOCUMENT_DEPRIVED,
80
+ :COMPROMISED_PERSONS,
81
+ :PEP,
82
+ :ADVERSE_MEDIA,
83
+ :FRAUDULENT_PATTERNS,
84
+ :SANCTIONS,
85
+ :NOT_ALL_CHECKS_COMPLETED,
86
+ :FRONT_SIDE_MISSING,
87
+ :BACK_SIDE_MISSING,
88
+ :SCREENSHOTS,
89
+ :BLACK_AND_WHITE,
90
+ :INCOMPATIBLE_LANGUAGE,
91
+ :EXPIRATION_DATE,
92
+ :UNFILLED_ID,
93
+ :BAD_SELFIE,
94
+ :BAD_VIDEO_SELFIE,
95
+ :BAD_FACE_MATCHING,
96
+ :BAD_PROOF_OF_IDENTITY,
97
+ :BAD_PROOF_OF_ADDRESS,
98
+ :BAD_PROOF_OF_PAYMENT,
99
+ :SELFIE_WITH_PAPER,
100
+ :FRAUDULENT_LIVENESS,
101
+ :OTHER,
102
+ :REQUESTED_DATA_MISMATCH,
103
+ :OK,
104
+ :COMPANY_NOT_DEFINED_STRUCTURE,
105
+ :COMPANY_NOT_DEFINED_BENEFICIARIES,
106
+ :COMPANY_NOT_VALIDATED_BENEFICIARIES,
107
+ :COMPANY_NOT_DEFINED_REPRESENTATIVES,
108
+ :COMPANY_NOT_VALIDATED_REPRESENTATIVES,
109
+ )
110
+
111
+ # https://developers.sumsub.com/api-reference/#getting-verification-results
112
+ ReviewRejectTypes = Types::Strict::Symbol
113
+ .constructor(&:to_sym)
114
+ .enum(
115
+ :FINAL,
116
+ :RETRY,
117
+ )
118
+
119
+ # https://developers.sumsub.com/api-reference/#webhook-types
120
+ WebhookTypes = Types::Strict::Symbol
121
+ .constructor(&:to_sym)
122
+ .enum(
123
+ :applicantReviewed,
124
+ :applicantPending,
125
+ :applicantCreated,
126
+ :applicantOnHold,
127
+ :applicantPersonalInfoChanged,
128
+ :applicantPrechecked,
129
+ :applicantDeleted,
130
+ :videoIdentStatusChanged,
131
+ :applicantReset,
132
+ :applicantActionPending,
133
+ :applicantActionReviewed,
134
+ :applicantActionOnHold,
135
+ )
136
+ end
137
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sumsub
4
- VERSION = "0.1.3"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sumsub
4
+ # https://developers.sumsub.com/api-reference/#verifying-webhook-sender
5
+ class WebhookSender
6
+ def self.get_payload(params)
7
+ JSON.pretty_generate(
8
+ params,
9
+ space_before: ' ',
10
+ )
11
+ .gsub("[\n \"", "[ \"")
12
+ .gsub("\n ]", " ]")
13
+ end
14
+ end
15
+ end
data/lib/sumsub.rb CHANGED
@@ -1,23 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ ########
4
+ # Gems #
5
+ ########
6
+
3
7
  require 'http'
4
- require 'types'
5
8
  require 'mime/types'
9
+ require 'dry-struct'
10
+
11
+ ################
12
+ # Own requires #
13
+ ################
14
+
15
+ require 'sumsub/version'
6
16
 
7
- module Sumsub
8
- require 'sumsub/message_signer'
9
- require 'sumsub/configuration'
10
- require 'sumsub/parser'
11
- require 'sumsub/request'
12
- require 'sumsub/struct/base_struct'
13
- require 'sumsub/struct/error_response'
14
- require 'sumsub/struct/address'
15
- require 'sumsub/struct/info'
16
- require 'sumsub/struct/applicant'
17
- require 'sumsub/struct/applicant_update'
18
- require 'sumsub/struct/document_metadata'
19
- require 'sumsub/version'
17
+ require 'sumsub/types'
18
+ require 'sumsub/message_signer'
19
+ require 'sumsub/configuration'
20
+ require 'sumsub/parser'
21
+ require 'sumsub/request'
22
+ require 'sumsub/webhook_sender'
23
+ require 'sumsub/struct/base_struct'
24
+ require 'sumsub/struct/error_response'
25
+ require 'sumsub/struct/address'
26
+ require 'sumsub/struct/info'
27
+ require 'sumsub/struct/applicant'
28
+ require 'sumsub/struct/applicant_update'
29
+ require 'sumsub/struct/document_metadata'
30
+ require 'sumsub/struct/review_result'
31
+ require 'sumsub/struct/webhook_payload'
20
32
 
33
+ module Sumsub
21
34
  class << self
22
35
  attr_accessor :configuration
23
36
  end
@@ -29,17 +29,12 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
- # Uncomment to register a new dependency of your gem
33
- # spec.add_dependency "example-gem", "~> 1.0"
34
-
35
- # For more information and examples about making a new gem, checkout our
36
- # guide at: https://bundler.io/guides/creating_gem.html
37
-
38
- spec.add_dependency "http", "~> 5.0.0"
39
- spec.add_dependency "dry-struct", "~> 1.4.0"
40
- spec.add_dependency "rspec", "~> 3.10.0"
41
- spec.add_dependency "pry", "~> 0.14.1"
42
- spec.add_dependency "webmock", "~> 3.13.0"
43
- spec.add_dependency "timecop", "~> 0.9.4"
44
- spec.add_dependency "mime-types", "~> 3.3.1"
32
+ spec.add_dependency "http", ">= 4.0"
33
+ spec.add_dependency "dry-struct", "~> 1.4"
34
+ spec.add_dependency "mime-types", "~> 3.3"
35
+
36
+ spec.add_development_dependency "rspec", "~> 3.10"
37
+ spec.add_development_dependency "pry", "~> 0.14"
38
+ spec.add_development_dependency "webmock", "~> 3.13"
39
+ spec.add_development_dependency "timecop", "~> 0.9"
45
40
  end
metadata CHANGED
@@ -1,113 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sumsub-ruby-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo W. Ehresmann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-14 00:00:00.000000000 Z
11
+ date: 2022-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.0
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dry-struct
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.4.0
33
+ version: '1.4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.4.0
40
+ version: '1.4'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: mime-types
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.10.0
47
+ version: '3.3'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 3.10.0
54
+ version: '3.3'
55
55
  - !ruby/object:Gem::Dependency
56
- name: pry
56
+ name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.14.1
62
- type: :runtime
61
+ version: '3.10'
62
+ type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.14.1
68
+ version: '3.10'
69
69
  - !ruby/object:Gem::Dependency
70
- name: webmock
70
+ name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 3.13.0
76
- type: :runtime
75
+ version: '0.14'
76
+ type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 3.13.0
82
+ version: '0.14'
83
83
  - !ruby/object:Gem::Dependency
84
- name: timecop
84
+ name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.9.4
90
- type: :runtime
89
+ version: '3.13'
90
+ type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.9.4
96
+ version: '3.13'
97
97
  - !ruby/object:Gem::Dependency
98
- name: mime-types
98
+ name: timecop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 3.3.1
104
- type: :runtime
103
+ version: '0.9'
104
+ type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 3.3.1
110
+ version: '0.9'
111
111
  description: SDK written in Ruby to handle SumSub API.
112
112
  email:
113
113
  - igoehresmann@gmail.com
@@ -139,8 +139,11 @@ files:
139
139
  - lib/sumsub/struct/document_metadata.rb
140
140
  - lib/sumsub/struct/error_response.rb
141
141
  - lib/sumsub/struct/info.rb
142
+ - lib/sumsub/struct/review_result.rb
143
+ - lib/sumsub/struct/webhook_payload.rb
144
+ - lib/sumsub/types.rb
142
145
  - lib/sumsub/version.rb
143
- - lib/types.rb
146
+ - lib/sumsub/webhook_sender.rb
144
147
  - sumsub-ruby-sdk.gemspec
145
148
  homepage: https://github.com/rwehresmann/sumsub-ruby-sdk
146
149
  licenses:
data/lib/types.rb DELETED
@@ -1,39 +0,0 @@
1
- require 'dry-struct'
2
-
3
- module Types
4
- include Dry.Types()
5
-
6
- # https://developers.sumsub.com/api-reference/#supported-document-types
7
- IdDocTypes = Types::Strict::Symbol
8
- .constructor(&:to_sym)
9
- .enum(
10
- :ID_CARD,
11
- :PASSPORT,
12
- :DRIVERS, # Driving license
13
- :BANK_CARD,
14
- :UTILITY_BILL,
15
- :BANK_STATEMENT,
16
- :SELFIE,
17
- :VIDEO_SELFIE,
18
- :PROFILE_IMAGE,
19
- :ID_DOC_PHOTO,
20
- :AGREEMENT,
21
- :CONTRACT,
22
- :RESIDENCE_PERMIT,
23
- :EMPLOYMENT_CERTIFICATE,
24
- :DRIVERS_TRANSLATION,
25
- :INVESTOR_DOC,
26
- :VEHICLE_REGISTRATION_CERTIFICATE,
27
- :INCOME_SOURCE, # Proof of income
28
- :PAYMENT_METHOD,
29
- :OTHER,
30
- nil,
31
- )
32
-
33
- IdDocSubType = Types::Strict::Symbol
34
- .constructor(&:to_sym)
35
- .enum(
36
- :FRONT_SIDE,
37
- :BACK_SIDE,
38
- )
39
- end