mailslurp_client 15.20.0 → 15.21.1

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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mailslurp_client/api/attachment_controller_api.rb +6 -0
  3. data/lib/mailslurp_client/api/bounce_controller_api.rb +79 -0
  4. data/lib/mailslurp_client/api/inbox_controller_api.rb +56 -2
  5. data/lib/mailslurp_client/api/o_auth_connection_api.rb +170 -0
  6. data/lib/mailslurp_client/api/phone_controller_api.rb +381 -1
  7. data/lib/mailslurp_client/api/user_controller_api.rb +267 -0
  8. data/lib/mailslurp_client/models/alias_projection.rb +29 -29
  9. data/lib/mailslurp_client/models/alias_thread_projection.rb +39 -39
  10. data/lib/mailslurp_client/models/attachment_projection.rb +25 -25
  11. data/lib/mailslurp_client/models/bounce_projection.rb +22 -22
  12. data/lib/mailslurp_client/models/bounce_recipient_projection.rb +10 -10
  13. data/lib/mailslurp_client/models/connector_event_projection.rb +15 -15
  14. data/lib/mailslurp_client/models/connector_projection.rb +15 -15
  15. data/lib/mailslurp_client/models/contact_projection.rb +10 -10
  16. data/lib/mailslurp_client/models/create_emergency_address_options.rb +2 -2
  17. data/lib/mailslurp_client/models/create_o_auth_connection_result.rb +211 -0
  18. data/lib/mailslurp_client/models/create_o_auth_exchange_result.rb +229 -0
  19. data/lib/mailslurp_client/models/create_phone_number_options.rb +284 -0
  20. data/lib/mailslurp_client/models/domain_dto.rb +27 -1
  21. data/lib/mailslurp_client/models/email.rb +12 -1
  22. data/lib/mailslurp_client/models/email_preview.rb +15 -5
  23. data/lib/mailslurp_client/models/email_projection.rb +35 -25
  24. data/lib/mailslurp_client/models/email_thread_projection.rb +52 -52
  25. data/lib/mailslurp_client/models/emergency_address.rb +2 -2
  26. data/lib/mailslurp_client/models/emergency_address_dto.rb +2 -2
  27. data/lib/mailslurp_client/models/entity_automation_item_projection.rb +295 -0
  28. data/lib/mailslurp_client/models/entity_event_item_projection.rb +303 -0
  29. data/lib/mailslurp_client/models/entity_favourite_item_projection.rb +296 -0
  30. data/lib/mailslurp_client/models/expired_inbox_record_projection.rb +15 -15
  31. data/lib/mailslurp_client/models/guest_portal_user_projection.rb +39 -39
  32. data/lib/mailslurp_client/models/inbox_dto.rb +2 -2
  33. data/lib/mailslurp_client/models/inbox_forwarder_event_projection.rb +10 -10
  34. data/lib/mailslurp_client/models/inbox_preview.rb +2 -2
  35. data/lib/mailslurp_client/models/inbox_replier_event_projection.rb +10 -10
  36. data/lib/mailslurp_client/models/list_unsubscribe_recipient_projection.rb +15 -15
  37. data/lib/mailslurp_client/models/missed_email_projection.rb +14 -14
  38. data/lib/mailslurp_client/models/opt_in_identity_projection.rb +29 -29
  39. data/lib/mailslurp_client/models/organization_inbox_projection.rb +2 -2
  40. data/lib/mailslurp_client/models/page_entity_automation_items.rb +309 -0
  41. data/lib/mailslurp_client/models/page_entity_event_items.rb +309 -0
  42. data/lib/mailslurp_client/models/page_entity_favourite_items.rb +309 -0
  43. data/lib/mailslurp_client/models/page_phone_message_thread_item_projection.rb +309 -0
  44. data/lib/mailslurp_client/models/page_phone_message_thread_projection.rb +309 -0
  45. data/lib/mailslurp_client/models/page_reputation_items.rb +309 -0
  46. data/lib/mailslurp_client/models/phone_message_thread_item_projection.rb +315 -0
  47. data/lib/mailslurp_client/models/phone_message_thread_projection.rb +315 -0
  48. data/lib/mailslurp_client/models/phone_number_dto.rb +2 -2
  49. data/lib/mailslurp_client/models/phone_number_projection.rb +17 -17
  50. data/lib/mailslurp_client/models/phone_plan_availability_item.rb +2 -2
  51. data/lib/mailslurp_client/models/phone_plan_dto.rb +2 -2
  52. data/lib/mailslurp_client/models/plus_address_projection.rb +29 -29
  53. data/lib/mailslurp_client/models/reputation_item_projection.rb +317 -0
  54. data/lib/mailslurp_client/models/search_inboxes_options.rb +2 -2
  55. data/lib/mailslurp_client/models/sent_email_dto.rb +12 -1
  56. data/lib/mailslurp_client/models/sent_email_projection.rb +25 -25
  57. data/lib/mailslurp_client/models/sent_sms_projection.rb +15 -15
  58. data/lib/mailslurp_client/models/sms_preview.rb +15 -1
  59. data/lib/mailslurp_client/models/sms_projection.rb +15 -15
  60. data/lib/mailslurp_client/models/template_projection.rb +15 -15
  61. data/lib/mailslurp_client/models/tracking_pixel_projection.rb +15 -15
  62. data/lib/mailslurp_client/models/unknown_missed_email_projection.rb +10 -10
  63. data/lib/mailslurp_client/models/wait_for_sms_conditions.rb +1 -1
  64. data/lib/mailslurp_client/models/webhook_projection.rb +47 -47
  65. data/lib/mailslurp_client/version.rb +1 -1
  66. data/lib/mailslurp_client.rb +16 -0
  67. metadata +18 -2
@@ -0,0 +1,309 @@
1
+ =begin
2
+ #MailSlurp API
3
+
4
+ #MailSlurp is an API for sending and receiving emails and SMS from dynamically allocated email addresses and phone numbers. 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
+ # Paginated phone message threads. Page index starts at zero. Projection results may omit larger entity fields. For fetching a full entity use the projection ID with individual method calls.
17
+ class PagePhoneMessageThreadProjection
18
+ attr_accessor :content
19
+
20
+ attr_accessor :pageable
21
+
22
+ attr_accessor :total_elements
23
+
24
+ attr_accessor :total_pages
25
+
26
+ attr_accessor :last
27
+
28
+ attr_accessor :number_of_elements
29
+
30
+ attr_accessor :first
31
+
32
+ attr_accessor :size
33
+
34
+ attr_accessor :number
35
+
36
+ attr_accessor :sort
37
+
38
+ attr_accessor :empty
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'content' => :'content',
44
+ :'pageable' => :'pageable',
45
+ :'total_elements' => :'totalElements',
46
+ :'total_pages' => :'totalPages',
47
+ :'last' => :'last',
48
+ :'number_of_elements' => :'numberOfElements',
49
+ :'first' => :'first',
50
+ :'size' => :'size',
51
+ :'number' => :'number',
52
+ :'sort' => :'sort',
53
+ :'empty' => :'empty'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'content' => :'Array<PhoneMessageThreadProjection>',
61
+ :'pageable' => :'PageableObject',
62
+ :'total_elements' => :'Integer',
63
+ :'total_pages' => :'Integer',
64
+ :'last' => :'Boolean',
65
+ :'number_of_elements' => :'Integer',
66
+ :'first' => :'Boolean',
67
+ :'size' => :'Integer',
68
+ :'number' => :'Integer',
69
+ :'sort' => :'SortObject',
70
+ :'empty' => :'Boolean'
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::PagePhoneMessageThreadProjection` 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::PagePhoneMessageThreadProjection`. 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?(:'content')
96
+ if (value = attributes[:'content']).is_a?(Array)
97
+ self.content = value
98
+ end
99
+ end
100
+
101
+ if attributes.key?(:'pageable')
102
+ self.pageable = attributes[:'pageable']
103
+ end
104
+
105
+ if attributes.key?(:'total_elements')
106
+ self.total_elements = attributes[:'total_elements']
107
+ end
108
+
109
+ if attributes.key?(:'total_pages')
110
+ self.total_pages = attributes[:'total_pages']
111
+ end
112
+
113
+ if attributes.key?(:'last')
114
+ self.last = attributes[:'last']
115
+ end
116
+
117
+ if attributes.key?(:'number_of_elements')
118
+ self.number_of_elements = attributes[:'number_of_elements']
119
+ end
120
+
121
+ if attributes.key?(:'first')
122
+ self.first = attributes[:'first']
123
+ end
124
+
125
+ if attributes.key?(:'size')
126
+ self.size = attributes[:'size']
127
+ end
128
+
129
+ if attributes.key?(:'number')
130
+ self.number = attributes[:'number']
131
+ end
132
+
133
+ if attributes.key?(:'sort')
134
+ self.sort = attributes[:'sort']
135
+ end
136
+
137
+ if attributes.key?(:'empty')
138
+ self.empty = attributes[:'empty']
139
+ end
140
+ end
141
+
142
+ # Show invalid properties with the reasons. Usually used together with valid?
143
+ # @return Array for valid properties with the reasons
144
+ def list_invalid_properties
145
+ invalid_properties = Array.new
146
+ if @total_elements.nil?
147
+ invalid_properties.push('invalid value for "total_elements", total_elements cannot be nil.')
148
+ end
149
+
150
+ if @total_pages.nil?
151
+ invalid_properties.push('invalid value for "total_pages", total_pages cannot be nil.')
152
+ end
153
+
154
+ invalid_properties
155
+ end
156
+
157
+ # Check to see if the all the properties in the model are valid
158
+ # @return true if the model is valid
159
+ def valid?
160
+ return false if @total_elements.nil?
161
+ return false if @total_pages.nil?
162
+ true
163
+ end
164
+
165
+ # Checks equality by comparing each attribute.
166
+ # @param [Object] Object to be compared
167
+ def ==(o)
168
+ return true if self.equal?(o)
169
+ self.class == o.class &&
170
+ content == o.content &&
171
+ pageable == o.pageable &&
172
+ total_elements == o.total_elements &&
173
+ total_pages == o.total_pages &&
174
+ last == o.last &&
175
+ number_of_elements == o.number_of_elements &&
176
+ first == o.first &&
177
+ size == o.size &&
178
+ number == o.number &&
179
+ sort == o.sort &&
180
+ empty == o.empty
181
+ end
182
+
183
+ # @see the `==` method
184
+ # @param [Object] Object to be compared
185
+ def eql?(o)
186
+ self == o
187
+ end
188
+
189
+ # Calculates hash code according to all attributes.
190
+ # @return [Integer] Hash code
191
+ def hash
192
+ [content, pageable, total_elements, total_pages, last, number_of_elements, first, size, number, sort, empty].hash
193
+ end
194
+
195
+ # Builds the object from hash
196
+ # @param [Hash] attributes Model attributes in the form of hash
197
+ # @return [Object] Returns the model itself
198
+ def self.build_from_hash(attributes)
199
+ new.build_from_hash(attributes)
200
+ end
201
+
202
+ # Builds the object from hash
203
+ # @param [Hash] attributes Model attributes in the form of hash
204
+ # @return [Object] Returns the model itself
205
+ def build_from_hash(attributes)
206
+ return nil unless attributes.is_a?(Hash)
207
+ self.class.openapi_types.each_pair do |key, type|
208
+ if type =~ /\AArray<(.*)>/i
209
+ # check to ensure the input is an array given that the attribute
210
+ # is documented as an array but the input is not
211
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
212
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
213
+ end
214
+ elsif !attributes[self.class.attribute_map[key]].nil?
215
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
216
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
217
+ end
218
+
219
+ self
220
+ end
221
+
222
+ # Deserializes the data based on type
223
+ # @param string type Data type
224
+ # @param string value Value to be deserialized
225
+ # @return [Object] Deserialized data
226
+ def _deserialize(type, value)
227
+ case type.to_sym
228
+ when :DateTime
229
+ DateTime.parse(value)
230
+ when :Date
231
+ Date.parse(value)
232
+ when :String
233
+ value.to_s
234
+ when :Integer
235
+ value.to_i
236
+ when :Float
237
+ value.to_f
238
+ when :Boolean
239
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
240
+ true
241
+ else
242
+ false
243
+ end
244
+ when :Object
245
+ # generic object (usually a Hash), return directly
246
+ value
247
+ when /\AArray<(?<inner_type>.+)>\z/
248
+ inner_type = Regexp.last_match[:inner_type]
249
+ value.map { |v| _deserialize(inner_type, v) }
250
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
251
+ k_type = Regexp.last_match[:k_type]
252
+ v_type = Regexp.last_match[:v_type]
253
+ {}.tap do |hash|
254
+ value.each do |k, v|
255
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
256
+ end
257
+ end
258
+ else # model
259
+ MailSlurpClient.const_get(type).build_from_hash(value)
260
+ end
261
+ end
262
+
263
+ # Returns the string representation of the object
264
+ # @return [String] String presentation of the object
265
+ def to_s
266
+ to_hash.to_s
267
+ end
268
+
269
+ # to_body is an alias to to_hash (backward compatibility)
270
+ # @return [Hash] Returns the object in the form of hash
271
+ def to_body
272
+ to_hash
273
+ end
274
+
275
+ # Returns the object in the form of hash
276
+ # @return [Hash] Returns the object in the form of hash
277
+ def to_hash
278
+ hash = {}
279
+ self.class.attribute_map.each_pair do |attr, param|
280
+ value = self.send(attr)
281
+ if value.nil?
282
+ is_nullable = self.class.openapi_nullable.include?(attr)
283
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
284
+ end
285
+
286
+ hash[param] = _to_hash(value)
287
+ end
288
+ hash
289
+ end
290
+
291
+ # Outputs non-array value in the form of hash
292
+ # For object, use to_hash. Otherwise, just return the value
293
+ # @param [Object] value Any valid value
294
+ # @return [Hash] Returns the value in the form of hash
295
+ def _to_hash(value)
296
+ if value.is_a?(Array)
297
+ value.compact.map { |v| _to_hash(v) }
298
+ elsif value.is_a?(Hash)
299
+ {}.tap do |hash|
300
+ value.each { |k, v| hash[k] = _to_hash(v) }
301
+ end
302
+ elsif value.respond_to? :to_hash
303
+ value.to_hash
304
+ else
305
+ value
306
+ end
307
+ end
308
+ end
309
+ end
@@ -0,0 +1,309 @@
1
+ =begin
2
+ #MailSlurp API
3
+
4
+ #MailSlurp is an API for sending and receiving emails and SMS from dynamically allocated email addresses and phone numbers. 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
+ # Paginated reputation items like complaints and bounces. Page index starts at zero. Projection results may omit larger entity fields. For fetching a full entity use the projection ID with individual method calls.
17
+ class PageReputationItems
18
+ attr_accessor :content
19
+
20
+ attr_accessor :pageable
21
+
22
+ attr_accessor :total_elements
23
+
24
+ attr_accessor :total_pages
25
+
26
+ attr_accessor :last
27
+
28
+ attr_accessor :number_of_elements
29
+
30
+ attr_accessor :first
31
+
32
+ attr_accessor :size
33
+
34
+ attr_accessor :number
35
+
36
+ attr_accessor :sort
37
+
38
+ attr_accessor :empty
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'content' => :'content',
44
+ :'pageable' => :'pageable',
45
+ :'total_elements' => :'totalElements',
46
+ :'total_pages' => :'totalPages',
47
+ :'last' => :'last',
48
+ :'number_of_elements' => :'numberOfElements',
49
+ :'first' => :'first',
50
+ :'size' => :'size',
51
+ :'number' => :'number',
52
+ :'sort' => :'sort',
53
+ :'empty' => :'empty'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'content' => :'Array<ReputationItemProjection>',
61
+ :'pageable' => :'PageableObject',
62
+ :'total_elements' => :'Integer',
63
+ :'total_pages' => :'Integer',
64
+ :'last' => :'Boolean',
65
+ :'number_of_elements' => :'Integer',
66
+ :'first' => :'Boolean',
67
+ :'size' => :'Integer',
68
+ :'number' => :'Integer',
69
+ :'sort' => :'SortObject',
70
+ :'empty' => :'Boolean'
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::PageReputationItems` 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::PageReputationItems`. 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?(:'content')
96
+ if (value = attributes[:'content']).is_a?(Array)
97
+ self.content = value
98
+ end
99
+ end
100
+
101
+ if attributes.key?(:'pageable')
102
+ self.pageable = attributes[:'pageable']
103
+ end
104
+
105
+ if attributes.key?(:'total_elements')
106
+ self.total_elements = attributes[:'total_elements']
107
+ end
108
+
109
+ if attributes.key?(:'total_pages')
110
+ self.total_pages = attributes[:'total_pages']
111
+ end
112
+
113
+ if attributes.key?(:'last')
114
+ self.last = attributes[:'last']
115
+ end
116
+
117
+ if attributes.key?(:'number_of_elements')
118
+ self.number_of_elements = attributes[:'number_of_elements']
119
+ end
120
+
121
+ if attributes.key?(:'first')
122
+ self.first = attributes[:'first']
123
+ end
124
+
125
+ if attributes.key?(:'size')
126
+ self.size = attributes[:'size']
127
+ end
128
+
129
+ if attributes.key?(:'number')
130
+ self.number = attributes[:'number']
131
+ end
132
+
133
+ if attributes.key?(:'sort')
134
+ self.sort = attributes[:'sort']
135
+ end
136
+
137
+ if attributes.key?(:'empty')
138
+ self.empty = attributes[:'empty']
139
+ end
140
+ end
141
+
142
+ # Show invalid properties with the reasons. Usually used together with valid?
143
+ # @return Array for valid properties with the reasons
144
+ def list_invalid_properties
145
+ invalid_properties = Array.new
146
+ if @total_elements.nil?
147
+ invalid_properties.push('invalid value for "total_elements", total_elements cannot be nil.')
148
+ end
149
+
150
+ if @total_pages.nil?
151
+ invalid_properties.push('invalid value for "total_pages", total_pages cannot be nil.')
152
+ end
153
+
154
+ invalid_properties
155
+ end
156
+
157
+ # Check to see if the all the properties in the model are valid
158
+ # @return true if the model is valid
159
+ def valid?
160
+ return false if @total_elements.nil?
161
+ return false if @total_pages.nil?
162
+ true
163
+ end
164
+
165
+ # Checks equality by comparing each attribute.
166
+ # @param [Object] Object to be compared
167
+ def ==(o)
168
+ return true if self.equal?(o)
169
+ self.class == o.class &&
170
+ content == o.content &&
171
+ pageable == o.pageable &&
172
+ total_elements == o.total_elements &&
173
+ total_pages == o.total_pages &&
174
+ last == o.last &&
175
+ number_of_elements == o.number_of_elements &&
176
+ first == o.first &&
177
+ size == o.size &&
178
+ number == o.number &&
179
+ sort == o.sort &&
180
+ empty == o.empty
181
+ end
182
+
183
+ # @see the `==` method
184
+ # @param [Object] Object to be compared
185
+ def eql?(o)
186
+ self == o
187
+ end
188
+
189
+ # Calculates hash code according to all attributes.
190
+ # @return [Integer] Hash code
191
+ def hash
192
+ [content, pageable, total_elements, total_pages, last, number_of_elements, first, size, number, sort, empty].hash
193
+ end
194
+
195
+ # Builds the object from hash
196
+ # @param [Hash] attributes Model attributes in the form of hash
197
+ # @return [Object] Returns the model itself
198
+ def self.build_from_hash(attributes)
199
+ new.build_from_hash(attributes)
200
+ end
201
+
202
+ # Builds the object from hash
203
+ # @param [Hash] attributes Model attributes in the form of hash
204
+ # @return [Object] Returns the model itself
205
+ def build_from_hash(attributes)
206
+ return nil unless attributes.is_a?(Hash)
207
+ self.class.openapi_types.each_pair do |key, type|
208
+ if type =~ /\AArray<(.*)>/i
209
+ # check to ensure the input is an array given that the attribute
210
+ # is documented as an array but the input is not
211
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
212
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
213
+ end
214
+ elsif !attributes[self.class.attribute_map[key]].nil?
215
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
216
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
217
+ end
218
+
219
+ self
220
+ end
221
+
222
+ # Deserializes the data based on type
223
+ # @param string type Data type
224
+ # @param string value Value to be deserialized
225
+ # @return [Object] Deserialized data
226
+ def _deserialize(type, value)
227
+ case type.to_sym
228
+ when :DateTime
229
+ DateTime.parse(value)
230
+ when :Date
231
+ Date.parse(value)
232
+ when :String
233
+ value.to_s
234
+ when :Integer
235
+ value.to_i
236
+ when :Float
237
+ value.to_f
238
+ when :Boolean
239
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
240
+ true
241
+ else
242
+ false
243
+ end
244
+ when :Object
245
+ # generic object (usually a Hash), return directly
246
+ value
247
+ when /\AArray<(?<inner_type>.+)>\z/
248
+ inner_type = Regexp.last_match[:inner_type]
249
+ value.map { |v| _deserialize(inner_type, v) }
250
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
251
+ k_type = Regexp.last_match[:k_type]
252
+ v_type = Regexp.last_match[:v_type]
253
+ {}.tap do |hash|
254
+ value.each do |k, v|
255
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
256
+ end
257
+ end
258
+ else # model
259
+ MailSlurpClient.const_get(type).build_from_hash(value)
260
+ end
261
+ end
262
+
263
+ # Returns the string representation of the object
264
+ # @return [String] String presentation of the object
265
+ def to_s
266
+ to_hash.to_s
267
+ end
268
+
269
+ # to_body is an alias to to_hash (backward compatibility)
270
+ # @return [Hash] Returns the object in the form of hash
271
+ def to_body
272
+ to_hash
273
+ end
274
+
275
+ # Returns the object in the form of hash
276
+ # @return [Hash] Returns the object in the form of hash
277
+ def to_hash
278
+ hash = {}
279
+ self.class.attribute_map.each_pair do |attr, param|
280
+ value = self.send(attr)
281
+ if value.nil?
282
+ is_nullable = self.class.openapi_nullable.include?(attr)
283
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
284
+ end
285
+
286
+ hash[param] = _to_hash(value)
287
+ end
288
+ hash
289
+ end
290
+
291
+ # Outputs non-array value in the form of hash
292
+ # For object, use to_hash. Otherwise, just return the value
293
+ # @param [Object] value Any valid value
294
+ # @return [Hash] Returns the value in the form of hash
295
+ def _to_hash(value)
296
+ if value.is_a?(Array)
297
+ value.compact.map { |v| _to_hash(v) }
298
+ elsif value.is_a?(Hash)
299
+ {}.tap do |hash|
300
+ value.each { |k, v| hash[k] = _to_hash(v) }
301
+ end
302
+ elsif value.respond_to? :to_hash
303
+ value.to_hash
304
+ else
305
+ value
306
+ end
307
+ end
308
+ end
309
+ end