yoti 1.6.4 → 1.10.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 (105) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/README.md +22 -224
  4. data/lib/yoti.rb +63 -1
  5. data/lib/yoti/activity_details.rb +3 -5
  6. data/lib/yoti/client.rb +13 -4
  7. data/lib/yoti/configuration.rb +8 -3
  8. data/lib/yoti/data_type/age_verification.rb +1 -1
  9. data/lib/yoti/data_type/base_profile.rb +1 -1
  10. data/lib/yoti/data_type/document_details.rb +1 -1
  11. data/lib/yoti/data_type/image.rb +4 -12
  12. data/lib/yoti/data_type/image_jpeg.rb +2 -0
  13. data/lib/yoti/data_type/image_png.rb +2 -0
  14. data/lib/yoti/data_type/media.rb +22 -0
  15. data/lib/yoti/data_type/signed_time_stamp.rb +1 -1
  16. data/lib/yoti/doc_scan/client.rb +191 -0
  17. data/lib/yoti/doc_scan/constants.rb +35 -0
  18. data/lib/yoti/doc_scan/errors.rb +81 -0
  19. data/lib/yoti/doc_scan/session/create/create_session_result.rb +50 -0
  20. data/lib/yoti/doc_scan/session/create/document_filter.rb +31 -0
  21. data/lib/yoti/doc_scan/session/create/document_restrictions_filter.rb +140 -0
  22. data/lib/yoti/doc_scan/session/create/notification_config.rb +142 -0
  23. data/lib/yoti/doc_scan/session/create/objective/objective.rb +31 -0
  24. data/lib/yoti/doc_scan/session/create/objective/proof_of_address_objective.rb +31 -0
  25. data/lib/yoti/doc_scan/session/create/orthogonal_restrictions_filter.rb +150 -0
  26. data/lib/yoti/doc_scan/session/create/requested_check.rb +39 -0
  27. data/lib/yoti/doc_scan/session/create/requested_document_authenticity_check.rb +95 -0
  28. data/lib/yoti/doc_scan/session/create/requested_face_match_check.rb +95 -0
  29. data/lib/yoti/doc_scan/session/create/requested_id_document_comparison_check.rb +53 -0
  30. data/lib/yoti/doc_scan/session/create/requested_liveness_check.rb +108 -0
  31. data/lib/yoti/doc_scan/session/create/requested_supplementary_doc_text_extraction_task.rb +94 -0
  32. data/lib/yoti/doc_scan/session/create/requested_task.rb +39 -0
  33. data/lib/yoti/doc_scan/session/create/requested_text_extraction_task.rb +116 -0
  34. data/lib/yoti/doc_scan/session/create/required_document.rb +31 -0
  35. data/lib/yoti/doc_scan/session/create/required_id_document.rb +53 -0
  36. data/lib/yoti/doc_scan/session/create/required_supplementary_document.rb +90 -0
  37. data/lib/yoti/doc_scan/session/create/sdk_config.rb +221 -0
  38. data/lib/yoti/doc_scan/session/create/session_specification.rb +221 -0
  39. data/lib/yoti/doc_scan/session/retrieve/authenticity_check_response.rb +12 -0
  40. data/lib/yoti/doc_scan/session/retrieve/breakdown_response.rb +38 -0
  41. data/lib/yoti/doc_scan/session/retrieve/check_response.rb +63 -0
  42. data/lib/yoti/doc_scan/session/retrieve/details_response.rb +28 -0
  43. data/lib/yoti/doc_scan/session/retrieve/document_fields_response.rb +21 -0
  44. data/lib/yoti/doc_scan/session/retrieve/document_id_photo_response.rb +21 -0
  45. data/lib/yoti/doc_scan/session/retrieve/face_map_response.rb +21 -0
  46. data/lib/yoti/doc_scan/session/retrieve/face_match_check_response.rb +12 -0
  47. data/lib/yoti/doc_scan/session/retrieve/file_response.rb +21 -0
  48. data/lib/yoti/doc_scan/session/retrieve/frame_response.rb +21 -0
  49. data/lib/yoti/doc_scan/session/retrieve/generated_check_response.rb +28 -0
  50. data/lib/yoti/doc_scan/session/retrieve/generated_media.rb +28 -0
  51. data/lib/yoti/doc_scan/session/retrieve/generated_supplementary_document_text_data_check_response.rb +12 -0
  52. data/lib/yoti/doc_scan/session/retrieve/generated_text_data_check_response.rb +12 -0
  53. data/lib/yoti/doc_scan/session/retrieve/get_session_result.rb +145 -0
  54. data/lib/yoti/doc_scan/session/retrieve/id_document_comparison_check_response.rb +12 -0
  55. data/lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb +57 -0
  56. data/lib/yoti/doc_scan/session/retrieve/liveness_check_response.rb +12 -0
  57. data/lib/yoti/doc_scan/session/retrieve/liveness_resource_response.rb +24 -0
  58. data/lib/yoti/doc_scan/session/retrieve/media_response.rb +38 -0
  59. data/lib/yoti/doc_scan/session/retrieve/page_response.rb +37 -0
  60. data/lib/yoti/doc_scan/session/retrieve/recommendation_response.rb +34 -0
  61. data/lib/yoti/doc_scan/session/retrieve/report_response.rb +31 -0
  62. data/lib/yoti/doc_scan/session/retrieve/resource_container.rb +69 -0
  63. data/lib/yoti/doc_scan/session/retrieve/resource_response.rb +41 -0
  64. data/lib/yoti/doc_scan/session/retrieve/supplementary_document_resource_response.rb +57 -0
  65. data/lib/yoti/doc_scan/session/retrieve/supplementary_document_text_data_check_response.rb +12 -0
  66. data/lib/yoti/doc_scan/session/retrieve/supplementary_document_text_extraction_task_response.rb +18 -0
  67. data/lib/yoti/doc_scan/session/retrieve/task_response.rb +89 -0
  68. data/lib/yoti/doc_scan/session/retrieve/text_data_check_response.rb +12 -0
  69. data/lib/yoti/doc_scan/session/retrieve/text_extraction_task_response.rb +18 -0
  70. data/lib/yoti/doc_scan/session/retrieve/zoom_liveness_resource_response.rb +33 -0
  71. data/lib/yoti/doc_scan/support/supported_documents.rb +60 -0
  72. data/lib/yoti/dynamic_share_service/dynamic_scenario.rb +5 -0
  73. data/lib/yoti/dynamic_share_service/extension/extension.rb +3 -0
  74. data/lib/yoti/dynamic_share_service/extension/location_constraint_extension.rb +3 -0
  75. data/lib/yoti/dynamic_share_service/extension/thirdparty_attribute_extension.rb +1 -1
  76. data/lib/yoti/dynamic_share_service/extension/transactional_flow_extension.rb +4 -0
  77. data/lib/yoti/dynamic_share_service/policy/dynamic_policy.rb +74 -9
  78. data/lib/yoti/dynamic_share_service/policy/wanted_anchor.rb +3 -0
  79. data/lib/yoti/dynamic_share_service/policy/wanted_attribute.rb +5 -0
  80. data/lib/yoti/dynamic_share_service/share_url.rb +26 -33
  81. data/lib/yoti/errors.rb +15 -2
  82. data/lib/yoti/http/aml_check_request.rb +12 -6
  83. data/lib/yoti/http/payloads/aml_address.rb +4 -0
  84. data/lib/yoti/http/payloads/aml_profile.rb +7 -1
  85. data/lib/yoti/http/profile_request.rb +11 -6
  86. data/lib/yoti/http/request.rb +219 -18
  87. data/lib/yoti/http/signed_request.rb +13 -4
  88. data/lib/yoti/protobuf/main.rb +8 -8
  89. data/lib/yoti/share/attribute_issuance_details.rb +6 -0
  90. data/lib/yoti/ssl.rb +4 -4
  91. data/lib/yoti/util/age_processor.rb +1 -1
  92. data/lib/yoti/util/anchor_processor.rb +2 -2
  93. data/lib/yoti/util/log.rb +1 -1
  94. data/lib/yoti/util/validation.rb +41 -0
  95. data/lib/yoti/version.rb +1 -1
  96. data/yoti.gemspec +18 -6
  97. metadata +69 -33
  98. data/.github/ISSUE_TEMPLATE.md +0 -17
  99. data/.gitignore +0 -39
  100. data/CONTRIBUTING.md +0 -98
  101. data/Guardfile +0 -11
  102. data/Rakefile +0 -54
  103. data/login_flow.png +0 -0
  104. data/rubocop.yml +0 -57
  105. data/yardstick.yml +0 -9
@@ -4,8 +4,13 @@ module Yoti
4
4
  module DynamicSharingService
5
5
  # Describes a dynamic share
6
6
  class DynamicScenario
7
+ # @return [Yoti::DynamicSharingService::DynamicPolicy]
7
8
  attr_reader :policy
9
+
10
+ # @return [Array<Yoti::DynamicSharingService::Extension>]
8
11
  attr_reader :extensions
12
+
13
+ # @return [String]
9
14
  attr_reader :callback_endpoint
10
15
 
11
16
  def initialize
@@ -3,7 +3,10 @@
3
3
  module Yoti
4
4
  module DynamicSharingService
5
5
  class Extension
6
+ # @return [String]
6
7
  attr_reader :type
8
+
9
+ # @return [#to_json]
7
10
  attr_reader :content
8
11
 
9
12
  def to_json(*_args)
@@ -6,7 +6,10 @@ module Yoti
6
6
  class LocationConstraintExtension
7
7
  EXTENSION_TYPE = 'LOCATION_CONSTRAINT'
8
8
 
9
+ # @return [#to_json]
9
10
  attr_reader :content
11
+
12
+ # @return [String]
10
13
  attr_reader :type
11
14
 
12
15
  def initialize
@@ -38,7 +38,7 @@ module Yoti
38
38
  end
39
39
 
40
40
  #
41
- # @param [String] *names
41
+ # @param [String] names
42
42
  #
43
43
  # @return [self]
44
44
  #
@@ -5,7 +5,11 @@ module Yoti
5
5
  # Extension for transactional flows
6
6
  class TransactionalFlowExtension
7
7
  EXTENSION_TYPE = 'TRANSACTIONAL_FLOW'
8
+
9
+ # @return [#to_json]
8
10
  attr_reader :content
11
+
12
+ # @return [String]
9
13
  attr_reader :type
10
14
 
11
15
  def initialize
@@ -7,7 +7,10 @@ module Yoti
7
7
  SELFIE_AUTH_TYPE = 1
8
8
  PIN_AUTH_TYPE = 2
9
9
 
10
+ # @return [Array<Integer>]
10
11
  attr_reader :wanted_auth_types
12
+
13
+ # @return [Array<Yoti::DynamicSharingService::WantedAttribute>]
11
14
  attr_reader :wanted
12
15
 
13
16
  def wanted_remember_me
@@ -16,8 +19,8 @@ module Yoti
16
19
  false
17
20
  end
18
21
 
19
- def to_json(*args)
20
- as_json.to_json(*args)
22
+ def to_json(*_args)
23
+ as_json.to_json
21
24
  end
22
25
 
23
26
  def as_json(*_args)
@@ -93,36 +96,54 @@ module Yoti
93
96
 
94
97
  #
95
98
  # @param [String] name
96
- # @param [Hash] constraints
99
+ # @param [Array<SourceConstraint>] constraints
100
+ # @param [Bool] accept_self_asserted
97
101
  #
98
- def with_wanted_attribute_by_name(name, constraints: nil)
102
+ def with_wanted_attribute_by_name(name, constraints: nil, accept_self_asserted: nil)
99
103
  attribute_builder = WantedAttribute.builder.with_name(name)
100
104
  constraints&.each do |constraint|
101
105
  attribute_builder.with_constraint constraint
102
106
  end
107
+ attribute_builder.with_accept_self_asserted(accept_self_asserted) unless accept_self_asserted.nil?
103
108
  attribute = attribute_builder.build
104
109
  with_wanted_attribute attribute
105
110
  end
106
111
 
112
+ #
113
+ # @option options [Array<SourceConstraint>] :constraints
114
+ # @option options [Bool] :accept_self_asserted
115
+ #
107
116
  def with_family_name(options = {})
108
117
  with_wanted_attribute_by_name Attribute::FAMILY_NAME, **options
109
118
  end
110
119
 
120
+ #
121
+ # @option options [Array<SourceConstraint>] :constraints
122
+ # @option options [Bool] :accept_self_asserted
123
+ #
111
124
  def with_given_names(options = {})
112
125
  with_wanted_attribute_by_name Attribute::GIVEN_NAMES, **options
113
126
  end
114
127
 
128
+ #
129
+ # @option options [Array<SourceConstraint>] :constraints
130
+ # @option options [Bool] :accept_self_asserted
131
+ #
115
132
  def with_full_name(options = {})
116
133
  with_wanted_attribute_by_name Attribute::FULL_NAME, **options
117
134
  end
118
135
 
136
+ #
137
+ # @option options [Array<SourceConstraint>] :constraints
138
+ # @option options [Bool] :accept_self_asserted
139
+ #
119
140
  def with_date_of_birth(options = {})
120
141
  with_wanted_attribute_by_name Attribute::DATE_OF_BIRTH, **options
121
142
  end
122
143
 
123
144
  #
124
145
  # @param [String] derivation
125
- # @param [Hash] constraints
146
+ # @param [Array<SourceConstraint>] constraints
126
147
  #
127
148
  def with_age_derived_attribute(derivation, constraints: nil)
128
149
  attribute_builder = WantedAttribute.builder
@@ -135,49 +156,93 @@ module Yoti
135
156
  end
136
157
 
137
158
  #
138
- # @param [Integer] derivation
159
+ # @param [Integer] age
160
+ # @option options [Array<SourceConstraint>] :constraints
161
+ # @option options [Bool] :accept_self_asserted
139
162
  #
140
163
  def with_age_over(age, options = {})
141
164
  with_age_derived_attribute(Attribute::AGE_OVER + age.to_s, **options)
142
165
  end
143
166
 
144
167
  #
145
- # @param [Integer] derivation
168
+ # @param [Integer] age
169
+ # @option options [Array<SourceConstraint>] :constraints
170
+ # @option options [Bool] :accept_self_asserted
146
171
  #
147
172
  def with_age_under(age, options = {})
148
173
  with_age_derived_attribute(Attribute::AGE_UNDER + age.to_s, **options)
149
174
  end
150
175
 
176
+ #
177
+ # @option options [Array<SourceConstraint>] :constraints
178
+ # @option options [Bool] :accept_self_asserted
179
+ #
151
180
  def with_gender(options = {})
152
181
  with_wanted_attribute_by_name Attribute::GENDER, **options
153
182
  end
154
183
 
184
+ #
185
+ # @option options [Array<SourceConstraint>] :constraints
186
+ # @option options [Bool] :accept_self_asserted
187
+ #
155
188
  def with_postal_address(options = {})
156
189
  with_wanted_attribute_by_name(Attribute::POSTAL_ADDRESS, **options)
157
190
  end
158
191
 
192
+ #
193
+ # @option options [Array<SourceConstraint>] :constraints
194
+ # @option options [Bool] :accept_self_asserted
195
+ #
159
196
  def with_structured_postal_address(options = {})
160
197
  with_wanted_attribute_by_name(Attribute::STRUCTURED_POSTAL_ADDRESS, **options)
161
198
  end
162
199
 
200
+ #
201
+ # @option options [Array<SourceConstraint>] :constraints
202
+ # @option options [Bool] :accept_self_asserted
203
+ #
163
204
  def with_nationality(options = {})
164
205
  with_wanted_attribute_by_name(Attribute::NATIONALITY, **options)
165
206
  end
166
207
 
208
+ #
209
+ # @option options [Array<SourceConstraint>] :constraints
210
+ # @option options [Bool] :accept_self_asserted
211
+ #
167
212
  def with_phone_number(options = {})
168
213
  with_wanted_attribute_by_name(Attribute::PHONE_NUMBER, **options)
169
214
  end
170
215
 
216
+ #
217
+ # @option options [Array<SourceConstraint>] :constraints
218
+ # @option options [Bool] :accept_self_asserted
219
+ #
171
220
  def with_selfie(options = {})
172
221
  with_wanted_attribute_by_name(Attribute::SELFIE, **options)
173
222
  end
174
223
 
224
+ #
225
+ # @option options [Array<SourceConstraint>] :constraints
226
+ # @option options [Bool] :accept_self_asserted
227
+ #
175
228
  def with_email(options = {})
176
229
  with_wanted_attribute_by_name(Attribute::EMAIL_ADDRESS, **options)
177
230
  end
178
231
 
179
- def with_document_details
180
- with_wanted_attribute_by_name(Attribute::DOCUMENT_DETAILS)
232
+ #
233
+ # @option options [Array<SourceConstraint>] :constraints
234
+ # @option options [Bool] :accept_self_asserted
235
+ #
236
+ def with_document_details(options = {})
237
+ with_wanted_attribute_by_name(Attribute::DOCUMENT_DETAILS, **options)
238
+ end
239
+
240
+ #
241
+ # @option options [Array<SourceConstraint>] :constraints
242
+ # @option options [Bool] :accept_self_asserted
243
+ #
244
+ def with_document_images(options = {})
245
+ with_wanted_attribute_by_name(Attribute::DOCUMENT_IMAGES, **options)
181
246
  end
182
247
  end
183
248
  end
@@ -4,7 +4,10 @@ module Yoti
4
4
  module DynamicSharingService
5
5
  # A wanted anchor for a source based constraint
6
6
  class WantedAnchor
7
+ # @return [String]
7
8
  attr_reader :value
9
+
10
+ # @return [String]
8
11
  attr_reader :sub_type
9
12
 
10
13
  def initialize
@@ -4,8 +4,13 @@ module Yoti
4
4
  module DynamicSharingService
5
5
  # Describes a wanted attribute in a dynamic sharing policy
6
6
  class WantedAttribute
7
+ # @return [String]
7
8
  attr_reader :name
9
+
10
+ # @return [String]
8
11
  attr_reader :derivation
12
+
13
+ # @return [Array<#as_json>]
9
14
  attr_reader :constraints
10
15
 
11
16
  def initialize
@@ -13,50 +13,33 @@ module Yoti
13
13
  end
14
14
  end
15
15
 
16
- def self.create_share_url_endpoint
17
- "/qrcodes/apps/#{Yoti.configuration.client_sdk_id}"
18
- end
19
-
20
- def self.create_share_url_query
21
- "?nonce=#{SecureRandom.uuid}&timestamp=#{Time.now.to_i}"
22
- end
23
-
24
16
  def self.create_share_url(scenario)
25
- endpoint = "#{create_share_url_endpoint}#{create_share_url_query}"
26
- uri = URI("#{Yoti.configuration.api_endpoint}#{endpoint}")
27
-
28
- unsigned = Net::HTTP::Post.new uri
29
- unsigned.body = scenario.to_json
30
-
31
- signed_request = Yoti::SignedRequest.new(
32
- unsigned,
33
- endpoint,
34
- scenario
35
- ).sign
36
-
37
- response = Net::HTTP.start(
38
- uri.hostname,
39
- uri.port,
40
- use_ssl: true
41
- ) do |http|
42
- http.request signed_request
43
- end
17
+ yoti_request = Yoti::Request
18
+ .builder
19
+ .with_http_method('POST')
20
+ .with_base_url(Yoti.configuration.api_endpoint)
21
+ .with_endpoint("qrcodes/apps/#{Yoti.configuration.client_sdk_id}")
22
+ .with_query_param('appId', Yoti.configuration.client_sdk_id)
23
+ .with_payload(scenario)
24
+ .build
44
25
 
45
- create_share_url_parse_response response
46
- end
26
+ begin
27
+ create_share_url_parse_response yoti_request.execute
28
+ rescue Yoti::RequestError => e
29
+ raise if e.response.nil?
47
30
 
48
- def self.create_share_url_parse_response(response)
49
- if response.code.to_i < 200 || response.code.to_i >= 300
50
- case response.code
31
+ case e.response.code
51
32
  when '400'
52
33
  raise InvalidDataError
53
34
  when '404'
54
35
  raise ApplicationNotFoundError
55
36
  else
56
- raise UnknownHTTPError, response.code
37
+ raise UnknownHTTPError, e.response.code
57
38
  end
58
39
  end
40
+ end
59
41
 
42
+ def self.create_share_url_parse_response(response)
60
43
  Share.new JSON.parse response.body
61
44
  end
62
45
 
@@ -78,5 +61,15 @@ module Yoti
78
61
  super msg
79
62
  end
80
63
  end
64
+
65
+ # @deprecated no longer used - will be removed in 2.0.0
66
+ def self.create_share_url_query
67
+ "?nonce=#{SecureRandom.uuid}&timestamp=#{Time.now.to_i}"
68
+ end
69
+
70
+ # @deprecated no longer used - will be removed in 2.0.0
71
+ def self.create_share_url_endpoint
72
+ "/qrcodes/apps/#{Yoti.configuration.client_sdk_id}"
73
+ end
81
74
  end
82
75
  end
@@ -3,12 +3,25 @@ module Yoti
3
3
  class ProtobufError < StandardError; end
4
4
 
5
5
  # Raises exceptions related to API requests
6
- class RequestError < StandardError; end
6
+ class RequestError < StandardError
7
+ attr_reader :response
8
+
9
+ def initialize(message, response = nil)
10
+ super(message)
11
+ @response = response
12
+ end
13
+
14
+ def message
15
+ return super if @response.nil? || @response.body.empty?
16
+
17
+ "#{super}: #{@response.body}"
18
+ end
19
+ end
7
20
 
8
21
  # Raises exceptions related to OpenSSL actions
9
22
  class SslError < StandardError; end
10
23
 
11
- # Raises exceptions realted to an incorrect gem configuration value
24
+ # Raises exceptions related to an incorrect gem configuration value
12
25
  class ConfigurationError < StandardError; end
13
26
 
14
27
  # Raises exceptions related to AML actions
@@ -1,13 +1,16 @@
1
1
  module Yoti
2
2
  # Manage the API's AML check requests
3
3
  class AmlCheckRequest
4
+ #
5
+ # @param [AmlProfile] aml_profile
6
+ #
4
7
  def initialize(aml_profile)
5
8
  @aml_profile = aml_profile
6
9
  @payload = aml_profile.payload
7
10
  @request = request
8
11
  end
9
12
 
10
- # @return [String] a JSON representation of the AML check response
13
+ # @return [Hash] a JSON representation of the AML check response
11
14
  def response
12
15
  JSON.parse(@request.body)
13
16
  end
@@ -15,11 +18,14 @@ module Yoti
15
18
  private
16
19
 
17
20
  def request
18
- yoti_request = Yoti::Request.new
19
- yoti_request.http_method = 'POST'
20
- yoti_request.endpoint = 'aml-check'
21
- yoti_request.payload = @payload
22
- yoti_request
21
+ Yoti::Request
22
+ .builder
23
+ .with_http_method('POST')
24
+ .with_base_url(Yoti.configuration.api_endpoint)
25
+ .with_endpoint('aml-check')
26
+ .with_query_param('appId', Yoti.configuration.client_sdk_id)
27
+ .with_payload(@payload)
28
+ .build
23
29
  end
24
30
  end
25
31
  end
@@ -7,6 +7,10 @@ module Yoti
7
7
  # @return [String] the postcode required for USA, optional otherwise
8
8
  attr_accessor :post_code
9
9
 
10
+ #
11
+ # @param [String] country
12
+ # @param [String] post_code
13
+ #
10
14
  def initialize(country, post_code = nil)
11
15
  raise AmlError, 'AmlAddress requires a country.' if country.to_s.empty?
12
16
 
@@ -1,6 +1,12 @@
1
1
  module Yoti
2
2
  # Manages the AML check Profile object
3
3
  class AmlProfile
4
+ #
5
+ # @param [String] given_names
6
+ # @param [String] family_name
7
+ # @param [AmlAddress] aml_address
8
+ # @param [String] ssn
9
+ #
4
10
  def initialize(given_names, family_name, aml_address, ssn = nil)
5
11
  @given_names = given_names
6
12
  @family_name = family_name
@@ -11,7 +17,7 @@ module Yoti
11
17
  raise AmlError, 'Request for USA require a valid SSN and postcode.' if usa_invalid
12
18
  end
13
19
 
14
- # @return [Object] the AML check request body
20
+ # @return [Hash] the AML check request body
15
21
  def payload
16
22
  {
17
23
  given_names: @given_names,
@@ -1,6 +1,9 @@
1
1
  module Yoti
2
2
  # Manage the API's profile requests
3
3
  class ProfileRequest
4
+ #
5
+ # @param [String] encrypted_connect_token
6
+ #
4
7
  def initialize(encrypted_connect_token)
5
8
  @encrypted_connect_token = encrypted_connect_token
6
9
  @request = request
@@ -14,12 +17,14 @@ module Yoti
14
17
  private
15
18
 
16
19
  def request
17
- yoti_request = Yoti::Request.new
18
- yoti_request.add_header('X-Yoti-Auth-Key', Yoti::SSL.auth_key_from_pem)
19
- yoti_request.encrypted_connect_token = @encrypted_connect_token
20
- yoti_request.http_method = 'GET'
21
- yoti_request.endpoint = 'profile'
22
- yoti_request
20
+ Yoti::Request
21
+ .builder
22
+ .with_http_method('GET')
23
+ .with_base_url(Yoti.configuration.api_endpoint)
24
+ .with_endpoint("profile/#{Yoti::SSL.decrypt_token(@encrypted_connect_token)}")
25
+ .with_query_param('appId', Yoti.configuration.client_sdk_id)
26
+ .with_header('X-Yoti-Auth-Key', Yoti::SSL.auth_key_from_pem)
27
+ .build
23
28
  end
24
29
  end
25
30
  end