mailslurp_client 15.8.1 → 15.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mailslurp_client/api/attachment_controller_api.rb +4 -4
  3. data/lib/mailslurp_client/api/email_controller_api.rb +68 -3
  4. data/lib/mailslurp_client/api/form_controller_api.rb +2 -2
  5. data/lib/mailslurp_client/api/inbox_controller_api.rb +75 -0
  6. data/lib/mailslurp_client/api/missed_email_controller_api.rb +56 -0
  7. data/lib/mailslurp_client/api/phone_controller_api.rb +487 -0
  8. data/lib/mailslurp_client/api/sent_emails_controller_api.rb +73 -0
  9. data/lib/mailslurp_client/api/sms_controller_api.rb +286 -0
  10. data/lib/mailslurp_client/api/wait_for_controller_api.rb +64 -0
  11. data/lib/mailslurp_client/api/webhook_controller_api.rb +2 -2
  12. data/lib/mailslurp_client/configuration.rb +2 -2
  13. data/lib/mailslurp_client/models/abstract_webhook_payload.rb +2 -2
  14. data/lib/mailslurp_client/models/alias_projection.rb +31 -31
  15. data/lib/mailslurp_client/models/attachment_entity.rb +10 -1
  16. data/lib/mailslurp_client/models/attachment_projection.rb +14 -14
  17. data/lib/mailslurp_client/models/contact_projection.rb +18 -13
  18. data/lib/mailslurp_client/models/create_emergency_address_options.rb +324 -0
  19. data/lib/mailslurp_client/models/create_webhook_options.rb +3 -3
  20. data/lib/mailslurp_client/models/email_html_dto.rb +215 -0
  21. data/lib/mailslurp_client/models/email_preview.rb +5 -0
  22. data/lib/mailslurp_client/models/email_projection.rb +20 -10
  23. data/lib/mailslurp_client/models/emergency_address.rb +408 -0
  24. data/lib/mailslurp_client/models/emergency_address_dto.rb +273 -0
  25. data/lib/mailslurp_client/models/empty_response_dto.rb +206 -0
  26. data/lib/mailslurp_client/models/expired_inbox_record_projection.rb +15 -15
  27. data/lib/mailslurp_client/models/inbox_preview.rb +5 -0
  28. data/lib/mailslurp_client/models/missed_email.rb +37 -1
  29. data/lib/mailslurp_client/models/organization_inbox_projection.rb +5 -0
  30. data/lib/mailslurp_client/models/page_alias.rb +19 -19
  31. data/lib/mailslurp_client/models/page_attachment_entity.rb +19 -19
  32. data/lib/mailslurp_client/models/page_bounced_email.rb +19 -19
  33. data/lib/mailslurp_client/models/page_bounced_recipients.rb +19 -19
  34. data/lib/mailslurp_client/models/page_contact_projection.rb +19 -19
  35. data/lib/mailslurp_client/models/page_email_preview.rb +19 -19
  36. data/lib/mailslurp_client/models/page_email_projection.rb +19 -19
  37. data/lib/mailslurp_client/models/page_email_validation_request.rb +19 -19
  38. data/lib/mailslurp_client/models/page_expired_inbox_record_projection.rb +19 -19
  39. data/lib/mailslurp_client/models/page_group_projection.rb +19 -19
  40. data/lib/mailslurp_client/models/page_inbox_forwarder_dto.rb +19 -19
  41. data/lib/mailslurp_client/models/page_inbox_projection.rb +19 -19
  42. data/lib/mailslurp_client/models/page_inbox_ruleset_dto.rb +19 -19
  43. data/lib/mailslurp_client/models/page_missed_email_projection.rb +19 -19
  44. data/lib/mailslurp_client/models/page_organization_inbox_projection.rb +19 -19
  45. data/lib/mailslurp_client/models/page_phone_number_projection.rb +308 -0
  46. data/lib/mailslurp_client/models/page_sent_email_with_queue_projection.rb +344 -0
  47. data/lib/mailslurp_client/models/page_sms_projection.rb +308 -0
  48. data/lib/mailslurp_client/models/page_template_projection.rb +19 -19
  49. data/lib/mailslurp_client/models/page_thread_projection.rb +19 -19
  50. data/lib/mailslurp_client/models/page_tracking_pixel_projection.rb +19 -19
  51. data/lib/mailslurp_client/models/page_unknown_missed_email_projection.rb +19 -19
  52. data/lib/mailslurp_client/models/page_webhook_projection.rb +19 -19
  53. data/lib/mailslurp_client/models/page_webhook_result.rb +19 -19
  54. data/lib/mailslurp_client/models/phone_number_dto.rb +347 -0
  55. data/lib/mailslurp_client/models/phone_number_projection.rb +302 -0
  56. data/lib/mailslurp_client/models/phone_plan_dto.rb +287 -0
  57. data/lib/mailslurp_client/models/send_with_queue_result.rb +318 -0
  58. data/lib/mailslurp_client/models/sent_email_projection.rb +32 -27
  59. data/lib/mailslurp_client/models/sms_match_option.rb +289 -0
  60. data/lib/mailslurp_client/models/sms_message.rb +318 -0
  61. data/lib/mailslurp_client/models/sms_preview.rb +267 -0
  62. data/lib/mailslurp_client/models/sms_projection.rb +282 -0
  63. data/lib/mailslurp_client/models/template_projection.rb +18 -18
  64. data/lib/mailslurp_client/models/thread_projection.rb +36 -36
  65. data/lib/mailslurp_client/models/tracking_pixel_projection.rb +10 -10
  66. data/lib/mailslurp_client/models/wait_for_sms_conditions.rb +371 -0
  67. data/lib/mailslurp_client/models/webhook_bounce_payload.rb +2 -2
  68. data/lib/mailslurp_client/models/webhook_bounce_recipient_payload.rb +2 -2
  69. data/lib/mailslurp_client/models/webhook_dto.rb +3 -3
  70. data/lib/mailslurp_client/models/webhook_email_opened_payload.rb +2 -2
  71. data/lib/mailslurp_client/models/webhook_email_read_payload.rb +2 -2
  72. data/lib/mailslurp_client/models/webhook_new_attachment_payload.rb +2 -2
  73. data/lib/mailslurp_client/models/webhook_new_contact_payload.rb +7 -2
  74. data/lib/mailslurp_client/models/webhook_new_email_payload.rb +2 -2
  75. data/lib/mailslurp_client/models/webhook_projection.rb +2 -2
  76. data/lib/mailslurp_client/models/webhook_result_dto.rb +7 -2
  77. data/lib/mailslurp_client/version.rb +1 -1
  78. data/lib/mailslurp_client.rb +19 -0
  79. metadata +21 -2
@@ -0,0 +1,302 @@
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
+ # Phone number projection
17
+ class PhoneNumberProjection
18
+ attr_accessor :id
19
+
20
+ attr_accessor :user_id
21
+
22
+ attr_accessor :phone_number
23
+
24
+ attr_accessor :phone_country
25
+
26
+ attr_accessor :created_at
27
+
28
+ class EnumAttributeValidator
29
+ attr_reader :datatype
30
+ attr_reader :allowable_values
31
+
32
+ def initialize(datatype, allowable_values)
33
+ @allowable_values = allowable_values.map do |value|
34
+ case datatype.to_s
35
+ when /Integer/i
36
+ value.to_i
37
+ when /Float/i
38
+ value.to_f
39
+ else
40
+ value
41
+ end
42
+ end
43
+ end
44
+
45
+ def valid?(value)
46
+ !value || allowable_values.include?(value)
47
+ end
48
+ end
49
+
50
+ # Attribute mapping from ruby-style variable name to JSON key.
51
+ def self.attribute_map
52
+ {
53
+ :'id' => :'id',
54
+ :'user_id' => :'userId',
55
+ :'phone_number' => :'phoneNumber',
56
+ :'phone_country' => :'phoneCountry',
57
+ :'created_at' => :'createdAt'
58
+ }
59
+ end
60
+
61
+ # Attribute type mapping.
62
+ def self.openapi_types
63
+ {
64
+ :'id' => :'String',
65
+ :'user_id' => :'String',
66
+ :'phone_number' => :'String',
67
+ :'phone_country' => :'String',
68
+ :'created_at' => :'DateTime'
69
+ }
70
+ end
71
+
72
+ # List of attributes with nullable: true
73
+ def self.openapi_nullable
74
+ Set.new([
75
+ ])
76
+ end
77
+
78
+ # Initializes the object
79
+ # @param [Hash] attributes Model attributes in the form of hash
80
+ def initialize(attributes = {})
81
+ if (!attributes.is_a?(Hash))
82
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::PhoneNumberProjection` initialize method"
83
+ end
84
+
85
+ # check to see if the attribute exists and convert string to symbol for hash key
86
+ attributes = attributes.each_with_object({}) { |(k, v), h|
87
+ if (!self.class.attribute_map.key?(k.to_sym))
88
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::PhoneNumberProjection`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
89
+ end
90
+ h[k.to_sym] = v
91
+ }
92
+
93
+ if attributes.key?(:'id')
94
+ self.id = attributes[:'id']
95
+ end
96
+
97
+ if attributes.key?(:'user_id')
98
+ self.user_id = attributes[:'user_id']
99
+ end
100
+
101
+ if attributes.key?(:'phone_number')
102
+ self.phone_number = attributes[:'phone_number']
103
+ end
104
+
105
+ if attributes.key?(:'phone_country')
106
+ self.phone_country = attributes[:'phone_country']
107
+ end
108
+
109
+ if attributes.key?(:'created_at')
110
+ self.created_at = attributes[:'created_at']
111
+ end
112
+ end
113
+
114
+ # Show invalid properties with the reasons. Usually used together with valid?
115
+ # @return Array for valid properties with the reasons
116
+ def list_invalid_properties
117
+ invalid_properties = Array.new
118
+ if @id.nil?
119
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
120
+ end
121
+
122
+ if @user_id.nil?
123
+ invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
124
+ end
125
+
126
+ if @phone_number.nil?
127
+ invalid_properties.push('invalid value for "phone_number", phone_number cannot be nil.')
128
+ end
129
+
130
+ if @phone_country.nil?
131
+ invalid_properties.push('invalid value for "phone_country", phone_country cannot be nil.')
132
+ end
133
+
134
+ if @created_at.nil?
135
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
136
+ end
137
+
138
+ invalid_properties
139
+ end
140
+
141
+ # Check to see if the all the properties in the model are valid
142
+ # @return true if the model is valid
143
+ def valid?
144
+ return false if @id.nil?
145
+ return false if @user_id.nil?
146
+ return false if @phone_number.nil?
147
+ return false if @phone_country.nil?
148
+ phone_country_validator = EnumAttributeValidator.new('String', ["US", "GB"])
149
+ return false unless phone_country_validator.valid?(@phone_country)
150
+ return false if @created_at.nil?
151
+ true
152
+ end
153
+
154
+ # Custom attribute writer method checking allowed values (enum).
155
+ # @param [Object] phone_country Object to be assigned
156
+ def phone_country=(phone_country)
157
+ validator = EnumAttributeValidator.new('String', ["US", "GB"])
158
+ unless validator.valid?(phone_country)
159
+ fail ArgumentError, "invalid value for \"phone_country\", must be one of #{validator.allowable_values}."
160
+ end
161
+ @phone_country = phone_country
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
+ id == o.id &&
170
+ user_id == o.user_id &&
171
+ phone_number == o.phone_number &&
172
+ phone_country == o.phone_country &&
173
+ created_at == o.created_at
174
+ end
175
+
176
+ # @see the `==` method
177
+ # @param [Object] Object to be compared
178
+ def eql?(o)
179
+ self == o
180
+ end
181
+
182
+ # Calculates hash code according to all attributes.
183
+ # @return [Integer] Hash code
184
+ def hash
185
+ [id, user_id, phone_number, phone_country, created_at].hash
186
+ end
187
+
188
+ # Builds the object from hash
189
+ # @param [Hash] attributes Model attributes in the form of hash
190
+ # @return [Object] Returns the model itself
191
+ def self.build_from_hash(attributes)
192
+ new.build_from_hash(attributes)
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 build_from_hash(attributes)
199
+ return nil unless attributes.is_a?(Hash)
200
+ self.class.openapi_types.each_pair do |key, type|
201
+ if type =~ /\AArray<(.*)>/i
202
+ # check to ensure the input is an array given that the attribute
203
+ # is documented as an array but the input is not
204
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
205
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
206
+ end
207
+ elsif !attributes[self.class.attribute_map[key]].nil?
208
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
209
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
210
+ end
211
+
212
+ self
213
+ end
214
+
215
+ # Deserializes the data based on type
216
+ # @param string type Data type
217
+ # @param string value Value to be deserialized
218
+ # @return [Object] Deserialized data
219
+ def _deserialize(type, value)
220
+ case type.to_sym
221
+ when :DateTime
222
+ DateTime.parse(value)
223
+ when :Date
224
+ Date.parse(value)
225
+ when :String
226
+ value.to_s
227
+ when :Integer
228
+ value.to_i
229
+ when :Float
230
+ value.to_f
231
+ when :Boolean
232
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
233
+ true
234
+ else
235
+ false
236
+ end
237
+ when :Object
238
+ # generic object (usually a Hash), return directly
239
+ value
240
+ when /\AArray<(?<inner_type>.+)>\z/
241
+ inner_type = Regexp.last_match[:inner_type]
242
+ value.map { |v| _deserialize(inner_type, v) }
243
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
244
+ k_type = Regexp.last_match[:k_type]
245
+ v_type = Regexp.last_match[:v_type]
246
+ {}.tap do |hash|
247
+ value.each do |k, v|
248
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
249
+ end
250
+ end
251
+ else # model
252
+ MailSlurpClient.const_get(type).build_from_hash(value)
253
+ end
254
+ end
255
+
256
+ # Returns the string representation of the object
257
+ # @return [String] String presentation of the object
258
+ def to_s
259
+ to_hash.to_s
260
+ end
261
+
262
+ # to_body is an alias to to_hash (backward compatibility)
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_body
265
+ to_hash
266
+ end
267
+
268
+ # Returns the object in the form of hash
269
+ # @return [Hash] Returns the object in the form of hash
270
+ def to_hash
271
+ hash = {}
272
+ self.class.attribute_map.each_pair do |attr, param|
273
+ value = self.send(attr)
274
+ if value.nil?
275
+ is_nullable = self.class.openapi_nullable.include?(attr)
276
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
277
+ end
278
+
279
+ hash[param] = _to_hash(value)
280
+ end
281
+ hash
282
+ end
283
+
284
+ # Outputs non-array value in the form of hash
285
+ # For object, use to_hash. Otherwise, just return the value
286
+ # @param [Object] value Any valid value
287
+ # @return [Hash] Returns the value in the form of hash
288
+ def _to_hash(value)
289
+ if value.is_a?(Array)
290
+ value.compact.map { |v| _to_hash(v) }
291
+ elsif value.is_a?(Hash)
292
+ {}.tap do |hash|
293
+ value.each { |k, v| hash[k] = _to_hash(v) }
294
+ end
295
+ elsif value.respond_to? :to_hash
296
+ value.to_hash
297
+ else
298
+ value
299
+ end
300
+ end
301
+ end
302
+ end
@@ -0,0 +1,287 @@
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 PhonePlanDto
17
+ attr_accessor :id
18
+
19
+ attr_accessor :user_id
20
+
21
+ attr_accessor :phone_country
22
+
23
+ attr_accessor :created_at
24
+
25
+ class EnumAttributeValidator
26
+ attr_reader :datatype
27
+ attr_reader :allowable_values
28
+
29
+ def initialize(datatype, allowable_values)
30
+ @allowable_values = allowable_values.map do |value|
31
+ case datatype.to_s
32
+ when /Integer/i
33
+ value.to_i
34
+ when /Float/i
35
+ value.to_f
36
+ else
37
+ value
38
+ end
39
+ end
40
+ end
41
+
42
+ def valid?(value)
43
+ !value || allowable_values.include?(value)
44
+ end
45
+ end
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ :'id' => :'id',
51
+ :'user_id' => :'userId',
52
+ :'phone_country' => :'phoneCountry',
53
+ :'created_at' => :'createdAt'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'id' => :'String',
61
+ :'user_id' => :'String',
62
+ :'phone_country' => :'String',
63
+ :'created_at' => :'DateTime'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
73
+ # Initializes the object
74
+ # @param [Hash] attributes Model attributes in the form of hash
75
+ def initialize(attributes = {})
76
+ if (!attributes.is_a?(Hash))
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::PhonePlanDto` initialize method"
78
+ end
79
+
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h|
82
+ if (!self.class.attribute_map.key?(k.to_sym))
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::PhonePlanDto`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
84
+ end
85
+ h[k.to_sym] = v
86
+ }
87
+
88
+ if attributes.key?(:'id')
89
+ self.id = attributes[:'id']
90
+ end
91
+
92
+ if attributes.key?(:'user_id')
93
+ self.user_id = attributes[:'user_id']
94
+ end
95
+
96
+ if attributes.key?(:'phone_country')
97
+ self.phone_country = attributes[:'phone_country']
98
+ end
99
+
100
+ if attributes.key?(:'created_at')
101
+ self.created_at = attributes[:'created_at']
102
+ end
103
+ end
104
+
105
+ # Show invalid properties with the reasons. Usually used together with valid?
106
+ # @return Array for valid properties with the reasons
107
+ def list_invalid_properties
108
+ invalid_properties = Array.new
109
+ if @id.nil?
110
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
111
+ end
112
+
113
+ if @user_id.nil?
114
+ invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
115
+ end
116
+
117
+ if @phone_country.nil?
118
+ invalid_properties.push('invalid value for "phone_country", phone_country cannot be nil.')
119
+ end
120
+
121
+ if @created_at.nil?
122
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
123
+ end
124
+
125
+ invalid_properties
126
+ end
127
+
128
+ # Check to see if the all the properties in the model are valid
129
+ # @return true if the model is valid
130
+ def valid?
131
+ return false if @id.nil?
132
+ return false if @user_id.nil?
133
+ return false if @phone_country.nil?
134
+ phone_country_validator = EnumAttributeValidator.new('String', ["US", "GB"])
135
+ return false unless phone_country_validator.valid?(@phone_country)
136
+ return false if @created_at.nil?
137
+ true
138
+ end
139
+
140
+ # Custom attribute writer method checking allowed values (enum).
141
+ # @param [Object] phone_country Object to be assigned
142
+ def phone_country=(phone_country)
143
+ validator = EnumAttributeValidator.new('String', ["US", "GB"])
144
+ unless validator.valid?(phone_country)
145
+ fail ArgumentError, "invalid value for \"phone_country\", must be one of #{validator.allowable_values}."
146
+ end
147
+ @phone_country = phone_country
148
+ end
149
+
150
+ # Checks equality by comparing each attribute.
151
+ # @param [Object] Object to be compared
152
+ def ==(o)
153
+ return true if self.equal?(o)
154
+ self.class == o.class &&
155
+ id == o.id &&
156
+ user_id == o.user_id &&
157
+ phone_country == o.phone_country &&
158
+ created_at == o.created_at
159
+ end
160
+
161
+ # @see the `==` method
162
+ # @param [Object] Object to be compared
163
+ def eql?(o)
164
+ self == o
165
+ end
166
+
167
+ # Calculates hash code according to all attributes.
168
+ # @return [Integer] Hash code
169
+ def hash
170
+ [id, user_id, phone_country, created_at].hash
171
+ end
172
+
173
+ # Builds the object from hash
174
+ # @param [Hash] attributes Model attributes in the form of hash
175
+ # @return [Object] Returns the model itself
176
+ def self.build_from_hash(attributes)
177
+ new.build_from_hash(attributes)
178
+ end
179
+
180
+ # Builds the object from hash
181
+ # @param [Hash] attributes Model attributes in the form of hash
182
+ # @return [Object] Returns the model itself
183
+ def build_from_hash(attributes)
184
+ return nil unless attributes.is_a?(Hash)
185
+ self.class.openapi_types.each_pair do |key, type|
186
+ if type =~ /\AArray<(.*)>/i
187
+ # check to ensure the input is an array given that the attribute
188
+ # is documented as an array but the input is not
189
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
190
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
191
+ end
192
+ elsif !attributes[self.class.attribute_map[key]].nil?
193
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
194
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
195
+ end
196
+
197
+ self
198
+ end
199
+
200
+ # Deserializes the data based on type
201
+ # @param string type Data type
202
+ # @param string value Value to be deserialized
203
+ # @return [Object] Deserialized data
204
+ def _deserialize(type, value)
205
+ case type.to_sym
206
+ when :DateTime
207
+ DateTime.parse(value)
208
+ when :Date
209
+ Date.parse(value)
210
+ when :String
211
+ value.to_s
212
+ when :Integer
213
+ value.to_i
214
+ when :Float
215
+ value.to_f
216
+ when :Boolean
217
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
218
+ true
219
+ else
220
+ false
221
+ end
222
+ when :Object
223
+ # generic object (usually a Hash), return directly
224
+ value
225
+ when /\AArray<(?<inner_type>.+)>\z/
226
+ inner_type = Regexp.last_match[:inner_type]
227
+ value.map { |v| _deserialize(inner_type, v) }
228
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
229
+ k_type = Regexp.last_match[:k_type]
230
+ v_type = Regexp.last_match[:v_type]
231
+ {}.tap do |hash|
232
+ value.each do |k, v|
233
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
234
+ end
235
+ end
236
+ else # model
237
+ MailSlurpClient.const_get(type).build_from_hash(value)
238
+ end
239
+ end
240
+
241
+ # Returns the string representation of the object
242
+ # @return [String] String presentation of the object
243
+ def to_s
244
+ to_hash.to_s
245
+ end
246
+
247
+ # to_body is an alias to to_hash (backward compatibility)
248
+ # @return [Hash] Returns the object in the form of hash
249
+ def to_body
250
+ to_hash
251
+ end
252
+
253
+ # Returns the object in the form of hash
254
+ # @return [Hash] Returns the object in the form of hash
255
+ def to_hash
256
+ hash = {}
257
+ self.class.attribute_map.each_pair do |attr, param|
258
+ value = self.send(attr)
259
+ if value.nil?
260
+ is_nullable = self.class.openapi_nullable.include?(attr)
261
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
262
+ end
263
+
264
+ hash[param] = _to_hash(value)
265
+ end
266
+ hash
267
+ end
268
+
269
+ # Outputs non-array value in the form of hash
270
+ # For object, use to_hash. Otherwise, just return the value
271
+ # @param [Object] value Any valid value
272
+ # @return [Hash] Returns the value in the form of hash
273
+ def _to_hash(value)
274
+ if value.is_a?(Array)
275
+ value.compact.map { |v| _to_hash(v) }
276
+ elsif value.is_a?(Hash)
277
+ {}.tap do |hash|
278
+ value.each { |k, v| hash[k] = _to_hash(v) }
279
+ end
280
+ elsif value.respond_to? :to_hash
281
+ value.to_hash
282
+ else
283
+ value
284
+ end
285
+ end
286
+ end
287
+ end