mailslurp_client 12.5.0 → 12.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mailslurp_client.rb +17 -2
  3. data/lib/mailslurp_client/api/contact_controller_api.rb +4 -4
  4. data/lib/mailslurp_client/api/email_controller_api.rb +71 -5
  5. data/lib/mailslurp_client/api/group_controller_api.rb +4 -4
  6. data/lib/mailslurp_client/api/inbox_controller_api.rb +107 -22
  7. data/lib/mailslurp_client/api/inbox_forwarder_controller_api.rb +548 -0
  8. data/lib/mailslurp_client/api/inbox_ruleset_controller_api.rb +211 -3
  9. data/lib/mailslurp_client/api/missed_email_controller_api.rb +75 -7
  10. data/lib/mailslurp_client/api/sent_emails_controller_api.rb +150 -4
  11. data/lib/mailslurp_client/api/template_controller_api.rb +4 -4
  12. data/lib/mailslurp_client/api/tracking_controller_api.rb +218 -0
  13. data/lib/mailslurp_client/api/wait_for_controller_api.rb +2 -2
  14. data/lib/mailslurp_client/api/webhook_controller_api.rb +55 -1
  15. data/lib/mailslurp_client/models/abstract_webhook_payload.rb +3 -3
  16. data/lib/mailslurp_client/models/create_inbox_forwarder_options.rb +275 -0
  17. data/lib/mailslurp_client/models/create_inbox_ruleset_options.rb +4 -4
  18. data/lib/mailslurp_client/models/create_tracking_pixel_options.rb +215 -0
  19. data/lib/mailslurp_client/models/create_webhook_options.rb +3 -3
  20. data/lib/mailslurp_client/models/domain_preview.rb +66 -4
  21. data/lib/mailslurp_client/models/email.rb +11 -1
  22. data/lib/mailslurp_client/models/email_projection.rb +10 -1
  23. data/lib/mailslurp_client/models/{inbox_ruleset_projection.rb → inbox_forwarder_dto.rb} +55 -78
  24. data/lib/mailslurp_client/models/inbox_forwarder_test_options.rb +211 -0
  25. data/lib/mailslurp_client/models/inbox_forwarder_test_result.rb +227 -0
  26. data/lib/mailslurp_client/models/inbox_ruleset_dto.rb +17 -3
  27. data/lib/mailslurp_client/models/inbox_ruleset_test_options.rb +211 -0
  28. data/lib/mailslurp_client/models/inbox_ruleset_test_result.rb +223 -0
  29. data/lib/mailslurp_client/models/page_inbox_forwarder_dto.rb +299 -0
  30. data/lib/mailslurp_client/models/{page_inbox_ruleset_projection.rb → page_inbox_ruleset_dto.rb} +4 -4
  31. data/lib/mailslurp_client/models/page_tracking_pixel_projection.rb +299 -0
  32. data/lib/mailslurp_client/models/send_email_options.rb +11 -1
  33. data/lib/mailslurp_client/models/sent_email_dto.rb +12 -1
  34. data/lib/mailslurp_client/models/test_new_inbox_forwarder_options.rb +225 -0
  35. data/lib/mailslurp_client/models/test_new_inbox_ruleset_options.rb +225 -0
  36. data/lib/mailslurp_client/models/tracking_pixel_dto.rb +303 -0
  37. data/lib/mailslurp_client/models/tracking_pixel_projection.rb +289 -0
  38. data/lib/mailslurp_client/models/webhook_dto.rb +2 -2
  39. data/lib/mailslurp_client/models/webhook_email_opened_payload.rb +322 -0
  40. data/lib/mailslurp_client/models/webhook_new_attachment_payload.rb +2 -2
  41. data/lib/mailslurp_client/models/webhook_new_contact_payload.rb +2 -2
  42. data/lib/mailslurp_client/models/webhook_new_email_payload.rb +2 -2
  43. data/lib/mailslurp_client/models/webhook_result_entity.rb +2 -2
  44. data/lib/mailslurp_client/version.rb +1 -1
  45. metadata +19 -4
@@ -0,0 +1,289 @@
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
+ class TrackingPixelProjection
17
+ attr_accessor :created_at
18
+
19
+ attr_accessor :id
20
+
21
+ attr_accessor :inbox_id
22
+
23
+ attr_accessor :name
24
+
25
+ attr_accessor :recipient
26
+
27
+ attr_accessor :seen
28
+
29
+ attr_accessor :seen_at
30
+
31
+ attr_accessor :user_id
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'created_at' => :'createdAt',
37
+ :'id' => :'id',
38
+ :'inbox_id' => :'inboxId',
39
+ :'name' => :'name',
40
+ :'recipient' => :'recipient',
41
+ :'seen' => :'seen',
42
+ :'seen_at' => :'seenAt',
43
+ :'user_id' => :'userId'
44
+ }
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'created_at' => :'DateTime',
51
+ :'id' => :'String',
52
+ :'inbox_id' => :'String',
53
+ :'name' => :'String',
54
+ :'recipient' => :'String',
55
+ :'seen' => :'Boolean',
56
+ :'seen_at' => :'DateTime',
57
+ :'user_id' => :'String'
58
+ }
59
+ end
60
+
61
+ # List of attributes with nullable: true
62
+ def self.openapi_nullable
63
+ Set.new([
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::TrackingPixelProjection` 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::TrackingPixelProjection`. 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?(:'created_at')
83
+ self.created_at = attributes[:'created_at']
84
+ end
85
+
86
+ if attributes.key?(:'id')
87
+ self.id = attributes[:'id']
88
+ end
89
+
90
+ if attributes.key?(:'inbox_id')
91
+ self.inbox_id = attributes[:'inbox_id']
92
+ end
93
+
94
+ if attributes.key?(:'name')
95
+ self.name = attributes[:'name']
96
+ end
97
+
98
+ if attributes.key?(:'recipient')
99
+ self.recipient = attributes[:'recipient']
100
+ end
101
+
102
+ if attributes.key?(:'seen')
103
+ self.seen = attributes[:'seen']
104
+ end
105
+
106
+ if attributes.key?(:'seen_at')
107
+ self.seen_at = attributes[:'seen_at']
108
+ end
109
+
110
+ if attributes.key?(:'user_id')
111
+ self.user_id = attributes[:'user_id']
112
+ end
113
+ end
114
+
115
+ # Show invalid properties with the reasons. Usually used together with valid?
116
+ # @return Array for valid properties with the reasons
117
+ def list_invalid_properties
118
+ invalid_properties = Array.new
119
+ if @created_at.nil?
120
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
121
+ end
122
+
123
+ if @id.nil?
124
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
125
+ end
126
+
127
+ if @seen.nil?
128
+ invalid_properties.push('invalid value for "seen", seen cannot be nil.')
129
+ end
130
+
131
+ if @user_id.nil?
132
+ invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
133
+ end
134
+
135
+ invalid_properties
136
+ end
137
+
138
+ # Check to see if the all the properties in the model are valid
139
+ # @return true if the model is valid
140
+ def valid?
141
+ return false if @created_at.nil?
142
+ return false if @id.nil?
143
+ return false if @seen.nil?
144
+ return false if @user_id.nil?
145
+ true
146
+ end
147
+
148
+ # Checks equality by comparing each attribute.
149
+ # @param [Object] Object to be compared
150
+ def ==(o)
151
+ return true if self.equal?(o)
152
+ self.class == o.class &&
153
+ created_at == o.created_at &&
154
+ id == o.id &&
155
+ inbox_id == o.inbox_id &&
156
+ name == o.name &&
157
+ recipient == o.recipient &&
158
+ seen == o.seen &&
159
+ seen_at == o.seen_at &&
160
+ user_id == o.user_id
161
+ end
162
+
163
+ # @see the `==` method
164
+ # @param [Object] Object to be compared
165
+ def eql?(o)
166
+ self == o
167
+ end
168
+
169
+ # Calculates hash code according to all attributes.
170
+ # @return [Integer] Hash code
171
+ def hash
172
+ [created_at, id, inbox_id, name, recipient, seen, seen_at, user_id].hash
173
+ end
174
+
175
+ # Builds the object from hash
176
+ # @param [Hash] attributes Model attributes in the form of hash
177
+ # @return [Object] Returns the model itself
178
+ def self.build_from_hash(attributes)
179
+ new.build_from_hash(attributes)
180
+ end
181
+
182
+ # Builds the object from hash
183
+ # @param [Hash] attributes Model attributes in the form of hash
184
+ # @return [Object] Returns the model itself
185
+ def build_from_hash(attributes)
186
+ return nil unless attributes.is_a?(Hash)
187
+ self.class.openapi_types.each_pair do |key, type|
188
+ if type =~ /\AArray<(.*)>/i
189
+ # check to ensure the input is an array given that the attribute
190
+ # is documented as an array but the input is not
191
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
192
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
193
+ end
194
+ elsif !attributes[self.class.attribute_map[key]].nil?
195
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
196
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
197
+ end
198
+
199
+ self
200
+ end
201
+
202
+ # Deserializes the data based on type
203
+ # @param string type Data type
204
+ # @param string value Value to be deserialized
205
+ # @return [Object] Deserialized data
206
+ def _deserialize(type, value)
207
+ case type.to_sym
208
+ when :DateTime
209
+ DateTime.parse(value)
210
+ when :Date
211
+ Date.parse(value)
212
+ when :String
213
+ value.to_s
214
+ when :Integer
215
+ value.to_i
216
+ when :Float
217
+ value.to_f
218
+ when :Boolean
219
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
220
+ true
221
+ else
222
+ false
223
+ end
224
+ when :Object
225
+ # generic object (usually a Hash), return directly
226
+ value
227
+ when /\AArray<(?<inner_type>.+)>\z/
228
+ inner_type = Regexp.last_match[:inner_type]
229
+ value.map { |v| _deserialize(inner_type, v) }
230
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
231
+ k_type = Regexp.last_match[:k_type]
232
+ v_type = Regexp.last_match[:v_type]
233
+ {}.tap do |hash|
234
+ value.each do |k, v|
235
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
236
+ end
237
+ end
238
+ else # model
239
+ MailSlurpClient.const_get(type).build_from_hash(value)
240
+ end
241
+ end
242
+
243
+ # Returns the string representation of the object
244
+ # @return [String] String presentation of the object
245
+ def to_s
246
+ to_hash.to_s
247
+ end
248
+
249
+ # to_body is an alias to to_hash (backward compatibility)
250
+ # @return [Hash] Returns the object in the form of hash
251
+ def to_body
252
+ to_hash
253
+ end
254
+
255
+ # Returns the object in the form of hash
256
+ # @return [Hash] Returns the object in the form of hash
257
+ def to_hash
258
+ hash = {}
259
+ self.class.attribute_map.each_pair do |attr, param|
260
+ value = self.send(attr)
261
+ if value.nil?
262
+ is_nullable = self.class.openapi_nullable.include?(attr)
263
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
264
+ end
265
+
266
+ hash[param] = _to_hash(value)
267
+ end
268
+ hash
269
+ end
270
+
271
+ # Outputs non-array value in the form of hash
272
+ # For object, use to_hash. Otherwise, just return the value
273
+ # @param [Object] value Any valid value
274
+ # @return [Hash] Returns the value in the form of hash
275
+ def _to_hash(value)
276
+ if value.is_a?(Array)
277
+ value.compact.map { |v| _to_hash(v) }
278
+ elsif value.is_a?(Hash)
279
+ {}.tap do |hash|
280
+ value.each { |k, v| hash[k] = _to_hash(v) }
281
+ end
282
+ elsif value.respond_to? :to_hash
283
+ value.to_hash
284
+ else
285
+ value
286
+ end
287
+ end
288
+ end
289
+ end
@@ -182,7 +182,7 @@ module MailSlurpClient
182
182
  # Check to see if the all the properties in the model are valid
183
183
  # @return true if the model is valid
184
184
  def valid?
185
- event_name_validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT"])
185
+ event_name_validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT", "EMAIL_OPENED"])
186
186
  return false unless event_name_validator.valid?(@event_name)
187
187
  method_validator = EnumAttributeValidator.new('String', ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "TRACE"])
188
188
  return false unless method_validator.valid?(@method)
@@ -193,7 +193,7 @@ module MailSlurpClient
193
193
  # Custom attribute writer method checking allowed values (enum).
194
194
  # @param [Object] event_name Object to be assigned
195
195
  def event_name=(event_name)
196
- validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT"])
196
+ validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT", "EMAIL_OPENED"])
197
197
  unless validator.valid?(event_name)
198
198
  fail ArgumentError, "invalid value for \"event_name\", must be one of #{validator.allowable_values}."
199
199
  end
@@ -0,0 +1,322 @@
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
+ # EMAIL_OPENED webhook payload. Sent to your webhook url endpoint via HTTP POST when an email containing a tracking pixel is opened and the pixel image is loaded by a reader.
17
+ class WebhookEmailOpenedPayload
18
+ # Date time of event creation
19
+ attr_accessor :created_at
20
+
21
+ # Name of the event type webhook is being triggered for.
22
+ attr_accessor :event_name
23
+
24
+ # Id of the inbox that received an email
25
+ attr_accessor :inbox_id
26
+
27
+ # Idempotent message ID. Store this ID locally or in a database to prevent message duplication.
28
+ attr_accessor :message_id
29
+
30
+ # ID of the tracking pixel
31
+ attr_accessor :pixel_id
32
+
33
+ # Email address for the recipient of the tracking pixel
34
+ attr_accessor :recipient
35
+
36
+ # ID of sent email
37
+ attr_accessor :sent_email_id
38
+
39
+ # ID of webhook entity being triggered
40
+ attr_accessor :webhook_id
41
+
42
+ # Name of the webhook being triggered
43
+ attr_accessor :webhook_name
44
+
45
+ class EnumAttributeValidator
46
+ attr_reader :datatype
47
+ attr_reader :allowable_values
48
+
49
+ def initialize(datatype, allowable_values)
50
+ @allowable_values = allowable_values.map do |value|
51
+ case datatype.to_s
52
+ when /Integer/i
53
+ value.to_i
54
+ when /Float/i
55
+ value.to_f
56
+ else
57
+ value
58
+ end
59
+ end
60
+ end
61
+
62
+ def valid?(value)
63
+ !value || allowable_values.include?(value)
64
+ end
65
+ end
66
+
67
+ # Attribute mapping from ruby-style variable name to JSON key.
68
+ def self.attribute_map
69
+ {
70
+ :'created_at' => :'createdAt',
71
+ :'event_name' => :'eventName',
72
+ :'inbox_id' => :'inboxId',
73
+ :'message_id' => :'messageId',
74
+ :'pixel_id' => :'pixelId',
75
+ :'recipient' => :'recipient',
76
+ :'sent_email_id' => :'sentEmailId',
77
+ :'webhook_id' => :'webhookId',
78
+ :'webhook_name' => :'webhookName'
79
+ }
80
+ end
81
+
82
+ # Attribute type mapping.
83
+ def self.openapi_types
84
+ {
85
+ :'created_at' => :'DateTime',
86
+ :'event_name' => :'String',
87
+ :'inbox_id' => :'String',
88
+ :'message_id' => :'String',
89
+ :'pixel_id' => :'String',
90
+ :'recipient' => :'String',
91
+ :'sent_email_id' => :'String',
92
+ :'webhook_id' => :'String',
93
+ :'webhook_name' => :'String'
94
+ }
95
+ end
96
+
97
+ # List of attributes with nullable: true
98
+ def self.openapi_nullable
99
+ Set.new([
100
+ ])
101
+ end
102
+
103
+ # Initializes the object
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ def initialize(attributes = {})
106
+ if (!attributes.is_a?(Hash))
107
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::WebhookEmailOpenedPayload` initialize method"
108
+ end
109
+
110
+ # check to see if the attribute exists and convert string to symbol for hash key
111
+ attributes = attributes.each_with_object({}) { |(k, v), h|
112
+ if (!self.class.attribute_map.key?(k.to_sym))
113
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::WebhookEmailOpenedPayload`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
114
+ end
115
+ h[k.to_sym] = v
116
+ }
117
+
118
+ if attributes.key?(:'created_at')
119
+ self.created_at = attributes[:'created_at']
120
+ end
121
+
122
+ if attributes.key?(:'event_name')
123
+ self.event_name = attributes[:'event_name']
124
+ end
125
+
126
+ if attributes.key?(:'inbox_id')
127
+ self.inbox_id = attributes[:'inbox_id']
128
+ end
129
+
130
+ if attributes.key?(:'message_id')
131
+ self.message_id = attributes[:'message_id']
132
+ end
133
+
134
+ if attributes.key?(:'pixel_id')
135
+ self.pixel_id = attributes[:'pixel_id']
136
+ end
137
+
138
+ if attributes.key?(:'recipient')
139
+ self.recipient = attributes[:'recipient']
140
+ end
141
+
142
+ if attributes.key?(:'sent_email_id')
143
+ self.sent_email_id = attributes[:'sent_email_id']
144
+ end
145
+
146
+ if attributes.key?(:'webhook_id')
147
+ self.webhook_id = attributes[:'webhook_id']
148
+ end
149
+
150
+ if attributes.key?(:'webhook_name')
151
+ self.webhook_name = attributes[:'webhook_name']
152
+ end
153
+ end
154
+
155
+ # Show invalid properties with the reasons. Usually used together with valid?
156
+ # @return Array for valid properties with the reasons
157
+ def list_invalid_properties
158
+ invalid_properties = Array.new
159
+ invalid_properties
160
+ end
161
+
162
+ # Check to see if the all the properties in the model are valid
163
+ # @return true if the model is valid
164
+ def valid?
165
+ event_name_validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT", "EMAIL_OPENED"])
166
+ return false unless event_name_validator.valid?(@event_name)
167
+ true
168
+ end
169
+
170
+ # Custom attribute writer method checking allowed values (enum).
171
+ # @param [Object] event_name Object to be assigned
172
+ def event_name=(event_name)
173
+ validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT", "EMAIL_OPENED"])
174
+ unless validator.valid?(event_name)
175
+ fail ArgumentError, "invalid value for \"event_name\", must be one of #{validator.allowable_values}."
176
+ end
177
+ @event_name = event_name
178
+ end
179
+
180
+ # Checks equality by comparing each attribute.
181
+ # @param [Object] Object to be compared
182
+ def ==(o)
183
+ return true if self.equal?(o)
184
+ self.class == o.class &&
185
+ created_at == o.created_at &&
186
+ event_name == o.event_name &&
187
+ inbox_id == o.inbox_id &&
188
+ message_id == o.message_id &&
189
+ pixel_id == o.pixel_id &&
190
+ recipient == o.recipient &&
191
+ sent_email_id == o.sent_email_id &&
192
+ webhook_id == o.webhook_id &&
193
+ webhook_name == o.webhook_name
194
+ end
195
+
196
+ # @see the `==` method
197
+ # @param [Object] Object to be compared
198
+ def eql?(o)
199
+ self == o
200
+ end
201
+
202
+ # Calculates hash code according to all attributes.
203
+ # @return [Integer] Hash code
204
+ def hash
205
+ [created_at, event_name, inbox_id, message_id, pixel_id, recipient, sent_email_id, webhook_id, webhook_name].hash
206
+ end
207
+
208
+ # Builds the object from hash
209
+ # @param [Hash] attributes Model attributes in the form of hash
210
+ # @return [Object] Returns the model itself
211
+ def self.build_from_hash(attributes)
212
+ new.build_from_hash(attributes)
213
+ end
214
+
215
+ # Builds the object from hash
216
+ # @param [Hash] attributes Model attributes in the form of hash
217
+ # @return [Object] Returns the model itself
218
+ def build_from_hash(attributes)
219
+ return nil unless attributes.is_a?(Hash)
220
+ self.class.openapi_types.each_pair do |key, type|
221
+ if type =~ /\AArray<(.*)>/i
222
+ # check to ensure the input is an array given that the attribute
223
+ # is documented as an array but the input is not
224
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
225
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
226
+ end
227
+ elsif !attributes[self.class.attribute_map[key]].nil?
228
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
229
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
230
+ end
231
+
232
+ self
233
+ end
234
+
235
+ # Deserializes the data based on type
236
+ # @param string type Data type
237
+ # @param string value Value to be deserialized
238
+ # @return [Object] Deserialized data
239
+ def _deserialize(type, value)
240
+ case type.to_sym
241
+ when :DateTime
242
+ DateTime.parse(value)
243
+ when :Date
244
+ Date.parse(value)
245
+ when :String
246
+ value.to_s
247
+ when :Integer
248
+ value.to_i
249
+ when :Float
250
+ value.to_f
251
+ when :Boolean
252
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
253
+ true
254
+ else
255
+ false
256
+ end
257
+ when :Object
258
+ # generic object (usually a Hash), return directly
259
+ value
260
+ when /\AArray<(?<inner_type>.+)>\z/
261
+ inner_type = Regexp.last_match[:inner_type]
262
+ value.map { |v| _deserialize(inner_type, v) }
263
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
264
+ k_type = Regexp.last_match[:k_type]
265
+ v_type = Regexp.last_match[:v_type]
266
+ {}.tap do |hash|
267
+ value.each do |k, v|
268
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
269
+ end
270
+ end
271
+ else # model
272
+ MailSlurpClient.const_get(type).build_from_hash(value)
273
+ end
274
+ end
275
+
276
+ # Returns the string representation of the object
277
+ # @return [String] String presentation of the object
278
+ def to_s
279
+ to_hash.to_s
280
+ end
281
+
282
+ # to_body is an alias to to_hash (backward compatibility)
283
+ # @return [Hash] Returns the object in the form of hash
284
+ def to_body
285
+ to_hash
286
+ end
287
+
288
+ # Returns the object in the form of hash
289
+ # @return [Hash] Returns the object in the form of hash
290
+ def to_hash
291
+ hash = {}
292
+ self.class.attribute_map.each_pair do |attr, param|
293
+ value = self.send(attr)
294
+ if value.nil?
295
+ is_nullable = self.class.openapi_nullable.include?(attr)
296
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
297
+ end
298
+
299
+ hash[param] = _to_hash(value)
300
+ end
301
+ hash
302
+ end
303
+
304
+ # Outputs non-array value in the form of hash
305
+ # For object, use to_hash. Otherwise, just return the value
306
+ # @param [Object] value Any valid value
307
+ # @return [Hash] Returns the value in the form of hash
308
+ def _to_hash(value)
309
+ if value.is_a?(Array)
310
+ value.compact.map { |v| _to_hash(v) }
311
+ elsif value.is_a?(Hash)
312
+ {}.tap do |hash|
313
+ value.each { |k, v| hash[k] = _to_hash(v) }
314
+ end
315
+ elsif value.respond_to? :to_hash
316
+ value.to_hash
317
+ else
318
+ value
319
+ end
320
+ end
321
+ end
322
+ end