ultracart_api 4.1.106 → 4.1.109

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.
@@ -0,0 +1,418 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class BulkJob
18
+ # When the job reached a terminal status
19
+ attr_accessor :completed_at
20
+
21
+ # Records short-circuited as duplicates
22
+ attr_accessor :duplicate_count
23
+
24
+ # Job-level failure code when status is failed
25
+ attr_accessor :error_code
26
+
27
+ # Records that failed
28
+ attr_accessor :fail_count
29
+
30
+ # Public-facing job id (uc-bulk-<ulid>)
31
+ attr_accessor :job_id
32
+
33
+ # Object type this job processes
34
+ attr_accessor :object
35
+
36
+ # Mutation mode this job runs (the bulk surface is write-only)
37
+ attr_accessor :operation
38
+
39
+ # Records processed so far
40
+ attr_accessor :processed_records
41
+
42
+ # Position behind the merchant's active job (queued jobs only)
43
+ attr_accessor :queue_position
44
+
45
+ # Presigned S3 URL to the full per-record results NDJSON (set when finished)
46
+ attr_accessor :results_summary_url
47
+
48
+ # When the worker started the job
49
+ attr_accessor :started_at
50
+
51
+ # Job status
52
+ attr_accessor :status
53
+
54
+ # When the job was submitted
55
+ attr_accessor :submitted_at
56
+
57
+ # Records that landed
58
+ attr_accessor :success_count
59
+
60
+ # Total records counted on the first pass (null until counted)
61
+ attr_accessor :total_records
62
+
63
+ class EnumAttributeValidator
64
+ attr_reader :datatype
65
+ attr_reader :allowable_values
66
+
67
+ def initialize(datatype, allowable_values)
68
+ @allowable_values = allowable_values.map do |value|
69
+ case datatype.to_s
70
+ when /Integer/i
71
+ value.to_i
72
+ when /Float/i
73
+ value.to_f
74
+ else
75
+ value
76
+ end
77
+ end
78
+ end
79
+
80
+ def valid?(value)
81
+ !value || allowable_values.include?(value)
82
+ end
83
+ end
84
+
85
+ # Attribute mapping from ruby-style variable name to JSON key.
86
+ def self.attribute_map
87
+ {
88
+ :'completed_at' => :'completed_at',
89
+ :'duplicate_count' => :'duplicate_count',
90
+ :'error_code' => :'error_code',
91
+ :'fail_count' => :'fail_count',
92
+ :'job_id' => :'job_id',
93
+ :'object' => :'object',
94
+ :'operation' => :'operation',
95
+ :'processed_records' => :'processed_records',
96
+ :'queue_position' => :'queue_position',
97
+ :'results_summary_url' => :'results_summary_url',
98
+ :'started_at' => :'started_at',
99
+ :'status' => :'status',
100
+ :'submitted_at' => :'submitted_at',
101
+ :'success_count' => :'success_count',
102
+ :'total_records' => :'total_records'
103
+ }
104
+ end
105
+
106
+ # Returns all the JSON keys this model knows about
107
+ def self.acceptable_attributes
108
+ attribute_map.values
109
+ end
110
+
111
+ # Attribute type mapping.
112
+ def self.openapi_types
113
+ {
114
+ :'completed_at' => :'String',
115
+ :'duplicate_count' => :'Integer',
116
+ :'error_code' => :'String',
117
+ :'fail_count' => :'Integer',
118
+ :'job_id' => :'String',
119
+ :'object' => :'String',
120
+ :'operation' => :'String',
121
+ :'processed_records' => :'Integer',
122
+ :'queue_position' => :'Integer',
123
+ :'results_summary_url' => :'String',
124
+ :'started_at' => :'String',
125
+ :'status' => :'String',
126
+ :'submitted_at' => :'String',
127
+ :'success_count' => :'Integer',
128
+ :'total_records' => :'Integer'
129
+ }
130
+ end
131
+
132
+ # List of attributes with nullable: true
133
+ def self.openapi_nullable
134
+ Set.new([
135
+ ])
136
+ end
137
+
138
+ # Initializes the object
139
+ # @param [Hash] attributes Model attributes in the form of hash
140
+ def initialize(attributes = {})
141
+ if (!attributes.is_a?(Hash))
142
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::BulkJob` initialize method"
143
+ end
144
+
145
+ # check to see if the attribute exists and convert string to symbol for hash key
146
+ attributes = attributes.each_with_object({}) { |(k, v), h|
147
+ if (!self.class.attribute_map.key?(k.to_sym))
148
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::BulkJob`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
149
+ end
150
+ h[k.to_sym] = v
151
+ }
152
+
153
+ if attributes.key?(:'completed_at')
154
+ self.completed_at = attributes[:'completed_at']
155
+ end
156
+
157
+ if attributes.key?(:'duplicate_count')
158
+ self.duplicate_count = attributes[:'duplicate_count']
159
+ end
160
+
161
+ if attributes.key?(:'error_code')
162
+ self.error_code = attributes[:'error_code']
163
+ end
164
+
165
+ if attributes.key?(:'fail_count')
166
+ self.fail_count = attributes[:'fail_count']
167
+ end
168
+
169
+ if attributes.key?(:'job_id')
170
+ self.job_id = attributes[:'job_id']
171
+ end
172
+
173
+ if attributes.key?(:'object')
174
+ self.object = attributes[:'object']
175
+ end
176
+
177
+ if attributes.key?(:'operation')
178
+ self.operation = attributes[:'operation']
179
+ end
180
+
181
+ if attributes.key?(:'processed_records')
182
+ self.processed_records = attributes[:'processed_records']
183
+ end
184
+
185
+ if attributes.key?(:'queue_position')
186
+ self.queue_position = attributes[:'queue_position']
187
+ end
188
+
189
+ if attributes.key?(:'results_summary_url')
190
+ self.results_summary_url = attributes[:'results_summary_url']
191
+ end
192
+
193
+ if attributes.key?(:'started_at')
194
+ self.started_at = attributes[:'started_at']
195
+ end
196
+
197
+ if attributes.key?(:'status')
198
+ self.status = attributes[:'status']
199
+ end
200
+
201
+ if attributes.key?(:'submitted_at')
202
+ self.submitted_at = attributes[:'submitted_at']
203
+ end
204
+
205
+ if attributes.key?(:'success_count')
206
+ self.success_count = attributes[:'success_count']
207
+ end
208
+
209
+ if attributes.key?(:'total_records')
210
+ self.total_records = attributes[:'total_records']
211
+ end
212
+ end
213
+
214
+ # Show invalid properties with the reasons. Usually used together with valid?
215
+ # @return Array for valid properties with the reasons
216
+ def list_invalid_properties
217
+ invalid_properties = Array.new
218
+ invalid_properties
219
+ end
220
+
221
+ # Check to see if the all the properties in the model are valid
222
+ # @return true if the model is valid
223
+ def valid?
224
+ object_validator = EnumAttributeValidator.new('String', ["order", "customer"])
225
+ return false unless object_validator.valid?(@object)
226
+ operation_validator = EnumAttributeValidator.new('String', ["insert", "upsert"])
227
+ return false unless operation_validator.valid?(@operation)
228
+ status_validator = EnumAttributeValidator.new('String', ["queued", "in_progress", "succeeded", "partial_success", "failed", "cancelled"])
229
+ return false unless status_validator.valid?(@status)
230
+ true
231
+ end
232
+
233
+ # Custom attribute writer method checking allowed values (enum).
234
+ # @param [Object] object Object to be assigned
235
+ def object=(object)
236
+ validator = EnumAttributeValidator.new('String', ["order", "customer"])
237
+ unless validator.valid?(object)
238
+ fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}."
239
+ end
240
+ @object = object
241
+ end
242
+
243
+ # Custom attribute writer method checking allowed values (enum).
244
+ # @param [Object] operation Object to be assigned
245
+ def operation=(operation)
246
+ validator = EnumAttributeValidator.new('String', ["insert", "upsert"])
247
+ unless validator.valid?(operation)
248
+ fail ArgumentError, "invalid value for \"operation\", must be one of #{validator.allowable_values}."
249
+ end
250
+ @operation = operation
251
+ end
252
+
253
+ # Custom attribute writer method checking allowed values (enum).
254
+ # @param [Object] status Object to be assigned
255
+ def status=(status)
256
+ validator = EnumAttributeValidator.new('String', ["queued", "in_progress", "succeeded", "partial_success", "failed", "cancelled"])
257
+ unless validator.valid?(status)
258
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
259
+ end
260
+ @status = status
261
+ end
262
+
263
+ # Checks equality by comparing each attribute.
264
+ # @param [Object] Object to be compared
265
+ def ==(o)
266
+ return true if self.equal?(o)
267
+ self.class == o.class &&
268
+ completed_at == o.completed_at &&
269
+ duplicate_count == o.duplicate_count &&
270
+ error_code == o.error_code &&
271
+ fail_count == o.fail_count &&
272
+ job_id == o.job_id &&
273
+ object == o.object &&
274
+ operation == o.operation &&
275
+ processed_records == o.processed_records &&
276
+ queue_position == o.queue_position &&
277
+ results_summary_url == o.results_summary_url &&
278
+ started_at == o.started_at &&
279
+ status == o.status &&
280
+ submitted_at == o.submitted_at &&
281
+ success_count == o.success_count &&
282
+ total_records == o.total_records
283
+ end
284
+
285
+ # @see the `==` method
286
+ # @param [Object] Object to be compared
287
+ def eql?(o)
288
+ self == o
289
+ end
290
+
291
+ # Calculates hash code according to all attributes.
292
+ # @return [Integer] Hash code
293
+ def hash
294
+ [completed_at, duplicate_count, error_code, fail_count, job_id, object, operation, processed_records, queue_position, results_summary_url, started_at, status, submitted_at, success_count, total_records].hash
295
+ end
296
+
297
+ # Builds the object from hash
298
+ # @param [Hash] attributes Model attributes in the form of hash
299
+ # @return [Object] Returns the model itself
300
+ def self.build_from_hash(attributes)
301
+ new.build_from_hash(attributes)
302
+ end
303
+
304
+ # Builds the object from hash
305
+ # @param [Hash] attributes Model attributes in the form of hash
306
+ # @return [Object] Returns the model itself
307
+ def build_from_hash(attributes)
308
+ return nil unless attributes.is_a?(Hash)
309
+ attributes = attributes.transform_keys(&:to_sym)
310
+ self.class.openapi_types.each_pair do |key, type|
311
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
312
+ self.send("#{key}=", nil)
313
+ elsif type =~ /\AArray<(.*)>/i
314
+ # check to ensure the input is an array given that the attribute
315
+ # is documented as an array but the input is not
316
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
317
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
318
+ end
319
+ elsif !attributes[self.class.attribute_map[key]].nil?
320
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
321
+ end
322
+ end
323
+
324
+ self
325
+ end
326
+
327
+ # Deserializes the data based on type
328
+ # @param string type Data type
329
+ # @param string value Value to be deserialized
330
+ # @return [Object] Deserialized data
331
+ def _deserialize(type, value)
332
+ case type.to_sym
333
+ when :Time
334
+ Time.parse(value)
335
+ when :Date
336
+ Date.parse(value)
337
+ when :String
338
+ value.to_s
339
+ when :Integer
340
+ value.to_i
341
+ when :Float
342
+ value.to_f
343
+ when :Boolean
344
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
345
+ true
346
+ else
347
+ false
348
+ end
349
+ when :Object
350
+ # generic object (usually a Hash), return directly
351
+ value
352
+ when /\AArray<(?<inner_type>.+)>\z/
353
+ inner_type = Regexp.last_match[:inner_type]
354
+ value.map { |v| _deserialize(inner_type, v) }
355
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
356
+ k_type = Regexp.last_match[:k_type]
357
+ v_type = Regexp.last_match[:v_type]
358
+ {}.tap do |hash|
359
+ value.each do |k, v|
360
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
361
+ end
362
+ end
363
+ else # model
364
+ # models (e.g. Pet) or oneOf
365
+ klass = UltracartClient.const_get(type)
366
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
367
+ end
368
+ end
369
+
370
+ # Returns the string representation of the object
371
+ # @return [String] String presentation of the object
372
+ def to_s
373
+ to_hash.to_s
374
+ end
375
+
376
+ # to_body is an alias to to_hash (backward compatibility)
377
+ # @return [Hash] Returns the object in the form of hash
378
+ def to_body
379
+ to_hash
380
+ end
381
+
382
+ # Returns the object in the form of hash
383
+ # @return [Hash] Returns the object in the form of hash
384
+ def to_hash
385
+ hash = {}
386
+ self.class.attribute_map.each_pair do |attr, param|
387
+ value = self.send(attr)
388
+ if value.nil?
389
+ is_nullable = self.class.openapi_nullable.include?(attr)
390
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
391
+ end
392
+
393
+ hash[param] = _to_hash(value)
394
+ end
395
+ hash
396
+ end
397
+
398
+ # Outputs non-array value in the form of hash
399
+ # For object, use to_hash. Otherwise, just return the value
400
+ # @param [Object] value Any valid value
401
+ # @return [Hash] Returns the value in the form of hash
402
+ def _to_hash(value)
403
+ if value.is_a?(Array)
404
+ value.compact.map { |v| _to_hash(v) }
405
+ elsif value.is_a?(Hash)
406
+ {}.tap do |hash|
407
+ value.each { |k, v| hash[k] = _to_hash(v) }
408
+ end
409
+ elsif value.respond_to? :to_hash
410
+ value.to_hash
411
+ else
412
+ value
413
+ end
414
+ end
415
+
416
+ end
417
+
418
+ end
@@ -0,0 +1,284 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class BulkJobRequest
18
+ # Mutation mode - insert (create only) or upsert (create or update). Defaults to insert. This is always a mutation verb — the bulk surface writes only and has no read / query mode. upsert is currently supported for customer only.
19
+ attr_accessor :operation
20
+
21
+ # The s3_key returned by the upload-url endpoint
22
+ attr_accessor :s3_key
23
+
24
+ # Optional shared secret echoed in the completion POST's Authorization header
25
+ attr_accessor :webhook_secret
26
+
27
+ # Optional URL to POST once, on completion
28
+ attr_accessor :webhook_url
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype
32
+ attr_reader :allowable_values
33
+
34
+ def initialize(datatype, allowable_values)
35
+ @allowable_values = allowable_values.map do |value|
36
+ case datatype.to_s
37
+ when /Integer/i
38
+ value.to_i
39
+ when /Float/i
40
+ value.to_f
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def valid?(value)
48
+ !value || allowable_values.include?(value)
49
+ end
50
+ end
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'operation' => :'operation',
56
+ :'s3_key' => :'s3_key',
57
+ :'webhook_secret' => :'webhook_secret',
58
+ :'webhook_url' => :'webhook_url'
59
+ }
60
+ end
61
+
62
+ # Returns all the JSON keys this model knows about
63
+ def self.acceptable_attributes
64
+ attribute_map.values
65
+ end
66
+
67
+ # Attribute type mapping.
68
+ def self.openapi_types
69
+ {
70
+ :'operation' => :'String',
71
+ :'s3_key' => :'String',
72
+ :'webhook_secret' => :'String',
73
+ :'webhook_url' => :'String'
74
+ }
75
+ end
76
+
77
+ # List of attributes with nullable: true
78
+ def self.openapi_nullable
79
+ Set.new([
80
+ ])
81
+ end
82
+
83
+ # Initializes the object
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ def initialize(attributes = {})
86
+ if (!attributes.is_a?(Hash))
87
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::BulkJobRequest` initialize method"
88
+ end
89
+
90
+ # check to see if the attribute exists and convert string to symbol for hash key
91
+ attributes = attributes.each_with_object({}) { |(k, v), h|
92
+ if (!self.class.attribute_map.key?(k.to_sym))
93
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::BulkJobRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
94
+ end
95
+ h[k.to_sym] = v
96
+ }
97
+
98
+ if attributes.key?(:'operation')
99
+ self.operation = attributes[:'operation']
100
+ end
101
+
102
+ if attributes.key?(:'s3_key')
103
+ self.s3_key = attributes[:'s3_key']
104
+ end
105
+
106
+ if attributes.key?(:'webhook_secret')
107
+ self.webhook_secret = attributes[:'webhook_secret']
108
+ end
109
+
110
+ if attributes.key?(:'webhook_url')
111
+ self.webhook_url = attributes[:'webhook_url']
112
+ end
113
+ end
114
+
115
+ # Show invalid properties with the reasons. Usually used together with valid?
116
+ # @return Array for valid properties with the reasons
117
+ def list_invalid_properties
118
+ invalid_properties = Array.new
119
+ invalid_properties
120
+ end
121
+
122
+ # Check to see if the all the properties in the model are valid
123
+ # @return true if the model is valid
124
+ def valid?
125
+ operation_validator = EnumAttributeValidator.new('String', ["insert", "upsert"])
126
+ return false unless operation_validator.valid?(@operation)
127
+ true
128
+ end
129
+
130
+ # Custom attribute writer method checking allowed values (enum).
131
+ # @param [Object] operation Object to be assigned
132
+ def operation=(operation)
133
+ validator = EnumAttributeValidator.new('String', ["insert", "upsert"])
134
+ unless validator.valid?(operation)
135
+ fail ArgumentError, "invalid value for \"operation\", must be one of #{validator.allowable_values}."
136
+ end
137
+ @operation = operation
138
+ end
139
+
140
+ # Checks equality by comparing each attribute.
141
+ # @param [Object] Object to be compared
142
+ def ==(o)
143
+ return true if self.equal?(o)
144
+ self.class == o.class &&
145
+ operation == o.operation &&
146
+ s3_key == o.s3_key &&
147
+ webhook_secret == o.webhook_secret &&
148
+ webhook_url == o.webhook_url
149
+ end
150
+
151
+ # @see the `==` method
152
+ # @param [Object] Object to be compared
153
+ def eql?(o)
154
+ self == o
155
+ end
156
+
157
+ # Calculates hash code according to all attributes.
158
+ # @return [Integer] Hash code
159
+ def hash
160
+ [operation, s3_key, webhook_secret, webhook_url].hash
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def self.build_from_hash(attributes)
167
+ new.build_from_hash(attributes)
168
+ end
169
+
170
+ # Builds the object from hash
171
+ # @param [Hash] attributes Model attributes in the form of hash
172
+ # @return [Object] Returns the model itself
173
+ def build_from_hash(attributes)
174
+ return nil unless attributes.is_a?(Hash)
175
+ attributes = attributes.transform_keys(&:to_sym)
176
+ self.class.openapi_types.each_pair do |key, type|
177
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
178
+ self.send("#{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[self.class.attribute_map[key]].is_a?(Array)
183
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
184
+ end
185
+ elsif !attributes[self.class.attribute_map[key]].nil?
186
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
187
+ end
188
+ end
189
+
190
+ self
191
+ end
192
+
193
+ # Deserializes the data based on type
194
+ # @param string type Data type
195
+ # @param string value Value to be deserialized
196
+ # @return [Object] Deserialized data
197
+ def _deserialize(type, value)
198
+ case type.to_sym
199
+ when :Time
200
+ Time.parse(value)
201
+ when :Date
202
+ Date.parse(value)
203
+ when :String
204
+ value.to_s
205
+ when :Integer
206
+ value.to_i
207
+ when :Float
208
+ value.to_f
209
+ when :Boolean
210
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
211
+ true
212
+ else
213
+ false
214
+ end
215
+ when :Object
216
+ # generic object (usually a Hash), return directly
217
+ value
218
+ when /\AArray<(?<inner_type>.+)>\z/
219
+ inner_type = Regexp.last_match[:inner_type]
220
+ value.map { |v| _deserialize(inner_type, v) }
221
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
222
+ k_type = Regexp.last_match[:k_type]
223
+ v_type = Regexp.last_match[:v_type]
224
+ {}.tap do |hash|
225
+ value.each do |k, v|
226
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
227
+ end
228
+ end
229
+ else # model
230
+ # models (e.g. Pet) or oneOf
231
+ klass = UltracartClient.const_get(type)
232
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
233
+ end
234
+ end
235
+
236
+ # Returns the string representation of the object
237
+ # @return [String] String presentation of the object
238
+ def to_s
239
+ to_hash.to_s
240
+ end
241
+
242
+ # to_body is an alias to to_hash (backward compatibility)
243
+ # @return [Hash] Returns the object in the form of hash
244
+ def to_body
245
+ to_hash
246
+ end
247
+
248
+ # Returns the object in the form of hash
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_hash
251
+ hash = {}
252
+ self.class.attribute_map.each_pair do |attr, param|
253
+ value = self.send(attr)
254
+ if value.nil?
255
+ is_nullable = self.class.openapi_nullable.include?(attr)
256
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
257
+ end
258
+
259
+ hash[param] = _to_hash(value)
260
+ end
261
+ hash
262
+ end
263
+
264
+ # Outputs non-array value in the form of hash
265
+ # For object, use to_hash. Otherwise, just return the value
266
+ # @param [Object] value Any valid value
267
+ # @return [Hash] Returns the value in the form of hash
268
+ def _to_hash(value)
269
+ if value.is_a?(Array)
270
+ value.compact.map { |v| _to_hash(v) }
271
+ elsif value.is_a?(Hash)
272
+ {}.tap do |hash|
273
+ value.each { |k, v| hash[k] = _to_hash(v) }
274
+ end
275
+ elsif value.respond_to? :to_hash
276
+ value.to_hash
277
+ else
278
+ value
279
+ end
280
+ end
281
+
282
+ end
283
+
284
+ end