sendpost_ruby_sdk 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +79 -0
  4. data/Rakefile +10 -0
  5. data/config-ruby.json +11 -0
  6. data/docs/Attachment.md +20 -0
  7. data/docs/City.md +26 -0
  8. data/docs/CopyTo.md +22 -0
  9. data/docs/Device.md +18 -0
  10. data/docs/EmailApi.md +145 -0
  11. data/docs/EmailMessage.md +46 -0
  12. data/docs/EmailResponse.md +26 -0
  13. data/docs/EventMetadata.md +30 -0
  14. data/docs/From.md +20 -0
  15. data/docs/Os.md +26 -0
  16. data/docs/QEmailMessage.md +70 -0
  17. data/docs/QEvent.md +42 -0
  18. data/docs/ReplyTo.md +20 -0
  19. data/docs/To.md +26 -0
  20. data/docs/UserAgent.md +24 -0
  21. data/docs/WebhookEvent.md +20 -0
  22. data/generate-libs.bash +1 -0
  23. data/git_push.sh +57 -0
  24. data/lib/sendpost_ruby_sdk/api/email_api.rb +160 -0
  25. data/lib/sendpost_ruby_sdk/api_client.rb +391 -0
  26. data/lib/sendpost_ruby_sdk/api_error.rb +58 -0
  27. data/lib/sendpost_ruby_sdk/configuration.rb +288 -0
  28. data/lib/sendpost_ruby_sdk/models/attachment.rb +228 -0
  29. data/lib/sendpost_ruby_sdk/models/city.rb +255 -0
  30. data/lib/sendpost_ruby_sdk/models/copy_to.rb +237 -0
  31. data/lib/sendpost_ruby_sdk/models/device.rb +219 -0
  32. data/lib/sendpost_ruby_sdk/models/email_message.rb +351 -0
  33. data/lib/sendpost_ruby_sdk/models/email_response.rb +255 -0
  34. data/lib/sendpost_ruby_sdk/models/event_metadata.rb +273 -0
  35. data/lib/sendpost_ruby_sdk/models/from.rb +228 -0
  36. data/lib/sendpost_ruby_sdk/models/os.rb +255 -0
  37. data/lib/sendpost_ruby_sdk/models/q_email_message.rb +461 -0
  38. data/lib/sendpost_ruby_sdk/models/q_event.rb +329 -0
  39. data/lib/sendpost_ruby_sdk/models/reply_to.rb +228 -0
  40. data/lib/sendpost_ruby_sdk/models/to.rb +259 -0
  41. data/lib/sendpost_ruby_sdk/models/user_agent.rb +246 -0
  42. data/lib/sendpost_ruby_sdk/models/webhook_event.rb +228 -0
  43. data/lib/sendpost_ruby_sdk/version.rb +15 -0
  44. data/lib/sendpost_ruby_sdk.rb +55 -0
  45. data/sendpost.yaml +438 -0
  46. data/sendpost_ruby_sdk.gemspec +38 -0
  47. data/spec/api/email_api_spec.rb +59 -0
  48. data/spec/api_client_spec.rb +228 -0
  49. data/spec/configuration_spec.rb +42 -0
  50. data/spec/models/attachment_spec.rb +40 -0
  51. data/spec/models/city_spec.rb +58 -0
  52. data/spec/models/copy_to_spec.rb +46 -0
  53. data/spec/models/device_spec.rb +34 -0
  54. data/spec/models/email_message_spec.rb +118 -0
  55. data/spec/models/email_response_spec.rb +58 -0
  56. data/spec/models/event_metadata_spec.rb +70 -0
  57. data/spec/models/from_spec.rb +40 -0
  58. data/spec/models/os_spec.rb +58 -0
  59. data/spec/models/q_email_message_spec.rb +190 -0
  60. data/spec/models/q_event_spec.rb +106 -0
  61. data/spec/models/reply_to_spec.rb +40 -0
  62. data/spec/models/to_spec.rb +58 -0
  63. data/spec/models/user_agent_spec.rb +52 -0
  64. data/spec/models/webhook_event_spec.rb +40 -0
  65. data/spec/spec_helper.rb +111 -0
  66. metadata +168 -0
@@ -0,0 +1,351 @@
1
+ =begin
2
+ #SendPost API
3
+
4
+ #Email API and SMTP relay to not just send and measure email sending, but also alert and optimise. We provide you with tools, expertise and support needed to reliably deliver emails to your customers inboxes on time, every time.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: hello@sendpost.io
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Sendpost
17
+ class EmailMessage
18
+ attr_accessor :attachments
19
+
20
+ attr_accessor :from
21
+
22
+ attr_accessor :groups
23
+
24
+ attr_accessor :html_body
25
+
26
+ attr_accessor :ippool
27
+
28
+ attr_accessor :pre_text
29
+
30
+ attr_accessor :reply_to
31
+
32
+ attr_accessor :subject
33
+
34
+ attr_accessor :template
35
+
36
+ attr_accessor :text_body
37
+
38
+ attr_accessor :to
39
+
40
+ attr_accessor :track_clicks
41
+
42
+ attr_accessor :track_opens
43
+
44
+ attr_accessor :headers
45
+
46
+ attr_accessor :amp_body
47
+
48
+ # Attribute mapping from ruby-style variable name to JSON key.
49
+ def self.attribute_map
50
+ {
51
+ :'attachments' => :'attachments',
52
+ :'from' => :'from',
53
+ :'groups' => :'groups',
54
+ :'html_body' => :'htmlBody',
55
+ :'ippool' => :'ippool',
56
+ :'pre_text' => :'preText',
57
+ :'reply_to' => :'replyTo',
58
+ :'subject' => :'subject',
59
+ :'template' => :'template',
60
+ :'text_body' => :'textBody',
61
+ :'to' => :'to',
62
+ :'track_clicks' => :'trackClicks',
63
+ :'track_opens' => :'trackOpens',
64
+ :'headers' => :'headers',
65
+ :'amp_body' => :'ampBody'
66
+ }
67
+ end
68
+
69
+ # Returns all the JSON keys this model knows about
70
+ def self.acceptable_attributes
71
+ attribute_map.values
72
+ end
73
+
74
+ # Attribute type mapping.
75
+ def self.openapi_types
76
+ {
77
+ :'attachments' => :'Array<Attachment>',
78
+ :'from' => :'From',
79
+ :'groups' => :'Array<String>',
80
+ :'html_body' => :'String',
81
+ :'ippool' => :'String',
82
+ :'pre_text' => :'String',
83
+ :'reply_to' => :'ReplyTo',
84
+ :'subject' => :'String',
85
+ :'template' => :'String',
86
+ :'text_body' => :'String',
87
+ :'to' => :'Array<To>',
88
+ :'track_clicks' => :'Boolean',
89
+ :'track_opens' => :'Boolean',
90
+ :'headers' => :'Object',
91
+ :'amp_body' => :'String'
92
+ }
93
+ end
94
+
95
+ # List of attributes with nullable: true
96
+ def self.openapi_nullable
97
+ Set.new([
98
+ ])
99
+ end
100
+
101
+ # Initializes the object
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ def initialize(attributes = {})
104
+ if (!attributes.is_a?(Hash))
105
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendpost::EmailMessage` initialize method"
106
+ end
107
+
108
+ # check to see if the attribute exists and convert string to symbol for hash key
109
+ attributes = attributes.each_with_object({}) { |(k, v), h|
110
+ if (!self.class.attribute_map.key?(k.to_sym))
111
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendpost::EmailMessage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
112
+ end
113
+ h[k.to_sym] = v
114
+ }
115
+
116
+ if attributes.key?(:'attachments')
117
+ if (value = attributes[:'attachments']).is_a?(Array)
118
+ self.attachments = value
119
+ end
120
+ end
121
+
122
+ if attributes.key?(:'from')
123
+ self.from = attributes[:'from']
124
+ end
125
+
126
+ if attributes.key?(:'groups')
127
+ if (value = attributes[:'groups']).is_a?(Array)
128
+ self.groups = value
129
+ end
130
+ end
131
+
132
+ if attributes.key?(:'html_body')
133
+ self.html_body = attributes[:'html_body']
134
+ end
135
+
136
+ if attributes.key?(:'ippool')
137
+ self.ippool = attributes[:'ippool']
138
+ end
139
+
140
+ if attributes.key?(:'pre_text')
141
+ self.pre_text = attributes[:'pre_text']
142
+ end
143
+
144
+ if attributes.key?(:'reply_to')
145
+ self.reply_to = attributes[:'reply_to']
146
+ end
147
+
148
+ if attributes.key?(:'subject')
149
+ self.subject = attributes[:'subject']
150
+ end
151
+
152
+ if attributes.key?(:'template')
153
+ self.template = attributes[:'template']
154
+ end
155
+
156
+ if attributes.key?(:'text_body')
157
+ self.text_body = attributes[:'text_body']
158
+ end
159
+
160
+ if attributes.key?(:'to')
161
+ if (value = attributes[:'to']).is_a?(Array)
162
+ self.to = value
163
+ end
164
+ end
165
+
166
+ if attributes.key?(:'track_clicks')
167
+ self.track_clicks = attributes[:'track_clicks']
168
+ end
169
+
170
+ if attributes.key?(:'track_opens')
171
+ self.track_opens = attributes[:'track_opens']
172
+ end
173
+
174
+ if attributes.key?(:'headers')
175
+ self.headers = attributes[:'headers']
176
+ end
177
+
178
+ if attributes.key?(:'amp_body')
179
+ self.amp_body = attributes[:'amp_body']
180
+ end
181
+ end
182
+
183
+ # Show invalid properties with the reasons. Usually used together with valid?
184
+ # @return Array for valid properties with the reasons
185
+ def list_invalid_properties
186
+ invalid_properties = Array.new
187
+ invalid_properties
188
+ end
189
+
190
+ # Check to see if the all the properties in the model are valid
191
+ # @return true if the model is valid
192
+ def valid?
193
+ true
194
+ end
195
+
196
+ # Checks equality by comparing each attribute.
197
+ # @param [Object] Object to be compared
198
+ def ==(o)
199
+ return true if self.equal?(o)
200
+ self.class == o.class &&
201
+ attachments == o.attachments &&
202
+ from == o.from &&
203
+ groups == o.groups &&
204
+ html_body == o.html_body &&
205
+ ippool == o.ippool &&
206
+ pre_text == o.pre_text &&
207
+ reply_to == o.reply_to &&
208
+ subject == o.subject &&
209
+ template == o.template &&
210
+ text_body == o.text_body &&
211
+ to == o.to &&
212
+ track_clicks == o.track_clicks &&
213
+ track_opens == o.track_opens &&
214
+ headers == o.headers &&
215
+ amp_body == o.amp_body
216
+ end
217
+
218
+ # @see the `==` method
219
+ # @param [Object] Object to be compared
220
+ def eql?(o)
221
+ self == o
222
+ end
223
+
224
+ # Calculates hash code according to all attributes.
225
+ # @return [Integer] Hash code
226
+ def hash
227
+ [attachments, from, groups, html_body, ippool, pre_text, reply_to, subject, template, text_body, to, track_clicks, track_opens, headers, amp_body].hash
228
+ end
229
+
230
+ # Builds the object from hash
231
+ # @param [Hash] attributes Model attributes in the form of hash
232
+ # @return [Object] Returns the model itself
233
+ def self.build_from_hash(attributes)
234
+ new.build_from_hash(attributes)
235
+ end
236
+
237
+ # Builds the object from hash
238
+ # @param [Hash] attributes Model attributes in the form of hash
239
+ # @return [Object] Returns the model itself
240
+ def build_from_hash(attributes)
241
+ return nil unless attributes.is_a?(Hash)
242
+ attributes = attributes.transform_keys(&:to_sym)
243
+ self.class.openapi_types.each_pair do |key, type|
244
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
245
+ self.send("#{key}=", nil)
246
+ elsif type =~ /\AArray<(.*)>/i
247
+ # check to ensure the input is an array given that the attribute
248
+ # is documented as an array but the input is not
249
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
250
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
251
+ end
252
+ elsif !attributes[self.class.attribute_map[key]].nil?
253
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
254
+ end
255
+ end
256
+
257
+ self
258
+ end
259
+
260
+ # Deserializes the data based on type
261
+ # @param string type Data type
262
+ # @param string value Value to be deserialized
263
+ # @return [Object] Deserialized data
264
+ def _deserialize(type, value)
265
+ case type.to_sym
266
+ when :Time
267
+ Time.parse(value)
268
+ when :Date
269
+ Date.parse(value)
270
+ when :String
271
+ value.to_s
272
+ when :Integer
273
+ value.to_i
274
+ when :Float
275
+ value.to_f
276
+ when :Boolean
277
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
278
+ true
279
+ else
280
+ false
281
+ end
282
+ when :Object
283
+ # generic object (usually a Hash), return directly
284
+ value
285
+ when /\AArray<(?<inner_type>.+)>\z/
286
+ inner_type = Regexp.last_match[:inner_type]
287
+ value.map { |v| _deserialize(inner_type, v) }
288
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
289
+ k_type = Regexp.last_match[:k_type]
290
+ v_type = Regexp.last_match[:v_type]
291
+ {}.tap do |hash|
292
+ value.each do |k, v|
293
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
294
+ end
295
+ end
296
+ else # model
297
+ # models (e.g. Pet) or oneOf
298
+ klass = Sendpost.const_get(type)
299
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
300
+ end
301
+ end
302
+
303
+ # Returns the string representation of the object
304
+ # @return [String] String presentation of the object
305
+ def to_s
306
+ to_hash.to_s
307
+ end
308
+
309
+ # to_body is an alias to to_hash (backward compatibility)
310
+ # @return [Hash] Returns the object in the form of hash
311
+ def to_body
312
+ to_hash
313
+ end
314
+
315
+ # Returns the object in the form of hash
316
+ # @return [Hash] Returns the object in the form of hash
317
+ def to_hash
318
+ hash = {}
319
+ self.class.attribute_map.each_pair do |attr, param|
320
+ value = self.send(attr)
321
+ if value.nil?
322
+ is_nullable = self.class.openapi_nullable.include?(attr)
323
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
324
+ end
325
+
326
+ hash[param] = _to_hash(value)
327
+ end
328
+ hash
329
+ end
330
+
331
+ # Outputs non-array value in the form of hash
332
+ # For object, use to_hash. Otherwise, just return the value
333
+ # @param [Object] value Any valid value
334
+ # @return [Hash] Returns the value in the form of hash
335
+ def _to_hash(value)
336
+ if value.is_a?(Array)
337
+ value.compact.map { |v| _to_hash(v) }
338
+ elsif value.is_a?(Hash)
339
+ {}.tap do |hash|
340
+ value.each { |k, v| hash[k] = _to_hash(v) }
341
+ end
342
+ elsif value.respond_to? :to_hash
343
+ value.to_hash
344
+ else
345
+ value
346
+ end
347
+ end
348
+
349
+ end
350
+
351
+ end
@@ -0,0 +1,255 @@
1
+ =begin
2
+ #SendPost API
3
+
4
+ #Email API and SMTP relay to not just send and measure email sending, but also alert and optimise. We provide you with tools, expertise and support needed to reliably deliver emails to your customers inboxes on time, every time.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: hello@sendpost.io
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Sendpost
17
+ class EmailResponse
18
+ attr_accessor :error_code
19
+
20
+ attr_accessor :message
21
+
22
+ attr_accessor :message_id
23
+
24
+ attr_accessor :submitted_at
25
+
26
+ attr_accessor :to
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'error_code' => :'errorCode',
32
+ :'message' => :'message',
33
+ :'message_id' => :'messageId',
34
+ :'submitted_at' => :'submittedAt',
35
+ :'to' => :'to'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'error_code' => :'Integer',
48
+ :'message' => :'String',
49
+ :'message_id' => :'String',
50
+ :'submitted_at' => :'Integer',
51
+ :'to' => :'String'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendpost::EmailResponse` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendpost::EmailResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'error_code')
77
+ self.error_code = attributes[:'error_code']
78
+ end
79
+
80
+ if attributes.key?(:'message')
81
+ self.message = attributes[:'message']
82
+ end
83
+
84
+ if attributes.key?(:'message_id')
85
+ self.message_id = attributes[:'message_id']
86
+ end
87
+
88
+ if attributes.key?(:'submitted_at')
89
+ self.submitted_at = attributes[:'submitted_at']
90
+ end
91
+
92
+ if attributes.key?(:'to')
93
+ self.to = attributes[:'to']
94
+ end
95
+ end
96
+
97
+ # Show invalid properties with the reasons. Usually used together with valid?
98
+ # @return Array for valid properties with the reasons
99
+ def list_invalid_properties
100
+ invalid_properties = Array.new
101
+ invalid_properties
102
+ end
103
+
104
+ # Check to see if the all the properties in the model are valid
105
+ # @return true if the model is valid
106
+ def valid?
107
+ true
108
+ end
109
+
110
+ # Checks equality by comparing each attribute.
111
+ # @param [Object] Object to be compared
112
+ def ==(o)
113
+ return true if self.equal?(o)
114
+ self.class == o.class &&
115
+ error_code == o.error_code &&
116
+ message == o.message &&
117
+ message_id == o.message_id &&
118
+ submitted_at == o.submitted_at &&
119
+ to == o.to
120
+ end
121
+
122
+ # @see the `==` method
123
+ # @param [Object] Object to be compared
124
+ def eql?(o)
125
+ self == o
126
+ end
127
+
128
+ # Calculates hash code according to all attributes.
129
+ # @return [Integer] Hash code
130
+ def hash
131
+ [error_code, message, message_id, submitted_at, to].hash
132
+ end
133
+
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def self.build_from_hash(attributes)
138
+ new.build_from_hash(attributes)
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def build_from_hash(attributes)
145
+ return nil unless attributes.is_a?(Hash)
146
+ attributes = attributes.transform_keys(&:to_sym)
147
+ self.class.openapi_types.each_pair do |key, type|
148
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
149
+ self.send("#{key}=", nil)
150
+ elsif type =~ /\AArray<(.*)>/i
151
+ # check to ensure the input is an array given that the attribute
152
+ # is documented as an array but the input is not
153
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
154
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
155
+ end
156
+ elsif !attributes[self.class.attribute_map[key]].nil?
157
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
158
+ end
159
+ end
160
+
161
+ self
162
+ end
163
+
164
+ # Deserializes the data based on type
165
+ # @param string type Data type
166
+ # @param string value Value to be deserialized
167
+ # @return [Object] Deserialized data
168
+ def _deserialize(type, value)
169
+ case type.to_sym
170
+ when :Time
171
+ Time.parse(value)
172
+ when :Date
173
+ Date.parse(value)
174
+ when :String
175
+ value.to_s
176
+ when :Integer
177
+ value.to_i
178
+ when :Float
179
+ value.to_f
180
+ when :Boolean
181
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
182
+ true
183
+ else
184
+ false
185
+ end
186
+ when :Object
187
+ # generic object (usually a Hash), return directly
188
+ value
189
+ when /\AArray<(?<inner_type>.+)>\z/
190
+ inner_type = Regexp.last_match[:inner_type]
191
+ value.map { |v| _deserialize(inner_type, v) }
192
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
193
+ k_type = Regexp.last_match[:k_type]
194
+ v_type = Regexp.last_match[:v_type]
195
+ {}.tap do |hash|
196
+ value.each do |k, v|
197
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198
+ end
199
+ end
200
+ else # model
201
+ # models (e.g. Pet) or oneOf
202
+ klass = Sendpost.const_get(type)
203
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
204
+ end
205
+ end
206
+
207
+ # Returns the string representation of the object
208
+ # @return [String] String presentation of the object
209
+ def to_s
210
+ to_hash.to_s
211
+ end
212
+
213
+ # to_body is an alias to to_hash (backward compatibility)
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_body
216
+ to_hash
217
+ end
218
+
219
+ # Returns the object in the form of hash
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_hash
222
+ hash = {}
223
+ self.class.attribute_map.each_pair do |attr, param|
224
+ value = self.send(attr)
225
+ if value.nil?
226
+ is_nullable = self.class.openapi_nullable.include?(attr)
227
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
228
+ end
229
+
230
+ hash[param] = _to_hash(value)
231
+ end
232
+ hash
233
+ end
234
+
235
+ # Outputs non-array value in the form of hash
236
+ # For object, use to_hash. Otherwise, just return the value
237
+ # @param [Object] value Any valid value
238
+ # @return [Hash] Returns the value in the form of hash
239
+ def _to_hash(value)
240
+ if value.is_a?(Array)
241
+ value.compact.map { |v| _to_hash(v) }
242
+ elsif value.is_a?(Hash)
243
+ {}.tap do |hash|
244
+ value.each { |k, v| hash[k] = _to_hash(v) }
245
+ end
246
+ elsif value.respond_to? :to_hash
247
+ value.to_hash
248
+ else
249
+ value
250
+ end
251
+ end
252
+
253
+ end
254
+
255
+ end