mailslurp_client 8.5.2 → 8.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,304 @@
1
+ =begin
2
+ #MailSlurp API
3
+
4
+ #MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more. ## Resources - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://www.mailslurp.com/docs/) - [Examples](https://github.com/mailslurp/examples) repository
5
+
6
+ The version of the OpenAPI document: 6.5.2
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module MailSlurpClient
16
+ # Options for replying to an alias email using the alias inbox
17
+ class ReplyToAliasEmailOptions
18
+ # List of uploaded attachments to send with the reply. Optional.
19
+ attr_accessor :attachments
20
+
21
+ # Body of the reply email you want to send
22
+ attr_accessor :body
23
+
24
+ # The charset that your message should be sent with. Optional. Default is UTF-8
25
+ attr_accessor :charset
26
+
27
+ # Is the reply HTML
28
+ attr_accessor :is_html
29
+
30
+ # When to send the email. Typically immediately
31
+ attr_accessor :send_strategy
32
+
33
+ # Template ID to use instead of body. Will use template variable map to fill defined variable slots.
34
+ attr_accessor :template
35
+
36
+ # Template variables if using a template
37
+ attr_accessor :template_variables
38
+
39
+ class EnumAttributeValidator
40
+ attr_reader :datatype
41
+ attr_reader :allowable_values
42
+
43
+ def initialize(datatype, allowable_values)
44
+ @allowable_values = allowable_values.map do |value|
45
+ case datatype.to_s
46
+ when /Integer/i
47
+ value.to_i
48
+ when /Float/i
49
+ value.to_f
50
+ else
51
+ value
52
+ end
53
+ end
54
+ end
55
+
56
+ def valid?(value)
57
+ !value || allowable_values.include?(value)
58
+ end
59
+ end
60
+
61
+ # Attribute mapping from ruby-style variable name to JSON key.
62
+ def self.attribute_map
63
+ {
64
+ :'attachments' => :'attachments',
65
+ :'body' => :'body',
66
+ :'charset' => :'charset',
67
+ :'is_html' => :'isHTML',
68
+ :'send_strategy' => :'sendStrategy',
69
+ :'template' => :'template',
70
+ :'template_variables' => :'templateVariables'
71
+ }
72
+ end
73
+
74
+ # Attribute type mapping.
75
+ def self.openapi_types
76
+ {
77
+ :'attachments' => :'Array<String>',
78
+ :'body' => :'String',
79
+ :'charset' => :'String',
80
+ :'is_html' => :'Boolean',
81
+ :'send_strategy' => :'String',
82
+ :'template' => :'String',
83
+ :'template_variables' => :'Object'
84
+ }
85
+ end
86
+
87
+ # List of attributes with nullable: true
88
+ def self.openapi_nullable
89
+ Set.new([
90
+ ])
91
+ end
92
+
93
+ # Initializes the object
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ def initialize(attributes = {})
96
+ if (!attributes.is_a?(Hash))
97
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::ReplyToAliasEmailOptions` initialize method"
98
+ end
99
+
100
+ # check to see if the attribute exists and convert string to symbol for hash key
101
+ attributes = attributes.each_with_object({}) { |(k, v), h|
102
+ if (!self.class.attribute_map.key?(k.to_sym))
103
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::ReplyToAliasEmailOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
104
+ end
105
+ h[k.to_sym] = v
106
+ }
107
+
108
+ if attributes.key?(:'attachments')
109
+ if (value = attributes[:'attachments']).is_a?(Array)
110
+ self.attachments = value
111
+ end
112
+ end
113
+
114
+ if attributes.key?(:'body')
115
+ self.body = attributes[:'body']
116
+ end
117
+
118
+ if attributes.key?(:'charset')
119
+ self.charset = attributes[:'charset']
120
+ end
121
+
122
+ if attributes.key?(:'is_html')
123
+ self.is_html = attributes[:'is_html']
124
+ end
125
+
126
+ if attributes.key?(:'send_strategy')
127
+ self.send_strategy = attributes[:'send_strategy']
128
+ end
129
+
130
+ if attributes.key?(:'template')
131
+ self.template = attributes[:'template']
132
+ end
133
+
134
+ if attributes.key?(:'template_variables')
135
+ self.template_variables = attributes[:'template_variables']
136
+ end
137
+ end
138
+
139
+ # Show invalid properties with the reasons. Usually used together with valid?
140
+ # @return Array for valid properties with the reasons
141
+ def list_invalid_properties
142
+ invalid_properties = Array.new
143
+ invalid_properties
144
+ end
145
+
146
+ # Check to see if the all the properties in the model are valid
147
+ # @return true if the model is valid
148
+ def valid?
149
+ send_strategy_validator = EnumAttributeValidator.new('String', ["SINGLE_MESSAGE"])
150
+ return false unless send_strategy_validator.valid?(@send_strategy)
151
+ true
152
+ end
153
+
154
+ # Custom attribute writer method checking allowed values (enum).
155
+ # @param [Object] send_strategy Object to be assigned
156
+ def send_strategy=(send_strategy)
157
+ validator = EnumAttributeValidator.new('String', ["SINGLE_MESSAGE"])
158
+ unless validator.valid?(send_strategy)
159
+ fail ArgumentError, "invalid value for \"send_strategy\", must be one of #{validator.allowable_values}."
160
+ end
161
+ @send_strategy = send_strategy
162
+ end
163
+
164
+ # Checks equality by comparing each attribute.
165
+ # @param [Object] Object to be compared
166
+ def ==(o)
167
+ return true if self.equal?(o)
168
+ self.class == o.class &&
169
+ attachments == o.attachments &&
170
+ body == o.body &&
171
+ charset == o.charset &&
172
+ is_html == o.is_html &&
173
+ send_strategy == o.send_strategy &&
174
+ template == o.template &&
175
+ template_variables == o.template_variables
176
+ end
177
+
178
+ # @see the `==` method
179
+ # @param [Object] Object to be compared
180
+ def eql?(o)
181
+ self == o
182
+ end
183
+
184
+ # Calculates hash code according to all attributes.
185
+ # @return [Integer] Hash code
186
+ def hash
187
+ [attachments, body, charset, is_html, send_strategy, template, template_variables].hash
188
+ end
189
+
190
+ # Builds the object from hash
191
+ # @param [Hash] attributes Model attributes in the form of hash
192
+ # @return [Object] Returns the model itself
193
+ def self.build_from_hash(attributes)
194
+ new.build_from_hash(attributes)
195
+ end
196
+
197
+ # Builds the object from hash
198
+ # @param [Hash] attributes Model attributes in the form of hash
199
+ # @return [Object] Returns the model itself
200
+ def build_from_hash(attributes)
201
+ return nil unless attributes.is_a?(Hash)
202
+ self.class.openapi_types.each_pair do |key, type|
203
+ if type =~ /\AArray<(.*)>/i
204
+ # check to ensure the input is an array given that the attribute
205
+ # is documented as an array but the input is not
206
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
207
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
208
+ end
209
+ elsif !attributes[self.class.attribute_map[key]].nil?
210
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
211
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
212
+ end
213
+
214
+ self
215
+ end
216
+
217
+ # Deserializes the data based on type
218
+ # @param string type Data type
219
+ # @param string value Value to be deserialized
220
+ # @return [Object] Deserialized data
221
+ def _deserialize(type, value)
222
+ case type.to_sym
223
+ when :DateTime
224
+ DateTime.parse(value)
225
+ when :Date
226
+ Date.parse(value)
227
+ when :String
228
+ value.to_s
229
+ when :Integer
230
+ value.to_i
231
+ when :Float
232
+ value.to_f
233
+ when :Boolean
234
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
235
+ true
236
+ else
237
+ false
238
+ end
239
+ when :Object
240
+ # generic object (usually a Hash), return directly
241
+ value
242
+ when /\AArray<(?<inner_type>.+)>\z/
243
+ inner_type = Regexp.last_match[:inner_type]
244
+ value.map { |v| _deserialize(inner_type, v) }
245
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
246
+ k_type = Regexp.last_match[:k_type]
247
+ v_type = Regexp.last_match[:v_type]
248
+ {}.tap do |hash|
249
+ value.each do |k, v|
250
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
251
+ end
252
+ end
253
+ else # model
254
+ MailSlurpClient.const_get(type).build_from_hash(value)
255
+ end
256
+ end
257
+
258
+ # Returns the string representation of the object
259
+ # @return [String] String presentation of the object
260
+ def to_s
261
+ to_hash.to_s
262
+ end
263
+
264
+ # to_body is an alias to to_hash (backward compatibility)
265
+ # @return [Hash] Returns the object in the form of hash
266
+ def to_body
267
+ to_hash
268
+ end
269
+
270
+ # Returns the object in the form of hash
271
+ # @return [Hash] Returns the object in the form of hash
272
+ def to_hash
273
+ hash = {}
274
+ self.class.attribute_map.each_pair do |attr, param|
275
+ value = self.send(attr)
276
+ if value.nil?
277
+ is_nullable = self.class.openapi_nullable.include?(attr)
278
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
279
+ end
280
+
281
+ hash[param] = _to_hash(value)
282
+ end
283
+ hash
284
+ end
285
+
286
+ # Outputs non-array value in the form of hash
287
+ # For object, use to_hash. Otherwise, just return the value
288
+ # @param [Object] value Any valid value
289
+ # @return [Hash] Returns the value in the form of hash
290
+ def _to_hash(value)
291
+ if value.is_a?(Array)
292
+ value.compact.map { |v| _to_hash(v) }
293
+ elsif value.is_a?(Hash)
294
+ {}.tap do |hash|
295
+ value.each { |k, v| hash[k] = _to_hash(v) }
296
+ end
297
+ elsif value.respond_to? :to_hash
298
+ value.to_hash
299
+ else
300
+ value
301
+ end
302
+ end
303
+ end
304
+ end
@@ -24,6 +24,9 @@ module MailSlurpClient
24
24
  # The charset that your message should be sent with. Optional. Default is UTF-8
25
25
  attr_accessor :charset
26
26
 
27
+ # The from header that should be used. Optional
28
+ attr_accessor :from
29
+
27
30
  # Is the reply HTML
28
31
  attr_accessor :is_html
29
32
 
@@ -67,6 +70,7 @@ module MailSlurpClient
67
70
  :'attachments' => :'attachments',
68
71
  :'body' => :'body',
69
72
  :'charset' => :'charset',
73
+ :'from' => :'from',
70
74
  :'is_html' => :'isHTML',
71
75
  :'reply_to' => :'replyTo',
72
76
  :'send_strategy' => :'sendStrategy',
@@ -81,6 +85,7 @@ module MailSlurpClient
81
85
  :'attachments' => :'Array<String>',
82
86
  :'body' => :'String',
83
87
  :'charset' => :'String',
88
+ :'from' => :'String',
84
89
  :'is_html' => :'Boolean',
85
90
  :'reply_to' => :'String',
86
91
  :'send_strategy' => :'String',
@@ -124,6 +129,10 @@ module MailSlurpClient
124
129
  self.charset = attributes[:'charset']
125
130
  end
126
131
 
132
+ if attributes.key?(:'from')
133
+ self.from = attributes[:'from']
134
+ end
135
+
127
136
  if attributes.key?(:'is_html')
128
137
  self.is_html = attributes[:'is_html']
129
138
  end
@@ -178,6 +187,7 @@ module MailSlurpClient
178
187
  attachments == o.attachments &&
179
188
  body == o.body &&
180
189
  charset == o.charset &&
190
+ from == o.from &&
181
191
  is_html == o.is_html &&
182
192
  reply_to == o.reply_to &&
183
193
  send_strategy == o.send_strategy &&
@@ -194,7 +204,7 @@ module MailSlurpClient
194
204
  # Calculates hash code according to all attributes.
195
205
  # @return [Integer] Hash code
196
206
  def hash
197
- [attachments, body, charset, is_html, reply_to, send_strategy, template, template_variables].hash
207
+ [attachments, body, charset, from, is_html, reply_to, send_strategy, template, template_variables].hash
198
208
  end
199
209
 
200
210
  # Builds the object from hash
@@ -0,0 +1,338 @@
1
+ =begin
2
+ #MailSlurp API
3
+
4
+ #MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more. ## Resources - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://www.mailslurp.com/docs/) - [Examples](https://github.com/mailslurp/examples) repository
5
+
6
+ The version of the OpenAPI document: 6.5.2
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module MailSlurpClient
16
+ # A thread is a message thread created for a message received by an alias
17
+ class ThreadProjection
18
+ attr_accessor :alias_id
19
+
20
+ attr_accessor :bcc
21
+
22
+ attr_accessor :cc
23
+
24
+ attr_accessor :created_at
25
+
26
+ attr_accessor :id
27
+
28
+ attr_accessor :inbox_id
29
+
30
+ attr_accessor :name
31
+
32
+ attr_accessor :subject
33
+
34
+ attr_accessor :to
35
+
36
+ attr_accessor :updated_at
37
+
38
+ attr_accessor :user_id
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'alias_id' => :'aliasId',
44
+ :'bcc' => :'bcc',
45
+ :'cc' => :'cc',
46
+ :'created_at' => :'createdAt',
47
+ :'id' => :'id',
48
+ :'inbox_id' => :'inboxId',
49
+ :'name' => :'name',
50
+ :'subject' => :'subject',
51
+ :'to' => :'to',
52
+ :'updated_at' => :'updatedAt',
53
+ :'user_id' => :'userId'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'alias_id' => :'String',
61
+ :'bcc' => :'Array<String>',
62
+ :'cc' => :'Array<String>',
63
+ :'created_at' => :'DateTime',
64
+ :'id' => :'String',
65
+ :'inbox_id' => :'String',
66
+ :'name' => :'String',
67
+ :'subject' => :'String',
68
+ :'to' => :'Array<String>',
69
+ :'updated_at' => :'DateTime',
70
+ :'user_id' => :'String'
71
+ }
72
+ end
73
+
74
+ # List of attributes with nullable: true
75
+ def self.openapi_nullable
76
+ Set.new([
77
+ ])
78
+ end
79
+
80
+ # Initializes the object
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ def initialize(attributes = {})
83
+ if (!attributes.is_a?(Hash))
84
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::ThreadProjection` initialize method"
85
+ end
86
+
87
+ # check to see if the attribute exists and convert string to symbol for hash key
88
+ attributes = attributes.each_with_object({}) { |(k, v), h|
89
+ if (!self.class.attribute_map.key?(k.to_sym))
90
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::ThreadProjection`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
91
+ end
92
+ h[k.to_sym] = v
93
+ }
94
+
95
+ if attributes.key?(:'alias_id')
96
+ self.alias_id = attributes[:'alias_id']
97
+ end
98
+
99
+ if attributes.key?(:'bcc')
100
+ if (value = attributes[:'bcc']).is_a?(Array)
101
+ self.bcc = value
102
+ end
103
+ end
104
+
105
+ if attributes.key?(:'cc')
106
+ if (value = attributes[:'cc']).is_a?(Array)
107
+ self.cc = value
108
+ end
109
+ end
110
+
111
+ if attributes.key?(:'created_at')
112
+ self.created_at = attributes[:'created_at']
113
+ end
114
+
115
+ if attributes.key?(:'id')
116
+ self.id = attributes[:'id']
117
+ end
118
+
119
+ if attributes.key?(:'inbox_id')
120
+ self.inbox_id = attributes[:'inbox_id']
121
+ end
122
+
123
+ if attributes.key?(:'name')
124
+ self.name = attributes[:'name']
125
+ end
126
+
127
+ if attributes.key?(:'subject')
128
+ self.subject = attributes[:'subject']
129
+ end
130
+
131
+ if attributes.key?(:'to')
132
+ if (value = attributes[:'to']).is_a?(Array)
133
+ self.to = value
134
+ end
135
+ end
136
+
137
+ if attributes.key?(:'updated_at')
138
+ self.updated_at = attributes[:'updated_at']
139
+ end
140
+
141
+ if attributes.key?(:'user_id')
142
+ self.user_id = attributes[:'user_id']
143
+ end
144
+ end
145
+
146
+ # Show invalid properties with the reasons. Usually used together with valid?
147
+ # @return Array for valid properties with the reasons
148
+ def list_invalid_properties
149
+ invalid_properties = Array.new
150
+ if @alias_id.nil?
151
+ invalid_properties.push('invalid value for "alias_id", alias_id cannot be nil.')
152
+ end
153
+
154
+ if @created_at.nil?
155
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
156
+ end
157
+
158
+ if @id.nil?
159
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
160
+ end
161
+
162
+ if @inbox_id.nil?
163
+ invalid_properties.push('invalid value for "inbox_id", inbox_id cannot be nil.')
164
+ end
165
+
166
+ if @to.nil?
167
+ invalid_properties.push('invalid value for "to", to cannot be nil.')
168
+ end
169
+
170
+ if @updated_at.nil?
171
+ invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
172
+ end
173
+
174
+ if @user_id.nil?
175
+ invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
176
+ end
177
+
178
+ invalid_properties
179
+ end
180
+
181
+ # Check to see if the all the properties in the model are valid
182
+ # @return true if the model is valid
183
+ def valid?
184
+ return false if @alias_id.nil?
185
+ return false if @created_at.nil?
186
+ return false if @id.nil?
187
+ return false if @inbox_id.nil?
188
+ return false if @to.nil?
189
+ return false if @updated_at.nil?
190
+ return false if @user_id.nil?
191
+ true
192
+ end
193
+
194
+ # Checks equality by comparing each attribute.
195
+ # @param [Object] Object to be compared
196
+ def ==(o)
197
+ return true if self.equal?(o)
198
+ self.class == o.class &&
199
+ alias_id == o.alias_id &&
200
+ bcc == o.bcc &&
201
+ cc == o.cc &&
202
+ created_at == o.created_at &&
203
+ id == o.id &&
204
+ inbox_id == o.inbox_id &&
205
+ name == o.name &&
206
+ subject == o.subject &&
207
+ to == o.to &&
208
+ updated_at == o.updated_at &&
209
+ user_id == o.user_id
210
+ end
211
+
212
+ # @see the `==` method
213
+ # @param [Object] Object to be compared
214
+ def eql?(o)
215
+ self == o
216
+ end
217
+
218
+ # Calculates hash code according to all attributes.
219
+ # @return [Integer] Hash code
220
+ def hash
221
+ [alias_id, bcc, cc, created_at, id, inbox_id, name, subject, to, updated_at, user_id].hash
222
+ end
223
+
224
+ # Builds the object from hash
225
+ # @param [Hash] attributes Model attributes in the form of hash
226
+ # @return [Object] Returns the model itself
227
+ def self.build_from_hash(attributes)
228
+ new.build_from_hash(attributes)
229
+ end
230
+
231
+ # Builds the object from hash
232
+ # @param [Hash] attributes Model attributes in the form of hash
233
+ # @return [Object] Returns the model itself
234
+ def build_from_hash(attributes)
235
+ return nil unless attributes.is_a?(Hash)
236
+ self.class.openapi_types.each_pair do |key, type|
237
+ if type =~ /\AArray<(.*)>/i
238
+ # check to ensure the input is an array given that the attribute
239
+ # is documented as an array but the input is not
240
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
241
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
242
+ end
243
+ elsif !attributes[self.class.attribute_map[key]].nil?
244
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
245
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
246
+ end
247
+
248
+ self
249
+ end
250
+
251
+ # Deserializes the data based on type
252
+ # @param string type Data type
253
+ # @param string value Value to be deserialized
254
+ # @return [Object] Deserialized data
255
+ def _deserialize(type, value)
256
+ case type.to_sym
257
+ when :DateTime
258
+ DateTime.parse(value)
259
+ when :Date
260
+ Date.parse(value)
261
+ when :String
262
+ value.to_s
263
+ when :Integer
264
+ value.to_i
265
+ when :Float
266
+ value.to_f
267
+ when :Boolean
268
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
269
+ true
270
+ else
271
+ false
272
+ end
273
+ when :Object
274
+ # generic object (usually a Hash), return directly
275
+ value
276
+ when /\AArray<(?<inner_type>.+)>\z/
277
+ inner_type = Regexp.last_match[:inner_type]
278
+ value.map { |v| _deserialize(inner_type, v) }
279
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
280
+ k_type = Regexp.last_match[:k_type]
281
+ v_type = Regexp.last_match[:v_type]
282
+ {}.tap do |hash|
283
+ value.each do |k, v|
284
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
285
+ end
286
+ end
287
+ else # model
288
+ MailSlurpClient.const_get(type).build_from_hash(value)
289
+ end
290
+ end
291
+
292
+ # Returns the string representation of the object
293
+ # @return [String] String presentation of the object
294
+ def to_s
295
+ to_hash.to_s
296
+ end
297
+
298
+ # to_body is an alias to to_hash (backward compatibility)
299
+ # @return [Hash] Returns the object in the form of hash
300
+ def to_body
301
+ to_hash
302
+ end
303
+
304
+ # Returns the object in the form of hash
305
+ # @return [Hash] Returns the object in the form of hash
306
+ def to_hash
307
+ hash = {}
308
+ self.class.attribute_map.each_pair do |attr, param|
309
+ value = self.send(attr)
310
+ if value.nil?
311
+ is_nullable = self.class.openapi_nullable.include?(attr)
312
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
313
+ end
314
+
315
+ hash[param] = _to_hash(value)
316
+ end
317
+ hash
318
+ end
319
+
320
+ # Outputs non-array value in the form of hash
321
+ # For object, use to_hash. Otherwise, just return the value
322
+ # @param [Object] value Any valid value
323
+ # @return [Hash] Returns the value in the form of hash
324
+ def _to_hash(value)
325
+ if value.is_a?(Array)
326
+ value.compact.map { |v| _to_hash(v) }
327
+ elsif value.is_a?(Hash)
328
+ {}.tap do |hash|
329
+ value.each { |k, v| hash[k] = _to_hash(v) }
330
+ end
331
+ elsif value.respond_to? :to_hash
332
+ value.to_hash
333
+ else
334
+ value
335
+ end
336
+ end
337
+ end
338
+ end