onfido 6.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +17 -1
- data/lib/onfido/api/default_api.rb +492 -79
- data/lib/onfido/api_client.rb +6 -2
- data/lib/onfido/configuration.rb +88 -0
- data/lib/onfido/models/biometric_token.rb +265 -0
- data/lib/onfido/models/biometric_token_data.rb +317 -0
- data/lib/onfido/models/biometric_token_response.rb +237 -0
- data/lib/onfido/models/biometric_token_updater.rb +262 -0
- data/lib/onfido/models/biometric_tokens_response.rb +239 -0
- data/lib/onfido/models/document_types.rb +3 -1
- data/lib/onfido/models/invalidated_biometric_token_response.rb +237 -0
- data/lib/onfido/models/invalidated_biometric_token_summary.rb +238 -0
- data/lib/onfido/models/invalidated_biometric_token_summary_deleted_items.rb +239 -0
- data/lib/onfido/models/invalidated_biometric_tokens_response.rb +237 -0
- data/lib/onfido/models/updated_biometric_token_response.rb +237 -0
- data/lib/onfido/models/watchlist_mesh_added_mentions.rb +247 -0
- data/lib/onfido/models/watchlist_mesh_alert_risk.rb +323 -0
- data/lib/onfido/models/watchlist_mesh_alert_risk1.rb +316 -0
- data/lib/onfido/models/watchlist_mesh_associate.rb +231 -0
- data/lib/onfido/models/watchlist_mesh_date_value.rb +231 -0
- data/lib/onfido/models/watchlist_mesh_field.rb +241 -0
- data/lib/onfido/models/watchlist_mesh_image.rb +231 -0
- data/lib/onfido/models/watchlist_mesh_lists.rb +309 -0
- data/lib/onfido/models/watchlist_mesh_media.rb +261 -0
- data/lib/onfido/models/watchlist_mesh_name.rb +231 -0
- data/lib/onfido/models/watchlist_mesh_pep.rb +369 -0
- data/lib/onfido/models/watchlist_mesh_person.rb +283 -0
- data/lib/onfido/models/watchlist_mesh_profile.rb +273 -0
- data/lib/onfido/models/watchlist_mesh_risk_decision.rb +43 -0
- data/lib/onfido/models/watchlist_mesh_risk_detail.rb +255 -0
- data/lib/onfido/models/watchlist_mesh_risk_indicators.rb +271 -0
- data/lib/onfido/models/watchlist_mesh_sanctions.rb +309 -0
- data/lib/onfido/models/webhook.rb +11 -1
- data/lib/onfido/models/webhook_builder.rb +11 -1
- data/lib/onfido/models/webhook_create.rb +11 -1
- data/lib/onfido/models/webhook_response.rb +11 -1
- data/lib/onfido/models/webhook_update.rb +11 -1
- data/lib/onfido/models/webhook_updater.rb +11 -1
- data/lib/onfido/version.rb +1 -1
- data/lib/onfido.rb +27 -0
- data/spec/integrations/biometric_token_spec.rb +122 -0
- data/spec/integrations/document_spec.rb +8 -1
- data/spec/integrations/media/nfc_data.json +11768 -0
- data/spec/integrations/watchlist_alert_risk_spec.rb +66 -0
- data/spec/shared_contexts/with_document.rb +0 -1
- data/spec/shared_contexts/with_onfido.rb +14 -2
- data/spec/spec_helper.rb +6 -7
- metadata +57 -24
data/lib/onfido/api_client.rb
CHANGED
|
@@ -35,7 +35,7 @@ module Onfido
|
|
|
35
35
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
|
36
36
|
def initialize(config = Configuration.default)
|
|
37
37
|
@config = config
|
|
38
|
-
@user_agent = "onfido-ruby/6.
|
|
38
|
+
@user_agent = "onfido-ruby/6.3.0"
|
|
39
39
|
@default_headers = {
|
|
40
40
|
'Content-Type' => 'application/json',
|
|
41
41
|
'User-Agent' => @user_agent
|
|
@@ -142,7 +142,11 @@ module Onfido
|
|
|
142
142
|
form_params.each do |key, value|
|
|
143
143
|
case value
|
|
144
144
|
when ::File, ::Tempfile
|
|
145
|
-
|
|
145
|
+
mime = Marcel::MimeType.for(Pathname.new(value.path))
|
|
146
|
+
if mime == 'application/octet-stream'
|
|
147
|
+
mime = Marcel::MimeType.for(extension: File.extname(value.path).delete_prefix('.')) || mime
|
|
148
|
+
end
|
|
149
|
+
data[key] = Faraday::FilePart.new(value.path, mime)
|
|
146
150
|
when ::Array, nil
|
|
147
151
|
# let Faraday handle Array and nil parameters
|
|
148
152
|
data[key] = value
|
data/lib/onfido/configuration.rb
CHANGED
|
@@ -10,6 +10,8 @@ Generator version: 7.16.0
|
|
|
10
10
|
=end
|
|
11
11
|
|
|
12
12
|
require 'faraday/follow_redirects'
|
|
13
|
+
require 'uri'
|
|
14
|
+
require 'json'
|
|
13
15
|
|
|
14
16
|
module Onfido
|
|
15
17
|
class Configuration
|
|
@@ -74,6 +76,14 @@ module Onfido
|
|
|
74
76
|
# @return [Proc]
|
|
75
77
|
attr_accessor :access_token_getter
|
|
76
78
|
|
|
79
|
+
# Defines the OAuth2 client ID for client credentials flow.
|
|
80
|
+
# @return [String]
|
|
81
|
+
attr_accessor :oauth_client_id
|
|
82
|
+
|
|
83
|
+
# Defines the OAuth2 client secret for client credentials flow.
|
|
84
|
+
# @return [String]
|
|
85
|
+
attr_accessor :oauth_client_secret
|
|
86
|
+
|
|
77
87
|
# Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
|
|
78
88
|
# HTTP responses with return type `File` will be returned as a stream of binary data.
|
|
79
89
|
# Default to false.
|
|
@@ -188,6 +198,7 @@ module Onfido
|
|
|
188
198
|
@ignore_operation_servers = false
|
|
189
199
|
@inject_format = false
|
|
190
200
|
@force_ending_format = false
|
|
201
|
+
@oauth_mutex = Mutex.new
|
|
191
202
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
|
192
203
|
|
|
193
204
|
use( Faraday::FollowRedirects::Middleware )
|
|
@@ -232,6 +243,7 @@ module Onfido
|
|
|
232
243
|
end
|
|
233
244
|
|
|
234
245
|
def api_token=(api_token)
|
|
246
|
+
raise ArgumentError, 'Cannot set API token when OAuth credentials are already configured' if @oauth_client_id
|
|
235
247
|
@api_key = {'Token' => "Token token=#{api_token}"}
|
|
236
248
|
end
|
|
237
249
|
|
|
@@ -248,6 +260,64 @@ module Onfido
|
|
|
248
260
|
@timeout = timeout
|
|
249
261
|
end
|
|
250
262
|
|
|
263
|
+
# Sets OAuth2 client credentials for authentication.
|
|
264
|
+
# The client will automatically exchange credentials for an access token
|
|
265
|
+
# and refresh it when expired. This is mutually exclusive with api_token.
|
|
266
|
+
#
|
|
267
|
+
# @param client_id [String] OAuth2 client ID
|
|
268
|
+
# @param client_secret [String] OAuth2 client secret
|
|
269
|
+
def set_oauth_credentials(client_id, client_secret)
|
|
270
|
+
raise ArgumentError, 'OAuth client ID must not be nil or empty' if client_id.nil? || client_id.empty?
|
|
271
|
+
raise ArgumentError, 'OAuth client secret must not be nil or empty' if client_secret.nil? || client_secret.empty?
|
|
272
|
+
raise ArgumentError, 'Cannot set OAuth credentials when API token is already configured' if @api_key&.key?('Token')
|
|
273
|
+
|
|
274
|
+
@oauth_client_id = client_id
|
|
275
|
+
@oauth_client_secret = client_secret
|
|
276
|
+
@oauth_access_token = nil
|
|
277
|
+
@oauth_token_expires_at = nil
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
private
|
|
281
|
+
|
|
282
|
+
def fetch_oauth_access_token
|
|
283
|
+
@oauth_mutex.synchronize do
|
|
284
|
+
return @oauth_access_token if @oauth_access_token && @oauth_token_expires_at && Time.now.to_f < @oauth_token_expires_at
|
|
285
|
+
|
|
286
|
+
conn = Faraday.new(
|
|
287
|
+
url: base_url,
|
|
288
|
+
ssl: { ca_file: ssl_ca_file, verify: ssl_verify, verify_mode: ssl_verify_mode,
|
|
289
|
+
client_cert: ssl_client_cert, client_key: ssl_client_key },
|
|
290
|
+
proxy: proxy
|
|
291
|
+
) do |f|
|
|
292
|
+
configure_middleware(f)
|
|
293
|
+
f.adapter(Faraday.default_adapter)
|
|
294
|
+
configure_connection(f)
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
response = conn.post('oauth/token') do |req|
|
|
298
|
+
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
|
299
|
+
req.options.timeout = timeout
|
|
300
|
+
req.body = URI.encode_www_form(
|
|
301
|
+
'client_id' => @oauth_client_id,
|
|
302
|
+
'client_secret' => @oauth_client_secret
|
|
303
|
+
)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
unless response.success?
|
|
307
|
+
raise "OAuth token exchange failed with status #{response.status}: #{response.body}"
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
data = JSON.parse(response.body)
|
|
311
|
+
@oauth_access_token = data['access_token']
|
|
312
|
+
expires_in = data['expires_in'].to_i
|
|
313
|
+
@oauth_token_expires_at = Time.now.to_f + (expires_in - 30)
|
|
314
|
+
|
|
315
|
+
@oauth_access_token
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
public
|
|
320
|
+
|
|
251
321
|
# Gets API key (with prefix if set).
|
|
252
322
|
# @param [String] param_name the parameter name of API key auth
|
|
253
323
|
def api_key_with_prefix(param_name, param_alias = nil)
|
|
@@ -273,6 +343,17 @@ module Onfido
|
|
|
273
343
|
|
|
274
344
|
# Returns Auth Settings hash for api client.
|
|
275
345
|
def auth_settings
|
|
346
|
+
if @oauth_client_id && !@oauth_client_id.empty?
|
|
347
|
+
return {
|
|
348
|
+
'Token' =>
|
|
349
|
+
{
|
|
350
|
+
type: 'bearer',
|
|
351
|
+
in: 'header',
|
|
352
|
+
key: 'Authorization',
|
|
353
|
+
value: "Bearer #{fetch_oauth_access_token}"
|
|
354
|
+
},
|
|
355
|
+
}
|
|
356
|
+
end
|
|
276
357
|
{
|
|
277
358
|
'Token' =>
|
|
278
359
|
{
|
|
@@ -281,6 +362,13 @@ module Onfido
|
|
|
281
362
|
key: 'Authorization',
|
|
282
363
|
value: api_key_with_prefix('Token')
|
|
283
364
|
},
|
|
365
|
+
'OAuth2ClientCredentials' =>
|
|
366
|
+
{
|
|
367
|
+
type: 'oauth2',
|
|
368
|
+
in: 'header',
|
|
369
|
+
key: 'Authorization',
|
|
370
|
+
value: "Bearer #{access_token_with_refresh}"
|
|
371
|
+
},
|
|
284
372
|
}
|
|
285
373
|
end
|
|
286
374
|
|
|
@@ -0,0 +1,265 @@
|
|
|
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
|
+
# Biometric token.
|
|
18
|
+
class BiometricToken
|
|
19
|
+
# The biometric token's unique identifier.
|
|
20
|
+
attr_accessor :uuid
|
|
21
|
+
|
|
22
|
+
attr_accessor :data
|
|
23
|
+
|
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
25
|
+
def self.attribute_map
|
|
26
|
+
{
|
|
27
|
+
:'uuid' => :'uuid',
|
|
28
|
+
:'data' => :'data'
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Returns attribute mapping this model knows about
|
|
33
|
+
def self.acceptable_attribute_map
|
|
34
|
+
attribute_map
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Returns all the JSON keys this model knows about
|
|
38
|
+
def self.acceptable_attributes
|
|
39
|
+
acceptable_attribute_map.values
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Attribute type mapping.
|
|
43
|
+
def self.openapi_types
|
|
44
|
+
{
|
|
45
|
+
:'uuid' => :'String',
|
|
46
|
+
:'data' => :'BiometricTokenData'
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# List of attributes with nullable: true
|
|
51
|
+
def self.openapi_nullable
|
|
52
|
+
Set.new([
|
|
53
|
+
])
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Initializes the object
|
|
57
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
58
|
+
def initialize(attributes = {})
|
|
59
|
+
if (!attributes.is_a?(Hash))
|
|
60
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::BiometricToken` initialize method"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
64
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
65
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
66
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
67
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::BiometricToken`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
68
|
+
end
|
|
69
|
+
h[k.to_sym] = v
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if attributes.key?(:'uuid')
|
|
73
|
+
self.uuid = attributes[:'uuid']
|
|
74
|
+
else
|
|
75
|
+
self.uuid = nil
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
if attributes.key?(:'data')
|
|
79
|
+
self.data = attributes[:'data']
|
|
80
|
+
else
|
|
81
|
+
self.data = nil
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
86
|
+
# @return Array for valid properties with the reasons
|
|
87
|
+
def list_invalid_properties
|
|
88
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
89
|
+
invalid_properties = Array.new
|
|
90
|
+
if @uuid.nil?
|
|
91
|
+
invalid_properties.push('invalid value for "uuid", uuid cannot be nil.')
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
if @data.nil?
|
|
95
|
+
invalid_properties.push('invalid value for "data", data cannot be nil.')
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
invalid_properties
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Check to see if the all the properties in the model are valid
|
|
102
|
+
# @return true if the model is valid
|
|
103
|
+
def valid?
|
|
104
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
105
|
+
return false if @uuid.nil?
|
|
106
|
+
return false if @data.nil?
|
|
107
|
+
true
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Custom attribute writer method with validation
|
|
111
|
+
# @param [Object] uuid Value to be assigned
|
|
112
|
+
def uuid=(uuid)
|
|
113
|
+
if uuid.nil?
|
|
114
|
+
fail ArgumentError, 'uuid cannot be nil'
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
@uuid = uuid
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Custom attribute writer method with validation
|
|
121
|
+
# @param [Object] data Value to be assigned
|
|
122
|
+
def data=(data)
|
|
123
|
+
if data.nil?
|
|
124
|
+
fail ArgumentError, 'data cannot be nil'
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
@data = data
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Checks equality by comparing each attribute.
|
|
131
|
+
# @param [Object] Object to be compared
|
|
132
|
+
def ==(o)
|
|
133
|
+
return true if self.equal?(o)
|
|
134
|
+
self.class == o.class &&
|
|
135
|
+
uuid == o.uuid &&
|
|
136
|
+
data == o.data
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# @see the `==` method
|
|
140
|
+
# @param [Object] Object to be compared
|
|
141
|
+
def eql?(o)
|
|
142
|
+
self == o
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Calculates hash code according to all attributes.
|
|
146
|
+
# @return [Integer] Hash code
|
|
147
|
+
def hash
|
|
148
|
+
[uuid, data].hash
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Builds the object from hash
|
|
152
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
153
|
+
# @return [Object] Returns the model itself
|
|
154
|
+
def self.build_from_hash(attributes)
|
|
155
|
+
return nil unless attributes.is_a?(Hash)
|
|
156
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
157
|
+
transformed_hash = {}
|
|
158
|
+
openapi_types.each_pair do |key, type|
|
|
159
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
160
|
+
transformed_hash["#{key}"] = nil
|
|
161
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
162
|
+
# check to ensure the input is an array given that the attribute
|
|
163
|
+
# is documented as an array but the input is not
|
|
164
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
165
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
166
|
+
end
|
|
167
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
168
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
new(transformed_hash)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Deserializes the data based on type
|
|
175
|
+
# @param string type Data type
|
|
176
|
+
# @param string value Value to be deserialized
|
|
177
|
+
# @return [Object] Deserialized data
|
|
178
|
+
def self._deserialize(type, value)
|
|
179
|
+
case type.to_sym
|
|
180
|
+
when :Time
|
|
181
|
+
Time.parse(value)
|
|
182
|
+
when :Date
|
|
183
|
+
Date.parse(value)
|
|
184
|
+
when :String
|
|
185
|
+
value.to_s
|
|
186
|
+
when :Integer
|
|
187
|
+
value.to_i
|
|
188
|
+
when :Float
|
|
189
|
+
value.to_f
|
|
190
|
+
when :Boolean
|
|
191
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
192
|
+
true
|
|
193
|
+
else
|
|
194
|
+
false
|
|
195
|
+
end
|
|
196
|
+
when :Object
|
|
197
|
+
# generic object (usually a Hash), return directly
|
|
198
|
+
value
|
|
199
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
200
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
201
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
202
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
203
|
+
k_type = Regexp.last_match[:k_type]
|
|
204
|
+
v_type = Regexp.last_match[:v_type]
|
|
205
|
+
{}.tap do |hash|
|
|
206
|
+
value.each do |k, v|
|
|
207
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
else # model
|
|
211
|
+
# models (e.g. Pet) or oneOf
|
|
212
|
+
klass = Onfido.const_get(type)
|
|
213
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Returns the string representation of the object
|
|
218
|
+
# @return [String] String presentation of the object
|
|
219
|
+
def to_s
|
|
220
|
+
to_hash.to_s
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
224
|
+
# @return [Hash] Returns the object in the form of hash
|
|
225
|
+
def to_body
|
|
226
|
+
to_hash
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# Returns the object in the form of hash
|
|
230
|
+
# @return [Hash] Returns the object in the form of hash
|
|
231
|
+
def to_hash
|
|
232
|
+
hash = {}
|
|
233
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
234
|
+
value = self.send(attr)
|
|
235
|
+
if value.nil?
|
|
236
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
237
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
hash[param] = _to_hash(value)
|
|
241
|
+
end
|
|
242
|
+
hash
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
# Outputs non-array value in the form of hash
|
|
246
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
247
|
+
# @param [Object] value Any valid value
|
|
248
|
+
# @return [Hash] Returns the value in the form of hash
|
|
249
|
+
def _to_hash(value)
|
|
250
|
+
if value.is_a?(Array)
|
|
251
|
+
value.compact.map { |v| _to_hash(v) }
|
|
252
|
+
elsif value.is_a?(Hash)
|
|
253
|
+
{}.tap do |hash|
|
|
254
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
255
|
+
end
|
|
256
|
+
elsif value.respond_to? :to_hash
|
|
257
|
+
value.to_hash
|
|
258
|
+
else
|
|
259
|
+
value
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
end
|