mailslurp_client 15.19.1 → 15.19.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mailslurp_client/api/imap_controller_api.rb +65 -0
  3. data/lib/mailslurp_client/models/alias_projection.rb +29 -29
  4. data/lib/mailslurp_client/models/attachment_projection.rb +29 -29
  5. data/lib/mailslurp_client/models/bounce_projection.rb +19 -19
  6. data/lib/mailslurp_client/models/bounce_recipient_projection.rb +15 -15
  7. data/lib/mailslurp_client/models/connector_projection.rb +15 -15
  8. data/lib/mailslurp_client/models/connector_sync_event_projection.rb +15 -15
  9. data/lib/mailslurp_client/models/contact_projection.rb +10 -10
  10. data/lib/mailslurp_client/models/email_projection.rb +19 -19
  11. data/lib/mailslurp_client/models/expired_inbox_record_projection.rb +15 -15
  12. data/lib/mailslurp_client/models/imap_email_projection.rb +25 -1
  13. data/lib/mailslurp_client/models/imap_mailbox_status.rb +367 -0
  14. data/lib/mailslurp_client/models/imap_server_status_options.rb +241 -0
  15. data/lib/mailslurp_client/models/imap_server_status_result.rb +207 -0
  16. data/lib/mailslurp_client/models/inbox_forwarder_event_projection.rb +10 -10
  17. data/lib/mailslurp_client/models/inbox_replier_event_projection.rb +14 -14
  18. data/lib/mailslurp_client/models/list_unsubscribe_recipient_projection.rb +15 -15
  19. data/lib/mailslurp_client/models/missed_email_projection.rb +14 -14
  20. data/lib/mailslurp_client/models/page_alias.rb +15 -15
  21. data/lib/mailslurp_client/models/page_attachment_entity.rb +15 -15
  22. data/lib/mailslurp_client/models/page_bounced_email.rb +15 -15
  23. data/lib/mailslurp_client/models/page_bounced_recipients.rb +15 -15
  24. data/lib/mailslurp_client/models/page_complaint.rb +15 -15
  25. data/lib/mailslurp_client/models/page_connector.rb +15 -15
  26. data/lib/mailslurp_client/models/page_connector_sync_events.rb +15 -15
  27. data/lib/mailslurp_client/models/page_contact_projection.rb +15 -15
  28. data/lib/mailslurp_client/models/page_delivery_status.rb +15 -15
  29. data/lib/mailslurp_client/models/page_email_preview.rb +15 -15
  30. data/lib/mailslurp_client/models/page_email_projection.rb +15 -15
  31. data/lib/mailslurp_client/models/page_email_validation_request.rb +15 -15
  32. data/lib/mailslurp_client/models/page_expired_inbox_record_projection.rb +15 -15
  33. data/lib/mailslurp_client/models/page_group_projection.rb +15 -15
  34. data/lib/mailslurp_client/models/page_inbox_forwarder_dto.rb +15 -15
  35. data/lib/mailslurp_client/models/page_inbox_forwarder_events.rb +15 -15
  36. data/lib/mailslurp_client/models/page_inbox_projection.rb +15 -15
  37. data/lib/mailslurp_client/models/page_inbox_replier_dto.rb +15 -15
  38. data/lib/mailslurp_client/models/page_inbox_replier_events.rb +15 -15
  39. data/lib/mailslurp_client/models/page_inbox_ruleset_dto.rb +15 -15
  40. data/lib/mailslurp_client/models/page_list_unsubscribe_recipients.rb +15 -15
  41. data/lib/mailslurp_client/models/page_missed_email_projection.rb +15 -15
  42. data/lib/mailslurp_client/models/page_organization_inbox_projection.rb +15 -15
  43. data/lib/mailslurp_client/models/page_phone_number_projection.rb +15 -15
  44. data/lib/mailslurp_client/models/page_scheduled_jobs.rb +15 -15
  45. data/lib/mailslurp_client/models/page_sent_email_projection.rb +15 -15
  46. data/lib/mailslurp_client/models/page_sent_email_with_queue_projection.rb +15 -15
  47. data/lib/mailslurp_client/models/page_sms_projection.rb +15 -15
  48. data/lib/mailslurp_client/models/page_template_projection.rb +15 -15
  49. data/lib/mailslurp_client/models/page_thread_projection.rb +15 -15
  50. data/lib/mailslurp_client/models/page_tracking_pixel_projection.rb +15 -15
  51. data/lib/mailslurp_client/models/page_unknown_missed_email_projection.rb +15 -15
  52. data/lib/mailslurp_client/models/page_webhook_projection.rb +15 -15
  53. data/lib/mailslurp_client/models/page_webhook_result.rb +15 -15
  54. data/lib/mailslurp_client/models/phone_number_projection.rb +15 -15
  55. data/lib/mailslurp_client/models/sent_email_projection.rb +27 -27
  56. data/lib/mailslurp_client/models/sms_projection.rb +29 -29
  57. data/lib/mailslurp_client/models/template_projection.rb +17 -17
  58. data/lib/mailslurp_client/models/thread_projection.rb +35 -35
  59. data/lib/mailslurp_client/models/tracking_pixel_projection.rb +15 -15
  60. data/lib/mailslurp_client/models/unknown_missed_email_projection.rb +13 -13
  61. data/lib/mailslurp_client/models/webhook_projection.rb +25 -25
  62. data/lib/mailslurp_client/version.rb +1 -1
  63. data/lib/mailslurp_client.rb +3 -0
  64. metadata +5 -2
@@ -0,0 +1,367 @@
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://docs.mailslurp.com/) - [Examples](https://github.com/mailslurp/examples) repository
5
+
6
+ The version of the OpenAPI document: 6.5.2
7
+ Contact: contact@mailslurp.dev
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
+ class ImapMailboxStatus
17
+ # The mailbox name.
18
+ attr_accessor :name
19
+
20
+ # True if the mailbox is open in read-only mode.
21
+ attr_accessor :read_only
22
+
23
+ # The mailbox items that are currently filled in. This map's values should not be used directly, they must only be used by libraries implementing extensions of the IMAP protocol.
24
+ attr_accessor :items
25
+
26
+ # The mailbox flags.
27
+ attr_accessor :flags
28
+
29
+ # The mailbox permanent flags.
30
+ attr_accessor :permanent_flags
31
+
32
+ # The sequence number of the first unseen message in the mailbox.
33
+ attr_accessor :unseen_seq_num
34
+
35
+ # The number of messages in this mailbox.
36
+ attr_accessor :messages
37
+
38
+ # The number of messages not seen since the last time the mailbox was opened.
39
+ attr_accessor :recent
40
+
41
+ # The number of unread messages.
42
+ attr_accessor :unseen
43
+
44
+ # The next UID.
45
+ attr_accessor :uid_next
46
+
47
+ # Together with a UID, it is a unique identifier for a message. Must be greater than or equal to 1.
48
+ attr_accessor :uid_validity
49
+
50
+ # Per-mailbox limit of message size. Set only if server supports the APPENDLIMIT extension
51
+ attr_accessor :append_limit
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'name' => :'name',
57
+ :'read_only' => :'readOnly',
58
+ :'items' => :'items',
59
+ :'flags' => :'flags',
60
+ :'permanent_flags' => :'permanentFlags',
61
+ :'unseen_seq_num' => :'unseenSeqNum',
62
+ :'messages' => :'messages',
63
+ :'recent' => :'recent',
64
+ :'unseen' => :'unseen',
65
+ :'uid_next' => :'uidNext',
66
+ :'uid_validity' => :'uidValidity',
67
+ :'append_limit' => :'appendLimit'
68
+ }
69
+ end
70
+
71
+ # Attribute type mapping.
72
+ def self.openapi_types
73
+ {
74
+ :'name' => :'String',
75
+ :'read_only' => :'Boolean',
76
+ :'items' => :'Hash<String, Object>',
77
+ :'flags' => :'Array<String>',
78
+ :'permanent_flags' => :'Array<String>',
79
+ :'unseen_seq_num' => :'Integer',
80
+ :'messages' => :'Integer',
81
+ :'recent' => :'Integer',
82
+ :'unseen' => :'Integer',
83
+ :'uid_next' => :'Integer',
84
+ :'uid_validity' => :'Integer',
85
+ :'append_limit' => :'Integer'
86
+ }
87
+ end
88
+
89
+ # List of attributes with nullable: true
90
+ def self.openapi_nullable
91
+ Set.new([
92
+ :'items',
93
+ :'flags',
94
+ :'permanent_flags',
95
+ :'append_limit'
96
+ ])
97
+ end
98
+
99
+ # Initializes the object
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ def initialize(attributes = {})
102
+ if (!attributes.is_a?(Hash))
103
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::ImapMailboxStatus` initialize method"
104
+ end
105
+
106
+ # check to see if the attribute exists and convert string to symbol for hash key
107
+ attributes = attributes.each_with_object({}) { |(k, v), h|
108
+ if (!self.class.attribute_map.key?(k.to_sym))
109
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::ImapMailboxStatus`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
110
+ end
111
+ h[k.to_sym] = v
112
+ }
113
+
114
+ if attributes.key?(:'name')
115
+ self.name = attributes[:'name']
116
+ end
117
+
118
+ if attributes.key?(:'read_only')
119
+ self.read_only = attributes[:'read_only']
120
+ end
121
+
122
+ if attributes.key?(:'items')
123
+ if (value = attributes[:'items']).is_a?(Hash)
124
+ self.items = value
125
+ end
126
+ end
127
+
128
+ if attributes.key?(:'flags')
129
+ if (value = attributes[:'flags']).is_a?(Array)
130
+ self.flags = value
131
+ end
132
+ end
133
+
134
+ if attributes.key?(:'permanent_flags')
135
+ if (value = attributes[:'permanent_flags']).is_a?(Array)
136
+ self.permanent_flags = value
137
+ end
138
+ end
139
+
140
+ if attributes.key?(:'unseen_seq_num')
141
+ self.unseen_seq_num = attributes[:'unseen_seq_num']
142
+ end
143
+
144
+ if attributes.key?(:'messages')
145
+ self.messages = attributes[:'messages']
146
+ end
147
+
148
+ if attributes.key?(:'recent')
149
+ self.recent = attributes[:'recent']
150
+ end
151
+
152
+ if attributes.key?(:'unseen')
153
+ self.unseen = attributes[:'unseen']
154
+ end
155
+
156
+ if attributes.key?(:'uid_next')
157
+ self.uid_next = attributes[:'uid_next']
158
+ end
159
+
160
+ if attributes.key?(:'uid_validity')
161
+ self.uid_validity = attributes[:'uid_validity']
162
+ end
163
+
164
+ if attributes.key?(:'append_limit')
165
+ self.append_limit = attributes[:'append_limit']
166
+ end
167
+ end
168
+
169
+ # Show invalid properties with the reasons. Usually used together with valid?
170
+ # @return Array for valid properties with the reasons
171
+ def list_invalid_properties
172
+ invalid_properties = Array.new
173
+ if @name.nil?
174
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
175
+ end
176
+
177
+ if @read_only.nil?
178
+ invalid_properties.push('invalid value for "read_only", read_only cannot be nil.')
179
+ end
180
+
181
+ if @unseen_seq_num.nil?
182
+ invalid_properties.push('invalid value for "unseen_seq_num", unseen_seq_num cannot be nil.')
183
+ end
184
+
185
+ if @messages.nil?
186
+ invalid_properties.push('invalid value for "messages", messages cannot be nil.')
187
+ end
188
+
189
+ if @recent.nil?
190
+ invalid_properties.push('invalid value for "recent", recent cannot be nil.')
191
+ end
192
+
193
+ if @unseen.nil?
194
+ invalid_properties.push('invalid value for "unseen", unseen cannot be nil.')
195
+ end
196
+
197
+ if @uid_next.nil?
198
+ invalid_properties.push('invalid value for "uid_next", uid_next cannot be nil.')
199
+ end
200
+
201
+ if @uid_validity.nil?
202
+ invalid_properties.push('invalid value for "uid_validity", uid_validity cannot be nil.')
203
+ end
204
+
205
+ invalid_properties
206
+ end
207
+
208
+ # Check to see if the all the properties in the model are valid
209
+ # @return true if the model is valid
210
+ def valid?
211
+ return false if @name.nil?
212
+ return false if @read_only.nil?
213
+ return false if @unseen_seq_num.nil?
214
+ return false if @messages.nil?
215
+ return false if @recent.nil?
216
+ return false if @unseen.nil?
217
+ return false if @uid_next.nil?
218
+ return false if @uid_validity.nil?
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
+ name == o.name &&
228
+ read_only == o.read_only &&
229
+ items == o.items &&
230
+ flags == o.flags &&
231
+ permanent_flags == o.permanent_flags &&
232
+ unseen_seq_num == o.unseen_seq_num &&
233
+ messages == o.messages &&
234
+ recent == o.recent &&
235
+ unseen == o.unseen &&
236
+ uid_next == o.uid_next &&
237
+ uid_validity == o.uid_validity &&
238
+ append_limit == o.append_limit
239
+ end
240
+
241
+ # @see the `==` method
242
+ # @param [Object] Object to be compared
243
+ def eql?(o)
244
+ self == o
245
+ end
246
+
247
+ # Calculates hash code according to all attributes.
248
+ # @return [Integer] Hash code
249
+ def hash
250
+ [name, read_only, items, flags, permanent_flags, unseen_seq_num, messages, recent, unseen, uid_next, uid_validity, append_limit].hash
251
+ end
252
+
253
+ # Builds the object from hash
254
+ # @param [Hash] attributes Model attributes in the form of hash
255
+ # @return [Object] Returns the model itself
256
+ def self.build_from_hash(attributes)
257
+ new.build_from_hash(attributes)
258
+ end
259
+
260
+ # Builds the object from hash
261
+ # @param [Hash] attributes Model attributes in the form of hash
262
+ # @return [Object] Returns the model itself
263
+ def build_from_hash(attributes)
264
+ return nil unless attributes.is_a?(Hash)
265
+ self.class.openapi_types.each_pair do |key, type|
266
+ if type =~ /\AArray<(.*)>/i
267
+ # check to ensure the input is an array given that the attribute
268
+ # is documented as an array but the input is not
269
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
270
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
271
+ end
272
+ elsif !attributes[self.class.attribute_map[key]].nil?
273
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
274
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
275
+ end
276
+
277
+ self
278
+ end
279
+
280
+ # Deserializes the data based on type
281
+ # @param string type Data type
282
+ # @param string value Value to be deserialized
283
+ # @return [Object] Deserialized data
284
+ def _deserialize(type, value)
285
+ case type.to_sym
286
+ when :DateTime
287
+ DateTime.parse(value)
288
+ when :Date
289
+ Date.parse(value)
290
+ when :String
291
+ value.to_s
292
+ when :Integer
293
+ value.to_i
294
+ when :Float
295
+ value.to_f
296
+ when :Boolean
297
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
298
+ true
299
+ else
300
+ false
301
+ end
302
+ when :Object
303
+ # generic object (usually a Hash), return directly
304
+ value
305
+ when /\AArray<(?<inner_type>.+)>\z/
306
+ inner_type = Regexp.last_match[:inner_type]
307
+ value.map { |v| _deserialize(inner_type, v) }
308
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
309
+ k_type = Regexp.last_match[:k_type]
310
+ v_type = Regexp.last_match[:v_type]
311
+ {}.tap do |hash|
312
+ value.each do |k, v|
313
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
314
+ end
315
+ end
316
+ else # model
317
+ MailSlurpClient.const_get(type).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
+ end
367
+ end
@@ -0,0 +1,241 @@
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://docs.mailslurp.com/) - [Examples](https://github.com/mailslurp/examples) repository
5
+
6
+ The version of the OpenAPI document: 6.5.2
7
+ Contact: contact@mailslurp.dev
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
+ class ImapServerStatusOptions
17
+ attr_accessor :name
18
+
19
+ attr_accessor :status_items
20
+
21
+ class EnumAttributeValidator
22
+ attr_reader :datatype
23
+ attr_reader :allowable_values
24
+
25
+ def initialize(datatype, allowable_values)
26
+ @allowable_values = allowable_values.map do |value|
27
+ case datatype.to_s
28
+ when /Integer/i
29
+ value.to_i
30
+ when /Float/i
31
+ value.to_f
32
+ else
33
+ value
34
+ end
35
+ end
36
+ end
37
+
38
+ def valid?(value)
39
+ !value || allowable_values.include?(value)
40
+ end
41
+ end
42
+
43
+ # Attribute mapping from ruby-style variable name to JSON key.
44
+ def self.attribute_map
45
+ {
46
+ :'name' => :'name',
47
+ :'status_items' => :'statusItems'
48
+ }
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.openapi_types
53
+ {
54
+ :'name' => :'String',
55
+ :'status_items' => :'Array<String>'
56
+ }
57
+ end
58
+
59
+ # List of attributes with nullable: true
60
+ def self.openapi_nullable
61
+ Set.new([
62
+ :'name',
63
+ :'status_items'
64
+ ])
65
+ end
66
+
67
+ # Initializes the object
68
+ # @param [Hash] attributes Model attributes in the form of hash
69
+ def initialize(attributes = {})
70
+ if (!attributes.is_a?(Hash))
71
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::ImapServerStatusOptions` initialize method"
72
+ end
73
+
74
+ # check to see if the attribute exists and convert string to symbol for hash key
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!self.class.attribute_map.key?(k.to_sym))
77
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::ImapServerStatusOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
78
+ end
79
+ h[k.to_sym] = v
80
+ }
81
+
82
+ if attributes.key?(:'name')
83
+ self.name = attributes[:'name']
84
+ end
85
+
86
+ if attributes.key?(:'status_items')
87
+ if (value = attributes[:'status_items']).is_a?(Array)
88
+ self.status_items = value
89
+ end
90
+ end
91
+ end
92
+
93
+ # Show invalid properties with the reasons. Usually used together with valid?
94
+ # @return Array for valid properties with the reasons
95
+ def list_invalid_properties
96
+ invalid_properties = Array.new
97
+ invalid_properties
98
+ end
99
+
100
+ # Check to see if the all the properties in the model are valid
101
+ # @return true if the model is valid
102
+ def valid?
103
+ true
104
+ end
105
+
106
+ # Checks equality by comparing each attribute.
107
+ # @param [Object] Object to be compared
108
+ def ==(o)
109
+ return true if self.equal?(o)
110
+ self.class == o.class &&
111
+ name == o.name &&
112
+ status_items == o.status_items
113
+ end
114
+
115
+ # @see the `==` method
116
+ # @param [Object] Object to be compared
117
+ def eql?(o)
118
+ self == o
119
+ end
120
+
121
+ # Calculates hash code according to all attributes.
122
+ # @return [Integer] Hash code
123
+ def hash
124
+ [name, status_items].hash
125
+ end
126
+
127
+ # Builds the object from hash
128
+ # @param [Hash] attributes Model attributes in the form of hash
129
+ # @return [Object] Returns the model itself
130
+ def self.build_from_hash(attributes)
131
+ new.build_from_hash(attributes)
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 build_from_hash(attributes)
138
+ return nil unless attributes.is_a?(Hash)
139
+ self.class.openapi_types.each_pair do |key, type|
140
+ if type =~ /\AArray<(.*)>/i
141
+ # check to ensure the input is an array given that the attribute
142
+ # is documented as an array but the input is not
143
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
144
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
145
+ end
146
+ elsif !attributes[self.class.attribute_map[key]].nil?
147
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
148
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
149
+ end
150
+
151
+ self
152
+ end
153
+
154
+ # Deserializes the data based on type
155
+ # @param string type Data type
156
+ # @param string value Value to be deserialized
157
+ # @return [Object] Deserialized data
158
+ def _deserialize(type, value)
159
+ case type.to_sym
160
+ when :DateTime
161
+ DateTime.parse(value)
162
+ when :Date
163
+ Date.parse(value)
164
+ when :String
165
+ value.to_s
166
+ when :Integer
167
+ value.to_i
168
+ when :Float
169
+ value.to_f
170
+ when :Boolean
171
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
172
+ true
173
+ else
174
+ false
175
+ end
176
+ when :Object
177
+ # generic object (usually a Hash), return directly
178
+ value
179
+ when /\AArray<(?<inner_type>.+)>\z/
180
+ inner_type = Regexp.last_match[:inner_type]
181
+ value.map { |v| _deserialize(inner_type, v) }
182
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
183
+ k_type = Regexp.last_match[:k_type]
184
+ v_type = Regexp.last_match[:v_type]
185
+ {}.tap do |hash|
186
+ value.each do |k, v|
187
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
188
+ end
189
+ end
190
+ else # model
191
+ MailSlurpClient.const_get(type).build_from_hash(value)
192
+ end
193
+ end
194
+
195
+ # Returns the string representation of the object
196
+ # @return [String] String presentation of the object
197
+ def to_s
198
+ to_hash.to_s
199
+ end
200
+
201
+ # to_body is an alias to to_hash (backward compatibility)
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_body
204
+ to_hash
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = self.send(attr)
213
+ if value.nil?
214
+ is_nullable = self.class.openapi_nullable.include?(attr)
215
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
216
+ end
217
+
218
+ hash[param] = _to_hash(value)
219
+ end
220
+ hash
221
+ end
222
+
223
+ # Outputs non-array value in the form of hash
224
+ # For object, use to_hash. Otherwise, just return the value
225
+ # @param [Object] value Any valid value
226
+ # @return [Hash] Returns the value in the form of hash
227
+ def _to_hash(value)
228
+ if value.is_a?(Array)
229
+ value.compact.map { |v| _to_hash(v) }
230
+ elsif value.is_a?(Hash)
231
+ {}.tap do |hash|
232
+ value.each { |k, v| hash[k] = _to_hash(v) }
233
+ end
234
+ elsif value.respond_to? :to_hash
235
+ value.to_hash
236
+ else
237
+ value
238
+ end
239
+ end
240
+ end
241
+ end