onfido 6.2.0 → 6.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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +1 -1
  4. data/lib/onfido/api/default_api.rb +413 -0
  5. data/lib/onfido/api_client.rb +6 -2
  6. data/lib/onfido/models/biometric_token.rb +265 -0
  7. data/lib/onfido/models/biometric_token_data.rb +317 -0
  8. data/lib/onfido/models/biometric_token_response.rb +237 -0
  9. data/lib/onfido/models/biometric_token_updater.rb +262 -0
  10. data/lib/onfido/models/biometric_tokens_response.rb +239 -0
  11. data/lib/onfido/models/document_types.rb +3 -1
  12. data/lib/onfido/models/invalidated_biometric_token_response.rb +237 -0
  13. data/lib/onfido/models/invalidated_biometric_token_summary.rb +238 -0
  14. data/lib/onfido/models/invalidated_biometric_token_summary_deleted_items.rb +239 -0
  15. data/lib/onfido/models/invalidated_biometric_tokens_response.rb +237 -0
  16. data/lib/onfido/models/updated_biometric_token_response.rb +237 -0
  17. data/lib/onfido/models/watchlist_mesh_added_mentions.rb +247 -0
  18. data/lib/onfido/models/watchlist_mesh_alert_risk.rb +323 -0
  19. data/lib/onfido/models/watchlist_mesh_alert_risk1.rb +316 -0
  20. data/lib/onfido/models/watchlist_mesh_associate.rb +231 -0
  21. data/lib/onfido/models/watchlist_mesh_date_value.rb +231 -0
  22. data/lib/onfido/models/watchlist_mesh_field.rb +241 -0
  23. data/lib/onfido/models/watchlist_mesh_image.rb +231 -0
  24. data/lib/onfido/models/watchlist_mesh_lists.rb +309 -0
  25. data/lib/onfido/models/watchlist_mesh_media.rb +261 -0
  26. data/lib/onfido/models/watchlist_mesh_name.rb +231 -0
  27. data/lib/onfido/models/watchlist_mesh_pep.rb +369 -0
  28. data/lib/onfido/models/watchlist_mesh_person.rb +283 -0
  29. data/lib/onfido/models/watchlist_mesh_profile.rb +273 -0
  30. data/lib/onfido/models/watchlist_mesh_risk_decision.rb +43 -0
  31. data/lib/onfido/models/watchlist_mesh_risk_detail.rb +255 -0
  32. data/lib/onfido/models/watchlist_mesh_risk_indicators.rb +271 -0
  33. data/lib/onfido/models/watchlist_mesh_sanctions.rb +309 -0
  34. data/lib/onfido/models/webhook.rb +11 -1
  35. data/lib/onfido/models/webhook_builder.rb +11 -1
  36. data/lib/onfido/models/webhook_create.rb +11 -1
  37. data/lib/onfido/models/webhook_response.rb +11 -1
  38. data/lib/onfido/models/webhook_update.rb +11 -1
  39. data/lib/onfido/models/webhook_updater.rb +11 -1
  40. data/lib/onfido/version.rb +1 -1
  41. data/lib/onfido.rb +27 -0
  42. data/spec/integrations/biometric_token_spec.rb +122 -0
  43. data/spec/integrations/document_spec.rb +8 -1
  44. data/spec/integrations/media/nfc_data.json +11768 -0
  45. data/spec/integrations/watchlist_alert_risk_spec.rb +66 -0
  46. data/spec/shared_contexts/with_document.rb +0 -1
  47. data/spec/spec_helper.rb +6 -7
  48. metadata +55 -22
@@ -0,0 +1,369 @@
1
+ =begin
2
+ #Onfido Public API v3.6
3
+
4
+ #The Onfido Public API (v3.6)
5
+
6
+ The version of the OpenAPI document: v3.6
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.16.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Onfido
17
+ class WatchlistMeshPep
18
+ attr_accessor :aml_types
19
+
20
+ attr_accessor :active_end_dates
21
+
22
+ attr_accessor :active_start_dates
23
+
24
+ attr_accessor :country_codes
25
+
26
+ attr_accessor :fields
27
+
28
+ attr_accessor :identifier
29
+
30
+ attr_accessor :listing_ended_utc
31
+
32
+ attr_accessor :listing_started_utc
33
+
34
+ attr_accessor :name
35
+
36
+ attr_accessor :political_parties
37
+
38
+ attr_accessor :political_positions
39
+
40
+ attr_accessor :political_regions
41
+
42
+ attr_accessor :related_urls
43
+
44
+ attr_accessor :url
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'aml_types' => :'aml_types',
50
+ :'active_end_dates' => :'active_end_dates',
51
+ :'active_start_dates' => :'active_start_dates',
52
+ :'country_codes' => :'country_codes',
53
+ :'fields' => :'fields',
54
+ :'identifier' => :'identifier',
55
+ :'listing_ended_utc' => :'listing_ended_utc',
56
+ :'listing_started_utc' => :'listing_started_utc',
57
+ :'name' => :'name',
58
+ :'political_parties' => :'political_parties',
59
+ :'political_positions' => :'political_positions',
60
+ :'political_regions' => :'political_regions',
61
+ :'related_urls' => :'related_urls',
62
+ :'url' => :'url'
63
+ }
64
+ end
65
+
66
+ # Returns attribute mapping this model knows about
67
+ def self.acceptable_attribute_map
68
+ attribute_map
69
+ end
70
+
71
+ # Returns all the JSON keys this model knows about
72
+ def self.acceptable_attributes
73
+ acceptable_attribute_map.values
74
+ end
75
+
76
+ # Attribute type mapping.
77
+ def self.openapi_types
78
+ {
79
+ :'aml_types' => :'Array<String>',
80
+ :'active_end_dates' => :'Array<String>',
81
+ :'active_start_dates' => :'Array<String>',
82
+ :'country_codes' => :'Array<String>',
83
+ :'fields' => :'Array<WatchlistMeshField>',
84
+ :'identifier' => :'String',
85
+ :'listing_ended_utc' => :'String',
86
+ :'listing_started_utc' => :'String',
87
+ :'name' => :'String',
88
+ :'political_parties' => :'Array<String>',
89
+ :'political_positions' => :'Array<String>',
90
+ :'political_regions' => :'Array<String>',
91
+ :'related_urls' => :'Array<String>',
92
+ :'url' => :'String'
93
+ }
94
+ end
95
+
96
+ # List of attributes with nullable: true
97
+ def self.openapi_nullable
98
+ Set.new([
99
+ :'aml_types',
100
+ :'active_end_dates',
101
+ :'active_start_dates',
102
+ :'country_codes',
103
+ :'fields',
104
+ :'identifier',
105
+ :'listing_ended_utc',
106
+ :'listing_started_utc',
107
+ :'name',
108
+ :'political_parties',
109
+ :'political_positions',
110
+ :'political_regions',
111
+ :'related_urls',
112
+ :'url'
113
+ ])
114
+ end
115
+
116
+ # Initializes the object
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ def initialize(attributes = {})
119
+ if (!attributes.is_a?(Hash))
120
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::WatchlistMeshPep` initialize method"
121
+ end
122
+
123
+ # check to see if the attribute exists and convert string to symbol for hash key
124
+ acceptable_attribute_map = self.class.acceptable_attribute_map
125
+ attributes = attributes.each_with_object({}) { |(k, v), h|
126
+ if (!acceptable_attribute_map.key?(k.to_sym))
127
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::WatchlistMeshPep`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
128
+ end
129
+ h[k.to_sym] = v
130
+ }
131
+
132
+ if attributes.key?(:'aml_types')
133
+ if (value = attributes[:'aml_types']).is_a?(Array)
134
+ self.aml_types = value
135
+ end
136
+ end
137
+
138
+ if attributes.key?(:'active_end_dates')
139
+ if (value = attributes[:'active_end_dates']).is_a?(Array)
140
+ self.active_end_dates = value
141
+ end
142
+ end
143
+
144
+ if attributes.key?(:'active_start_dates')
145
+ if (value = attributes[:'active_start_dates']).is_a?(Array)
146
+ self.active_start_dates = value
147
+ end
148
+ end
149
+
150
+ if attributes.key?(:'country_codes')
151
+ if (value = attributes[:'country_codes']).is_a?(Array)
152
+ self.country_codes = value
153
+ end
154
+ end
155
+
156
+ if attributes.key?(:'fields')
157
+ if (value = attributes[:'fields']).is_a?(Array)
158
+ self.fields = value
159
+ end
160
+ end
161
+
162
+ if attributes.key?(:'identifier')
163
+ self.identifier = attributes[:'identifier']
164
+ end
165
+
166
+ if attributes.key?(:'listing_ended_utc')
167
+ self.listing_ended_utc = attributes[:'listing_ended_utc']
168
+ end
169
+
170
+ if attributes.key?(:'listing_started_utc')
171
+ self.listing_started_utc = attributes[:'listing_started_utc']
172
+ end
173
+
174
+ if attributes.key?(:'name')
175
+ self.name = attributes[:'name']
176
+ end
177
+
178
+ if attributes.key?(:'political_parties')
179
+ if (value = attributes[:'political_parties']).is_a?(Array)
180
+ self.political_parties = value
181
+ end
182
+ end
183
+
184
+ if attributes.key?(:'political_positions')
185
+ if (value = attributes[:'political_positions']).is_a?(Array)
186
+ self.political_positions = value
187
+ end
188
+ end
189
+
190
+ if attributes.key?(:'political_regions')
191
+ if (value = attributes[:'political_regions']).is_a?(Array)
192
+ self.political_regions = value
193
+ end
194
+ end
195
+
196
+ if attributes.key?(:'related_urls')
197
+ if (value = attributes[:'related_urls']).is_a?(Array)
198
+ self.related_urls = value
199
+ end
200
+ end
201
+
202
+ if attributes.key?(:'url')
203
+ self.url = attributes[:'url']
204
+ end
205
+ end
206
+
207
+ # Show invalid properties with the reasons. Usually used together with valid?
208
+ # @return Array for valid properties with the reasons
209
+ def list_invalid_properties
210
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
211
+ invalid_properties = Array.new
212
+ invalid_properties
213
+ end
214
+
215
+ # Check to see if the all the properties in the model are valid
216
+ # @return true if the model is valid
217
+ def valid?
218
+ warn '[DEPRECATED] the `valid?` method is obsolete'
219
+ true
220
+ end
221
+
222
+ # Checks equality by comparing each attribute.
223
+ # @param [Object] Object to be compared
224
+ def ==(o)
225
+ return true if self.equal?(o)
226
+ self.class == o.class &&
227
+ aml_types == o.aml_types &&
228
+ active_end_dates == o.active_end_dates &&
229
+ active_start_dates == o.active_start_dates &&
230
+ country_codes == o.country_codes &&
231
+ fields == o.fields &&
232
+ identifier == o.identifier &&
233
+ listing_ended_utc == o.listing_ended_utc &&
234
+ listing_started_utc == o.listing_started_utc &&
235
+ name == o.name &&
236
+ political_parties == o.political_parties &&
237
+ political_positions == o.political_positions &&
238
+ political_regions == o.political_regions &&
239
+ related_urls == o.related_urls &&
240
+ url == o.url
241
+ end
242
+
243
+ # @see the `==` method
244
+ # @param [Object] Object to be compared
245
+ def eql?(o)
246
+ self == o
247
+ end
248
+
249
+ # Calculates hash code according to all attributes.
250
+ # @return [Integer] Hash code
251
+ def hash
252
+ [aml_types, active_end_dates, active_start_dates, country_codes, fields, identifier, listing_ended_utc, listing_started_utc, name, political_parties, political_positions, political_regions, related_urls, url].hash
253
+ end
254
+
255
+ # Builds the object from hash
256
+ # @param [Hash] attributes Model attributes in the form of hash
257
+ # @return [Object] Returns the model itself
258
+ def self.build_from_hash(attributes)
259
+ return nil unless attributes.is_a?(Hash)
260
+ attributes = attributes.transform_keys(&:to_sym)
261
+ transformed_hash = {}
262
+ openapi_types.each_pair do |key, type|
263
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
264
+ transformed_hash["#{key}"] = nil
265
+ elsif type =~ /\AArray<(.*)>/i
266
+ # check to ensure the input is an array given that the attribute
267
+ # is documented as an array but the input is not
268
+ if attributes[attribute_map[key]].is_a?(Array)
269
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
270
+ end
271
+ elsif !attributes[attribute_map[key]].nil?
272
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
273
+ end
274
+ end
275
+ new(transformed_hash)
276
+ end
277
+
278
+ # Deserializes the data based on type
279
+ # @param string type Data type
280
+ # @param string value Value to be deserialized
281
+ # @return [Object] Deserialized data
282
+ def self._deserialize(type, value)
283
+ case type.to_sym
284
+ when :Time
285
+ Time.parse(value)
286
+ when :Date
287
+ Date.parse(value)
288
+ when :String
289
+ value.to_s
290
+ when :Integer
291
+ value.to_i
292
+ when :Float
293
+ value.to_f
294
+ when :Boolean
295
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
296
+ true
297
+ else
298
+ false
299
+ end
300
+ when :Object
301
+ # generic object (usually a Hash), return directly
302
+ value
303
+ when /\AArray<(?<inner_type>.+)>\z/
304
+ inner_type = Regexp.last_match[:inner_type]
305
+ value.map { |v| _deserialize(inner_type, v) }
306
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
307
+ k_type = Regexp.last_match[:k_type]
308
+ v_type = Regexp.last_match[:v_type]
309
+ {}.tap do |hash|
310
+ value.each do |k, v|
311
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
312
+ end
313
+ end
314
+ else # model
315
+ # models (e.g. Pet) or oneOf
316
+ klass = Onfido.const_get(type)
317
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
318
+ end
319
+ end
320
+
321
+ # Returns the string representation of the object
322
+ # @return [String] String presentation of the object
323
+ def to_s
324
+ to_hash.to_s
325
+ end
326
+
327
+ # to_body is an alias to to_hash (backward compatibility)
328
+ # @return [Hash] Returns the object in the form of hash
329
+ def to_body
330
+ to_hash
331
+ end
332
+
333
+ # Returns the object in the form of hash
334
+ # @return [Hash] Returns the object in the form of hash
335
+ def to_hash
336
+ hash = {}
337
+ self.class.attribute_map.each_pair do |attr, param|
338
+ value = self.send(attr)
339
+ if value.nil?
340
+ is_nullable = self.class.openapi_nullable.include?(attr)
341
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
342
+ end
343
+
344
+ hash[param] = _to_hash(value)
345
+ end
346
+ hash
347
+ end
348
+
349
+ # Outputs non-array value in the form of hash
350
+ # For object, use to_hash. Otherwise, just return the value
351
+ # @param [Object] value Any valid value
352
+ # @return [Hash] Returns the value in the form of hash
353
+ def _to_hash(value)
354
+ if value.is_a?(Array)
355
+ value.compact.map { |v| _to_hash(v) }
356
+ elsif value.is_a?(Hash)
357
+ {}.tap do |hash|
358
+ value.each { |k, v| hash[k] = _to_hash(v) }
359
+ end
360
+ elsif value.respond_to? :to_hash
361
+ value.to_hash
362
+ else
363
+ value
364
+ end
365
+ end
366
+
367
+ end
368
+
369
+ end
@@ -0,0 +1,283 @@
1
+ =begin
2
+ #Onfido Public API v3.6
3
+
4
+ #The Onfido Public API (v3.6)
5
+
6
+ The version of the OpenAPI document: v3.6
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.16.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Onfido
17
+ class WatchlistMeshPerson
18
+ attr_accessor :associates
19
+
20
+ attr_accessor :dates_of_birth
21
+
22
+ attr_accessor :dates_of_death
23
+
24
+ attr_accessor :images
25
+
26
+ attr_accessor :names
27
+
28
+ attr_accessor :places_of_birth
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'associates' => :'associates',
34
+ :'dates_of_birth' => :'dates_of_birth',
35
+ :'dates_of_death' => :'dates_of_death',
36
+ :'images' => :'images',
37
+ :'names' => :'names',
38
+ :'places_of_birth' => :'places_of_birth'
39
+ }
40
+ end
41
+
42
+ # Returns attribute mapping this model knows about
43
+ def self.acceptable_attribute_map
44
+ attribute_map
45
+ end
46
+
47
+ # Returns all the JSON keys this model knows about
48
+ def self.acceptable_attributes
49
+ acceptable_attribute_map.values
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.openapi_types
54
+ {
55
+ :'associates' => :'Array<WatchlistMeshAssociate>',
56
+ :'dates_of_birth' => :'Array<WatchlistMeshDateValue>',
57
+ :'dates_of_death' => :'Array<WatchlistMeshDateValue>',
58
+ :'images' => :'Array<WatchlistMeshImage>',
59
+ :'names' => :'Array<WatchlistMeshName>',
60
+ :'places_of_birth' => :'Array<String>'
61
+ }
62
+ end
63
+
64
+ # List of attributes with nullable: true
65
+ def self.openapi_nullable
66
+ Set.new([
67
+ :'associates',
68
+ :'dates_of_birth',
69
+ :'dates_of_death',
70
+ :'images',
71
+ :'names',
72
+ :'places_of_birth'
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::WatchlistMeshPerson` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ acceptable_attribute_map = self.class.acceptable_attribute_map
85
+ attributes = attributes.each_with_object({}) { |(k, v), h|
86
+ if (!acceptable_attribute_map.key?(k.to_sym))
87
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::WatchlistMeshPerson`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
88
+ end
89
+ h[k.to_sym] = v
90
+ }
91
+
92
+ if attributes.key?(:'associates')
93
+ if (value = attributes[:'associates']).is_a?(Array)
94
+ self.associates = value
95
+ end
96
+ end
97
+
98
+ if attributes.key?(:'dates_of_birth')
99
+ if (value = attributes[:'dates_of_birth']).is_a?(Array)
100
+ self.dates_of_birth = value
101
+ end
102
+ end
103
+
104
+ if attributes.key?(:'dates_of_death')
105
+ if (value = attributes[:'dates_of_death']).is_a?(Array)
106
+ self.dates_of_death = value
107
+ end
108
+ end
109
+
110
+ if attributes.key?(:'images')
111
+ if (value = attributes[:'images']).is_a?(Array)
112
+ self.images = value
113
+ end
114
+ end
115
+
116
+ if attributes.key?(:'names')
117
+ if (value = attributes[:'names']).is_a?(Array)
118
+ self.names = value
119
+ end
120
+ end
121
+
122
+ if attributes.key?(:'places_of_birth')
123
+ if (value = attributes[:'places_of_birth']).is_a?(Array)
124
+ self.places_of_birth = value
125
+ end
126
+ end
127
+ end
128
+
129
+ # Show invalid properties with the reasons. Usually used together with valid?
130
+ # @return Array for valid properties with the reasons
131
+ def list_invalid_properties
132
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
133
+ invalid_properties = Array.new
134
+ invalid_properties
135
+ end
136
+
137
+ # Check to see if the all the properties in the model are valid
138
+ # @return true if the model is valid
139
+ def valid?
140
+ warn '[DEPRECATED] the `valid?` method is obsolete'
141
+ true
142
+ end
143
+
144
+ # Checks equality by comparing each attribute.
145
+ # @param [Object] Object to be compared
146
+ def ==(o)
147
+ return true if self.equal?(o)
148
+ self.class == o.class &&
149
+ associates == o.associates &&
150
+ dates_of_birth == o.dates_of_birth &&
151
+ dates_of_death == o.dates_of_death &&
152
+ images == o.images &&
153
+ names == o.names &&
154
+ places_of_birth == o.places_of_birth
155
+ end
156
+
157
+ # @see the `==` method
158
+ # @param [Object] Object to be compared
159
+ def eql?(o)
160
+ self == o
161
+ end
162
+
163
+ # Calculates hash code according to all attributes.
164
+ # @return [Integer] Hash code
165
+ def hash
166
+ [associates, dates_of_birth, dates_of_death, images, names, places_of_birth].hash
167
+ end
168
+
169
+ # Builds the object from hash
170
+ # @param [Hash] attributes Model attributes in the form of hash
171
+ # @return [Object] Returns the model itself
172
+ def self.build_from_hash(attributes)
173
+ return nil unless attributes.is_a?(Hash)
174
+ attributes = attributes.transform_keys(&:to_sym)
175
+ transformed_hash = {}
176
+ openapi_types.each_pair do |key, type|
177
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
178
+ transformed_hash["#{key}"] = nil
179
+ elsif type =~ /\AArray<(.*)>/i
180
+ # check to ensure the input is an array given that the attribute
181
+ # is documented as an array but the input is not
182
+ if attributes[attribute_map[key]].is_a?(Array)
183
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
184
+ end
185
+ elsif !attributes[attribute_map[key]].nil?
186
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
187
+ end
188
+ end
189
+ new(transformed_hash)
190
+ end
191
+
192
+ # Deserializes the data based on type
193
+ # @param string type Data type
194
+ # @param string value Value to be deserialized
195
+ # @return [Object] Deserialized data
196
+ def self._deserialize(type, value)
197
+ case type.to_sym
198
+ when :Time
199
+ Time.parse(value)
200
+ when :Date
201
+ Date.parse(value)
202
+ when :String
203
+ value.to_s
204
+ when :Integer
205
+ value.to_i
206
+ when :Float
207
+ value.to_f
208
+ when :Boolean
209
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
210
+ true
211
+ else
212
+ false
213
+ end
214
+ when :Object
215
+ # generic object (usually a Hash), return directly
216
+ value
217
+ when /\AArray<(?<inner_type>.+)>\z/
218
+ inner_type = Regexp.last_match[:inner_type]
219
+ value.map { |v| _deserialize(inner_type, v) }
220
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
221
+ k_type = Regexp.last_match[:k_type]
222
+ v_type = Regexp.last_match[:v_type]
223
+ {}.tap do |hash|
224
+ value.each do |k, v|
225
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
226
+ end
227
+ end
228
+ else # model
229
+ # models (e.g. Pet) or oneOf
230
+ klass = Onfido.const_get(type)
231
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
232
+ end
233
+ end
234
+
235
+ # Returns the string representation of the object
236
+ # @return [String] String presentation of the object
237
+ def to_s
238
+ to_hash.to_s
239
+ end
240
+
241
+ # to_body is an alias to to_hash (backward compatibility)
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_body
244
+ to_hash
245
+ end
246
+
247
+ # Returns the object in the form of hash
248
+ # @return [Hash] Returns the object in the form of hash
249
+ def to_hash
250
+ hash = {}
251
+ self.class.attribute_map.each_pair do |attr, param|
252
+ value = self.send(attr)
253
+ if value.nil?
254
+ is_nullable = self.class.openapi_nullable.include?(attr)
255
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
256
+ end
257
+
258
+ hash[param] = _to_hash(value)
259
+ end
260
+ hash
261
+ end
262
+
263
+ # Outputs non-array value in the form of hash
264
+ # For object, use to_hash. Otherwise, just return the value
265
+ # @param [Object] value Any valid value
266
+ # @return [Hash] Returns the value in the form of hash
267
+ def _to_hash(value)
268
+ if value.is_a?(Array)
269
+ value.compact.map { |v| _to_hash(v) }
270
+ elsif value.is_a?(Hash)
271
+ {}.tap do |hash|
272
+ value.each { |k, v| hash[k] = _to_hash(v) }
273
+ end
274
+ elsif value.respond_to? :to_hash
275
+ value.to_hash
276
+ else
277
+ value
278
+ end
279
+ end
280
+
281
+ end
282
+
283
+ end