Class: Yoti::Sandbox::Profile::TokenRequestBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/yoti_sandbox/profile/token_request.rb

Overview

Builder for TokenRequest

Instance Method Summary collapse

Constructor Details

#initializeTokenRequestBuilder

Returns a new instance of TokenRequestBuilder.



54
55
56
57
# File 'lib/yoti_sandbox/profile/token_request.rb', line 54

def initialize
  @remember_me_id = ''
  @attributes = []
end

Instance Method Details

#buildTokenRequest

Returns:



296
297
298
# File 'lib/yoti_sandbox/profile/token_request.rb', line 296

def build
  TokenRequest.new(@remember_me_id, @attributes)
end

#with_age_verification(age_verification) ⇒ self

Parameters:

Returns:

  • (self)


148
149
150
# File 'lib/yoti_sandbox/profile/token_request.rb', line 148

def with_age_verification(age_verification)
  with_attribute(age_verification.to_attribute)
end

#with_attribute(attribute) ⇒ self

Parameters:

Returns:

  • (self)


74
75
76
77
# File 'lib/yoti_sandbox/profile/token_request.rb', line 74

def with_attribute(attribute)
  @attributes.push attribute
  self
end

#with_base64_selfie(base64_data, anchors: []) ⇒ self

Parameters:

  • base64_data (String)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


251
252
253
254
255
256
257
258
259
# File 'lib/yoti_sandbox/profile/token_request.rb', line 251

def with_base64_selfie(base64_data, anchors: [])
  with_attribute(
    create_attribute(
      name: Yoti::Attribute::SELFIE,
      value: base64_data,
      anchors: anchors
    )
  )
end

#with_date_of_birth(date, anchors: []) ⇒ self

Parameters:

  • date (DateTime|Time)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


133
134
135
136
137
138
139
140
141
# File 'lib/yoti_sandbox/profile/token_request.rb', line 133

def with_date_of_birth(date, anchors: [])
  with_attribute(
    create_attribute(
      name: Yoti::Attribute::DATE_OF_BIRTH,
      value: date.strftime('%F'),
      anchors: anchors
    )
  )
end

#with_document_details(value, anchors: []) ⇒ self

Parameters:

  • value (String)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


283
284
285
286
287
288
289
290
291
# File 'lib/yoti_sandbox/profile/token_request.rb', line 283

def with_document_details(value, anchors: [])
  with_attribute(
    create_attribute(
      name: Yoti::Attribute::DOCUMENT_DETAILS,
      value: value,
      anchors: anchors
    )
  )
end

#with_email_address(value, anchors: []) ⇒ self

Parameters:

  • value (String)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


267
268
269
270
271
272
273
274
275
# File 'lib/yoti_sandbox/profile/token_request.rb', line 267

def with_email_address(value, anchors: [])
  with_attribute(
    create_attribute(
      name: Yoti::Attribute::EMAIL_ADDRESS,
      value: value,
      anchors: anchors
    )
  )
end

#with_family_name(value, anchors: []) ⇒ self

Parameters:

  • value (String)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


101
102
103
104
105
106
107
108
109
# File 'lib/yoti_sandbox/profile/token_request.rb', line 101

def with_family_name(value, anchors: [])
  with_attribute(
    create_attribute(
      name: Yoti::Attribute::FAMILY_NAME,
      value: value,
      anchors: anchors
    )
  )
end

#with_full_name(value, anchors: []) ⇒ self

Parameters:

  • value (String)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


117
118
119
120
121
122
123
124
125
# File 'lib/yoti_sandbox/profile/token_request.rb', line 117

def with_full_name(value, anchors: [])
  with_attribute(
    create_attribute(
      name: Yoti::Attribute::FULL_NAME,
      value: value,
      anchors: anchors
    )
  )
end

#with_gender(value, anchors: []) ⇒ self

Parameters:

  • value (String)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


158
159
160
161
162
163
164
165
166
# File 'lib/yoti_sandbox/profile/token_request.rb', line 158

def with_gender(value, anchors: [])
  with_attribute(
    create_attribute(
      name: Yoti::Attribute::GENDER,
      value: value,
      anchors: anchors
    )
  )
end

#with_given_names(value, anchors: []) ⇒ self

Parameters:

  • value (String)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


85
86
87
88
89
90
91
92
93
# File 'lib/yoti_sandbox/profile/token_request.rb', line 85

def with_given_names(value, anchors: [])
  with_attribute(
    create_attribute(
      name: Yoti::Attribute::GIVEN_NAMES,
      value: value,
      anchors: anchors
    )
  )
end

#with_nationality(value, anchors: []) ⇒ self

Parameters:

  • value (String)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


190
191
192
193
194
195
196
197
198
# File 'lib/yoti_sandbox/profile/token_request.rb', line 190

def with_nationality(value, anchors: [])
  with_attribute(
    create_attribute(
      name: Yoti::Attribute::NATIONALITY,
      value: value,
      anchors: anchors
    )
  )
end

#with_phone_number(value, anchors: []) ⇒ self

Parameters:

  • value (String)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


174
175
176
177
178
179
180
181
182
# File 'lib/yoti_sandbox/profile/token_request.rb', line 174

def with_phone_number(value, anchors: [])
  with_attribute(
    create_attribute(
      name: Yoti::Attribute::PHONE_NUMBER,
      value: value,
      anchors: anchors
    )
  )
end

#with_postal_address(value, anchors: []) ⇒ self

Parameters:

  • value (String)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


206
207
208
209
210
211
212
213
214
# File 'lib/yoti_sandbox/profile/token_request.rb', line 206

def with_postal_address(value, anchors: [])
  with_attribute(
    create_attribute(
      name: Yoti::Attribute::POSTAL_ADDRESS,
      value: value,
      anchors: anchors
    )
  )
end

#with_remember_me_id(remember_me_id) ⇒ self

Parameters:

  • remember_me_id (String)

Returns:

  • (self)


64
65
66
67
# File 'lib/yoti_sandbox/profile/token_request.rb', line 64

def with_remember_me_id(remember_me_id)
  @remember_me_id = remember_me_id
  self
end

#with_selfie(data, anchors: []) ⇒ self

Parameters:

  • data (bin)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


238
239
240
241
242
243
# File 'lib/yoti_sandbox/profile/token_request.rb', line 238

def with_selfie(data, anchors: [])
  with_base64_selfie(
    Base64.strict_encode64(data),
    anchors: anchors
  )
end

#with_structured_postal_address(data, anchors: []) ⇒ self

Parameters:

  • data (Hash)
  • anchors (Array<Anchor>) (defaults to: [])

Returns:

  • (self)


222
223
224
225
226
227
228
229
230
# File 'lib/yoti_sandbox/profile/token_request.rb', line 222

def with_structured_postal_address(data, anchors: [])
  with_attribute(
    create_attribute(
      name: Yoti::Attribute::STRUCTURED_POSTAL_ADDRESS,
      value: data.to_json,
      anchors: anchors
    )
  )
end