mailslurp_client 12.1.1 → 12.1.26

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,14 +13,18 @@ OpenAPI Generator version: 4.3.1
13
13
  require 'date'
14
14
 
15
15
  module MailSlurpClient
16
- # Optional filter for matching emails based on fields. For instance filter results to only include emails whose `SUBJECT` value does `CONTAIN` given match value. An example payload would be `{ matches: [{ field: 'SUBJECT', should: 'CONTAIN', value: 'Welcome' }] }`. If you wish to extract regex matches inside the email content see the `getEmailContentMatch` method in the EmailController.
16
+ # Optional filter for matching emails based on fields. For instance filter results to only include emails whose `SUBJECT` value does `CONTAIN` given match value. An example payload would be `{ matches: [{ field: 'SUBJECT', should: 'CONTAIN', value: 'Welcome' }] }`. You can also pass conditions such as `HAS_ATTACHMENT`. If you wish to extract regex matches inside the email content see the `getEmailContentMatch` method in the EmailController.
17
17
  class MatchOptions
18
- # 1 or more match options. Options are additive so if one does not match the email is excluded from results
18
+ # Zero or more conditions such as `{ condition: 'HAS_ATTACHMENTS', value: 'TRUE' }`. Note the values are the strings `TRUE|FALSE` not booleans.
19
+ attr_accessor :conditions
20
+
21
+ # Zero or more match options such as `{ field: 'SUBJECT', should: 'CONTAIN', value: 'Welcome' }`. Options are additive so if one does not match the email is excluded from results
19
22
  attr_accessor :matches
20
23
 
21
24
  # Attribute mapping from ruby-style variable name to JSON key.
22
25
  def self.attribute_map
23
26
  {
27
+ :'conditions' => :'conditions',
24
28
  :'matches' => :'matches'
25
29
  }
26
30
  end
@@ -28,6 +32,7 @@ module MailSlurpClient
28
32
  # Attribute type mapping.
29
33
  def self.openapi_types
30
34
  {
35
+ :'conditions' => :'Array<ConditionOption>',
31
36
  :'matches' => :'Array<MatchOption>'
32
37
  }
33
38
  end
@@ -53,6 +58,12 @@ module MailSlurpClient
53
58
  h[k.to_sym] = v
54
59
  }
55
60
 
61
+ if attributes.key?(:'conditions')
62
+ if (value = attributes[:'conditions']).is_a?(Array)
63
+ self.conditions = value
64
+ end
65
+ end
66
+
56
67
  if attributes.key?(:'matches')
57
68
  if (value = attributes[:'matches']).is_a?(Array)
58
69
  self.matches = value
@@ -78,6 +89,7 @@ module MailSlurpClient
78
89
  def ==(o)
79
90
  return true if self.equal?(o)
80
91
  self.class == o.class &&
92
+ conditions == o.conditions &&
81
93
  matches == o.matches
82
94
  end
83
95
 
@@ -90,7 +102,7 @@ module MailSlurpClient
90
102
  # Calculates hash code according to all attributes.
91
103
  # @return [Integer] Hash code
92
104
  def hash
93
- [matches].hash
105
+ [conditions, matches].hash
94
106
  end
95
107
 
96
108
  # Builds the object from hash
@@ -15,7 +15,7 @@ require 'date'
15
15
  module MailSlurpClient
16
16
  # Options for sending an email message from an inbox. You must provide one of: `to`, `toGroup`, or `toContacts` to send an email. All other parameters are optional.
17
17
  class SendEmailOptions
18
- # Optional list of attachment IDs to send with this email. You must first upload each attachment separately in order to obtain attachment IDs. This way you can reuse attachments with different emails once uploaded.
18
+ # Optional list of attachment IDs to send with this email. You must first upload each attachment separately via method call or dashboard in order to obtain attachment IDs. This way you can reuse attachments with different emails once uploaded. There are several ways to upload that support `multi-part form`, `base64 file encoding`, and octet stream binary uploads. See the `UploadController` for available methods.
19
19
  attr_accessor :attachments
20
20
 
21
21
  # Optional list of bcc destination email addresses
@@ -30,10 +30,10 @@ module MailSlurpClient
30
30
  # Optional charset
31
31
  attr_accessor :charset
32
32
 
33
- # Optional from address. Email address is RFC 5322 format and may include a display name and email in angle brackets (`my@address.com` or `My inbox <my@address.com>`). If no sender is set the source inbox address will be used for this field. Beware of potential spam penalties when setting this field to an address not used by the inbox. For custom email addresses use a custom domain.
33
+ # Optional from address. Email address is RFC 5322 format and may include a display name and email in angle brackets (`my@address.com` or `My inbox <my@address.com>`). If no sender is set the source inbox address will be used for this field. If you set `useInboxName` to `true` the from field will include the inbox name as a display name: `inbox_name <inbox@address.com>`. For this to work use the name field when creating an inbox. Beware of potential spam penalties when setting the from field to an address not used by the inbox. Your emails may get blocked by services if you impersonate another address. To use a custom email addresses use a custom domain. You can create domains with the DomainController. The domain must be verified in the dashboard before it can be used.
34
34
  attr_accessor :from
35
35
 
36
- # Optional HTML flag (Deprecated: use isHTML instead)
36
+ # Optional HTML flag to indicate that contents is HTML. Set's a `content-type: text/html` for email. (Deprecated: use `isHTML` instead.)
37
37
  attr_accessor :html
38
38
 
39
39
  # Optional HTML flag. If true the `content-type` of the email will be `text/html`. Set to true when sending HTML to ensure proper rending on email clients
@@ -54,7 +54,7 @@ module MailSlurpClient
54
54
  # Optional map of template variables. Will replace moustache syntax variables in subject and body or template with the associated values if found.
55
55
  attr_accessor :template_variables
56
56
 
57
- # List of destination email addresses. Even single recipients must be in array form. Maximum recipients per email depends on your plan. If you need to send many emails try using contacts or contact groups or use a non standard sendStrategy to ensure that spam filters are not triggered (many recipients in one email can affect your spam rating).
57
+ # List of destination email addresses. Each email address must be RFC 5322 format. Even single recipients must be in array form. Maximum recipients per email depends on your plan. If you need to send many emails try using contacts or contact groups or use a non standard sendStrategy to ensure that spam filters are not triggered (many recipients in one email can affect your spam rating). Be cautious when sending emails that your recipients exist. High bounce rates (meaning a high percentage of emails cannot be delivered because an address does not exist) can result in account freezing.
58
58
  attr_accessor :to
59
59
 
60
60
  # Optional list of contact IDs to send email to. Manage your contacts via the API or dashboard. When contacts are used the email is sent to each contact separately so they will not see other recipients.
@@ -63,7 +63,7 @@ module MailSlurpClient
63
63
  # Optional contact group ID to send email to. You can create contacts and contact groups in the API or dashboard and use them for email campaigns. When contact groups are used the email is sent to each contact separately so they will not see other recipients
64
64
  attr_accessor :to_group
65
65
 
66
- # Use name of inbox as sender email address name. Will construct RFC 5322 email address with `Inbox name <inbox@address.com>`
66
+ # Use name of inbox as sender email address name. Will construct RFC 5322 email address with `Inbox name <inbox@address.com>` if the inbox has a name.
67
67
  attr_accessor :use_inbox_name
68
68
 
69
69
  class EnumAttributeValidator
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  require 'date'
14
14
 
15
15
  module MailSlurpClient
16
- # Conditions that a `waitForXEmails` endpoint operates on. The methods wait until given conditions are met or a timeout is reached. If the conditions are met without needing to wait the results will be returned immediately.
16
+ # Conditions that a `waitForXEmails` endpoint operates on. The methods wait until given conditions are met or a timeout is reached. If the conditions are met without needing to wait the results will be returned immediately. Can include `unreadOnly` to ignore already read emails that were returned in an API call or viewing in the dashboard. Can also include matches for emails containing `from`, `subject`, `hasAttachments` etc.
17
17
  class WaitForConditions
18
18
  # Number of results that should match conditions. Either exactly or at least this amount based on the `countType`. If count condition is not met and the timeout has not been reached the `waitFor` method will retry the operation.
19
19
  attr_accessor :count
@@ -0,0 +1,312 @@
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
+ # NEW_ATTACHMENT webhook payload
17
+ class WebhookNewAttachmentPayload
18
+ # ID of attachment. Use the `AttachmentController` to
19
+ attr_accessor :attachment_id
20
+
21
+ # Size of attachment in bytes
22
+ attr_accessor :content_length
23
+
24
+ # Content type of attachment such as 'image/png' or 'application/pdf
25
+ attr_accessor :content_type
26
+
27
+ # Name of the event type webhook is being triggered for.
28
+ attr_accessor :event_name
29
+
30
+ # Idempotent message ID. Store this ID locally or in a database to prevent message duplication.
31
+ attr_accessor :message_id
32
+
33
+ # Filename of the attachment if present
34
+ attr_accessor :name
35
+
36
+ # ID of webhook entity being triggered
37
+ attr_accessor :webhook_id
38
+
39
+ # Name of the webhook being triggered
40
+ attr_accessor :webhook_name
41
+
42
+ class EnumAttributeValidator
43
+ attr_reader :datatype
44
+ attr_reader :allowable_values
45
+
46
+ def initialize(datatype, allowable_values)
47
+ @allowable_values = allowable_values.map do |value|
48
+ case datatype.to_s
49
+ when /Integer/i
50
+ value.to_i
51
+ when /Float/i
52
+ value.to_f
53
+ else
54
+ value
55
+ end
56
+ end
57
+ end
58
+
59
+ def valid?(value)
60
+ !value || allowable_values.include?(value)
61
+ end
62
+ end
63
+
64
+ # Attribute mapping from ruby-style variable name to JSON key.
65
+ def self.attribute_map
66
+ {
67
+ :'attachment_id' => :'attachmentId',
68
+ :'content_length' => :'contentLength',
69
+ :'content_type' => :'contentType',
70
+ :'event_name' => :'eventName',
71
+ :'message_id' => :'messageId',
72
+ :'name' => :'name',
73
+ :'webhook_id' => :'webhookId',
74
+ :'webhook_name' => :'webhookName'
75
+ }
76
+ end
77
+
78
+ # Attribute type mapping.
79
+ def self.openapi_types
80
+ {
81
+ :'attachment_id' => :'String',
82
+ :'content_length' => :'Integer',
83
+ :'content_type' => :'String',
84
+ :'event_name' => :'String',
85
+ :'message_id' => :'String',
86
+ :'name' => :'String',
87
+ :'webhook_id' => :'String',
88
+ :'webhook_name' => :'String'
89
+ }
90
+ end
91
+
92
+ # List of attributes with nullable: true
93
+ def self.openapi_nullable
94
+ Set.new([
95
+ ])
96
+ end
97
+
98
+ # Initializes the object
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ def initialize(attributes = {})
101
+ if (!attributes.is_a?(Hash))
102
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::WebhookNewAttachmentPayload` initialize method"
103
+ end
104
+
105
+ # check to see if the attribute exists and convert string to symbol for hash key
106
+ attributes = attributes.each_with_object({}) { |(k, v), h|
107
+ if (!self.class.attribute_map.key?(k.to_sym))
108
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::WebhookNewAttachmentPayload`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
109
+ end
110
+ h[k.to_sym] = v
111
+ }
112
+
113
+ if attributes.key?(:'attachment_id')
114
+ self.attachment_id = attributes[:'attachment_id']
115
+ end
116
+
117
+ if attributes.key?(:'content_length')
118
+ self.content_length = attributes[:'content_length']
119
+ end
120
+
121
+ if attributes.key?(:'content_type')
122
+ self.content_type = attributes[:'content_type']
123
+ end
124
+
125
+ if attributes.key?(:'event_name')
126
+ self.event_name = attributes[:'event_name']
127
+ end
128
+
129
+ if attributes.key?(:'message_id')
130
+ self.message_id = attributes[:'message_id']
131
+ end
132
+
133
+ if attributes.key?(:'name')
134
+ self.name = attributes[:'name']
135
+ end
136
+
137
+ if attributes.key?(:'webhook_id')
138
+ self.webhook_id = attributes[:'webhook_id']
139
+ end
140
+
141
+ if attributes.key?(:'webhook_name')
142
+ self.webhook_name = attributes[:'webhook_name']
143
+ end
144
+ end
145
+
146
+ # Show invalid properties with the reasons. Usually used together with valid?
147
+ # @return Array for valid properties with the reasons
148
+ def list_invalid_properties
149
+ invalid_properties = Array.new
150
+ invalid_properties
151
+ end
152
+
153
+ # Check to see if the all the properties in the model are valid
154
+ # @return true if the model is valid
155
+ def valid?
156
+ event_name_validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT"])
157
+ return false unless event_name_validator.valid?(@event_name)
158
+ true
159
+ end
160
+
161
+ # Custom attribute writer method checking allowed values (enum).
162
+ # @param [Object] event_name Object to be assigned
163
+ def event_name=(event_name)
164
+ validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT"])
165
+ unless validator.valid?(event_name)
166
+ fail ArgumentError, "invalid value for \"event_name\", must be one of #{validator.allowable_values}."
167
+ end
168
+ @event_name = event_name
169
+ end
170
+
171
+ # Checks equality by comparing each attribute.
172
+ # @param [Object] Object to be compared
173
+ def ==(o)
174
+ return true if self.equal?(o)
175
+ self.class == o.class &&
176
+ attachment_id == o.attachment_id &&
177
+ content_length == o.content_length &&
178
+ content_type == o.content_type &&
179
+ event_name == o.event_name &&
180
+ message_id == o.message_id &&
181
+ name == o.name &&
182
+ webhook_id == o.webhook_id &&
183
+ webhook_name == o.webhook_name
184
+ end
185
+
186
+ # @see the `==` method
187
+ # @param [Object] Object to be compared
188
+ def eql?(o)
189
+ self == o
190
+ end
191
+
192
+ # Calculates hash code according to all attributes.
193
+ # @return [Integer] Hash code
194
+ def hash
195
+ [attachment_id, content_length, content_type, event_name, message_id, name, webhook_id, webhook_name].hash
196
+ end
197
+
198
+ # Builds the object from hash
199
+ # @param [Hash] attributes Model attributes in the form of hash
200
+ # @return [Object] Returns the model itself
201
+ def self.build_from_hash(attributes)
202
+ new.build_from_hash(attributes)
203
+ end
204
+
205
+ # Builds the object from hash
206
+ # @param [Hash] attributes Model attributes in the form of hash
207
+ # @return [Object] Returns the model itself
208
+ def build_from_hash(attributes)
209
+ return nil unless attributes.is_a?(Hash)
210
+ self.class.openapi_types.each_pair do |key, type|
211
+ if type =~ /\AArray<(.*)>/i
212
+ # check to ensure the input is an array given that the attribute
213
+ # is documented as an array but the input is not
214
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
215
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
216
+ end
217
+ elsif !attributes[self.class.attribute_map[key]].nil?
218
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
219
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
220
+ end
221
+
222
+ self
223
+ end
224
+
225
+ # Deserializes the data based on type
226
+ # @param string type Data type
227
+ # @param string value Value to be deserialized
228
+ # @return [Object] Deserialized data
229
+ def _deserialize(type, value)
230
+ case type.to_sym
231
+ when :DateTime
232
+ DateTime.parse(value)
233
+ when :Date
234
+ Date.parse(value)
235
+ when :String
236
+ value.to_s
237
+ when :Integer
238
+ value.to_i
239
+ when :Float
240
+ value.to_f
241
+ when :Boolean
242
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
243
+ true
244
+ else
245
+ false
246
+ end
247
+ when :Object
248
+ # generic object (usually a Hash), return directly
249
+ value
250
+ when /\AArray<(?<inner_type>.+)>\z/
251
+ inner_type = Regexp.last_match[:inner_type]
252
+ value.map { |v| _deserialize(inner_type, v) }
253
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
254
+ k_type = Regexp.last_match[:k_type]
255
+ v_type = Regexp.last_match[:v_type]
256
+ {}.tap do |hash|
257
+ value.each do |k, v|
258
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
259
+ end
260
+ end
261
+ else # model
262
+ MailSlurpClient.const_get(type).build_from_hash(value)
263
+ end
264
+ end
265
+
266
+ # Returns the string representation of the object
267
+ # @return [String] String presentation of the object
268
+ def to_s
269
+ to_hash.to_s
270
+ end
271
+
272
+ # to_body is an alias to to_hash (backward compatibility)
273
+ # @return [Hash] Returns the object in the form of hash
274
+ def to_body
275
+ to_hash
276
+ end
277
+
278
+ # Returns the object in the form of hash
279
+ # @return [Hash] Returns the object in the form of hash
280
+ def to_hash
281
+ hash = {}
282
+ self.class.attribute_map.each_pair do |attr, param|
283
+ value = self.send(attr)
284
+ if value.nil?
285
+ is_nullable = self.class.openapi_nullable.include?(attr)
286
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
287
+ end
288
+
289
+ hash[param] = _to_hash(value)
290
+ end
291
+ hash
292
+ end
293
+
294
+ # Outputs non-array value in the form of hash
295
+ # For object, use to_hash. Otherwise, just return the value
296
+ # @param [Object] value Any valid value
297
+ # @return [Hash] Returns the value in the form of hash
298
+ def _to_hash(value)
299
+ if value.is_a?(Array)
300
+ value.compact.map { |v| _to_hash(v) }
301
+ elsif value.is_a?(Hash)
302
+ {}.tap do |hash|
303
+ value.each { |k, v| hash[k] = _to_hash(v) }
304
+ end
305
+ elsif value.respond_to? :to_hash
306
+ value.to_hash
307
+ else
308
+ value
309
+ end
310
+ end
311
+ end
312
+ end
@@ -0,0 +1,395 @@
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
+ # NEW_CONTACT webhook payload
17
+ class WebhookNewContactPayload
18
+ attr_accessor :company
19
+
20
+ attr_accessor :contact_id
21
+
22
+ attr_accessor :created_at
23
+
24
+ attr_accessor :email_addresses
25
+
26
+ # Name of the event type webhook is being triggered for.
27
+ attr_accessor :event_name
28
+
29
+ attr_accessor :first_name
30
+
31
+ attr_accessor :group_id
32
+
33
+ attr_accessor :last_name
34
+
35
+ # Idempotent message ID. Store this ID locally or in a database to prevent message duplication.
36
+ attr_accessor :message_id
37
+
38
+ attr_accessor :meta_data
39
+
40
+ attr_accessor :opt_out
41
+
42
+ attr_accessor :primary_email_address
43
+
44
+ attr_accessor :tags
45
+
46
+ # ID of webhook entity being triggered
47
+ attr_accessor :webhook_id
48
+
49
+ # Name of the webhook being triggered
50
+ attr_accessor :webhook_name
51
+
52
+ class EnumAttributeValidator
53
+ attr_reader :datatype
54
+ attr_reader :allowable_values
55
+
56
+ def initialize(datatype, allowable_values)
57
+ @allowable_values = allowable_values.map do |value|
58
+ case datatype.to_s
59
+ when /Integer/i
60
+ value.to_i
61
+ when /Float/i
62
+ value.to_f
63
+ else
64
+ value
65
+ end
66
+ end
67
+ end
68
+
69
+ def valid?(value)
70
+ !value || allowable_values.include?(value)
71
+ end
72
+ end
73
+
74
+ # Attribute mapping from ruby-style variable name to JSON key.
75
+ def self.attribute_map
76
+ {
77
+ :'company' => :'company',
78
+ :'contact_id' => :'contactId',
79
+ :'created_at' => :'createdAt',
80
+ :'email_addresses' => :'emailAddresses',
81
+ :'event_name' => :'eventName',
82
+ :'first_name' => :'firstName',
83
+ :'group_id' => :'groupId',
84
+ :'last_name' => :'lastName',
85
+ :'message_id' => :'messageId',
86
+ :'meta_data' => :'metaData',
87
+ :'opt_out' => :'optOut',
88
+ :'primary_email_address' => :'primaryEmailAddress',
89
+ :'tags' => :'tags',
90
+ :'webhook_id' => :'webhookId',
91
+ :'webhook_name' => :'webhookName'
92
+ }
93
+ end
94
+
95
+ # Attribute type mapping.
96
+ def self.openapi_types
97
+ {
98
+ :'company' => :'String',
99
+ :'contact_id' => :'String',
100
+ :'created_at' => :'DateTime',
101
+ :'email_addresses' => :'Array<String>',
102
+ :'event_name' => :'String',
103
+ :'first_name' => :'String',
104
+ :'group_id' => :'String',
105
+ :'last_name' => :'String',
106
+ :'message_id' => :'String',
107
+ :'meta_data' => :'Object',
108
+ :'opt_out' => :'Boolean',
109
+ :'primary_email_address' => :'String',
110
+ :'tags' => :'Array<String>',
111
+ :'webhook_id' => :'String',
112
+ :'webhook_name' => :'String'
113
+ }
114
+ end
115
+
116
+ # List of attributes with nullable: true
117
+ def self.openapi_nullable
118
+ Set.new([
119
+ ])
120
+ end
121
+
122
+ # Initializes the object
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ def initialize(attributes = {})
125
+ if (!attributes.is_a?(Hash))
126
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::WebhookNewContactPayload` initialize method"
127
+ end
128
+
129
+ # check to see if the attribute exists and convert string to symbol for hash key
130
+ attributes = attributes.each_with_object({}) { |(k, v), h|
131
+ if (!self.class.attribute_map.key?(k.to_sym))
132
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::WebhookNewContactPayload`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
133
+ end
134
+ h[k.to_sym] = v
135
+ }
136
+
137
+ if attributes.key?(:'company')
138
+ self.company = attributes[:'company']
139
+ end
140
+
141
+ if attributes.key?(:'contact_id')
142
+ self.contact_id = attributes[:'contact_id']
143
+ end
144
+
145
+ if attributes.key?(:'created_at')
146
+ self.created_at = attributes[:'created_at']
147
+ end
148
+
149
+ if attributes.key?(:'email_addresses')
150
+ if (value = attributes[:'email_addresses']).is_a?(Array)
151
+ self.email_addresses = value
152
+ end
153
+ end
154
+
155
+ if attributes.key?(:'event_name')
156
+ self.event_name = attributes[:'event_name']
157
+ end
158
+
159
+ if attributes.key?(:'first_name')
160
+ self.first_name = attributes[:'first_name']
161
+ end
162
+
163
+ if attributes.key?(:'group_id')
164
+ self.group_id = attributes[:'group_id']
165
+ end
166
+
167
+ if attributes.key?(:'last_name')
168
+ self.last_name = attributes[:'last_name']
169
+ end
170
+
171
+ if attributes.key?(:'message_id')
172
+ self.message_id = attributes[:'message_id']
173
+ end
174
+
175
+ if attributes.key?(:'meta_data')
176
+ self.meta_data = attributes[:'meta_data']
177
+ end
178
+
179
+ if attributes.key?(:'opt_out')
180
+ self.opt_out = attributes[:'opt_out']
181
+ end
182
+
183
+ if attributes.key?(:'primary_email_address')
184
+ self.primary_email_address = attributes[:'primary_email_address']
185
+ end
186
+
187
+ if attributes.key?(:'tags')
188
+ if (value = attributes[:'tags']).is_a?(Array)
189
+ self.tags = value
190
+ end
191
+ end
192
+
193
+ if attributes.key?(:'webhook_id')
194
+ self.webhook_id = attributes[:'webhook_id']
195
+ end
196
+
197
+ if attributes.key?(:'webhook_name')
198
+ self.webhook_name = attributes[:'webhook_name']
199
+ end
200
+ end
201
+
202
+ # Show invalid properties with the reasons. Usually used together with valid?
203
+ # @return Array for valid properties with the reasons
204
+ def list_invalid_properties
205
+ invalid_properties = Array.new
206
+ if @contact_id.nil?
207
+ invalid_properties.push('invalid value for "contact_id", contact_id cannot be nil.')
208
+ end
209
+
210
+ if @created_at.nil?
211
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
212
+ end
213
+
214
+ if @email_addresses.nil?
215
+ invalid_properties.push('invalid value for "email_addresses", email_addresses cannot be nil.')
216
+ end
217
+
218
+ if @tags.nil?
219
+ invalid_properties.push('invalid value for "tags", tags cannot be nil.')
220
+ end
221
+
222
+ invalid_properties
223
+ end
224
+
225
+ # Check to see if the all the properties in the model are valid
226
+ # @return true if the model is valid
227
+ def valid?
228
+ return false if @contact_id.nil?
229
+ return false if @created_at.nil?
230
+ return false if @email_addresses.nil?
231
+ event_name_validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT"])
232
+ return false unless event_name_validator.valid?(@event_name)
233
+ return false if @tags.nil?
234
+ true
235
+ end
236
+
237
+ # Custom attribute writer method checking allowed values (enum).
238
+ # @param [Object] event_name Object to be assigned
239
+ def event_name=(event_name)
240
+ validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT"])
241
+ unless validator.valid?(event_name)
242
+ fail ArgumentError, "invalid value for \"event_name\", must be one of #{validator.allowable_values}."
243
+ end
244
+ @event_name = event_name
245
+ end
246
+
247
+ # Checks equality by comparing each attribute.
248
+ # @param [Object] Object to be compared
249
+ def ==(o)
250
+ return true if self.equal?(o)
251
+ self.class == o.class &&
252
+ company == o.company &&
253
+ contact_id == o.contact_id &&
254
+ created_at == o.created_at &&
255
+ email_addresses == o.email_addresses &&
256
+ event_name == o.event_name &&
257
+ first_name == o.first_name &&
258
+ group_id == o.group_id &&
259
+ last_name == o.last_name &&
260
+ message_id == o.message_id &&
261
+ meta_data == o.meta_data &&
262
+ opt_out == o.opt_out &&
263
+ primary_email_address == o.primary_email_address &&
264
+ tags == o.tags &&
265
+ webhook_id == o.webhook_id &&
266
+ webhook_name == o.webhook_name
267
+ end
268
+
269
+ # @see the `==` method
270
+ # @param [Object] Object to be compared
271
+ def eql?(o)
272
+ self == o
273
+ end
274
+
275
+ # Calculates hash code according to all attributes.
276
+ # @return [Integer] Hash code
277
+ def hash
278
+ [company, contact_id, created_at, email_addresses, event_name, first_name, group_id, last_name, message_id, meta_data, opt_out, primary_email_address, tags, webhook_id, webhook_name].hash
279
+ end
280
+
281
+ # Builds the object from hash
282
+ # @param [Hash] attributes Model attributes in the form of hash
283
+ # @return [Object] Returns the model itself
284
+ def self.build_from_hash(attributes)
285
+ new.build_from_hash(attributes)
286
+ end
287
+
288
+ # Builds the object from hash
289
+ # @param [Hash] attributes Model attributes in the form of hash
290
+ # @return [Object] Returns the model itself
291
+ def build_from_hash(attributes)
292
+ return nil unless attributes.is_a?(Hash)
293
+ self.class.openapi_types.each_pair do |key, type|
294
+ if type =~ /\AArray<(.*)>/i
295
+ # check to ensure the input is an array given that the attribute
296
+ # is documented as an array but the input is not
297
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
298
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
299
+ end
300
+ elsif !attributes[self.class.attribute_map[key]].nil?
301
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
302
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
303
+ end
304
+
305
+ self
306
+ end
307
+
308
+ # Deserializes the data based on type
309
+ # @param string type Data type
310
+ # @param string value Value to be deserialized
311
+ # @return [Object] Deserialized data
312
+ def _deserialize(type, value)
313
+ case type.to_sym
314
+ when :DateTime
315
+ DateTime.parse(value)
316
+ when :Date
317
+ Date.parse(value)
318
+ when :String
319
+ value.to_s
320
+ when :Integer
321
+ value.to_i
322
+ when :Float
323
+ value.to_f
324
+ when :Boolean
325
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
326
+ true
327
+ else
328
+ false
329
+ end
330
+ when :Object
331
+ # generic object (usually a Hash), return directly
332
+ value
333
+ when /\AArray<(?<inner_type>.+)>\z/
334
+ inner_type = Regexp.last_match[:inner_type]
335
+ value.map { |v| _deserialize(inner_type, v) }
336
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
337
+ k_type = Regexp.last_match[:k_type]
338
+ v_type = Regexp.last_match[:v_type]
339
+ {}.tap do |hash|
340
+ value.each do |k, v|
341
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
342
+ end
343
+ end
344
+ else # model
345
+ MailSlurpClient.const_get(type).build_from_hash(value)
346
+ end
347
+ end
348
+
349
+ # Returns the string representation of the object
350
+ # @return [String] String presentation of the object
351
+ def to_s
352
+ to_hash.to_s
353
+ end
354
+
355
+ # to_body is an alias to to_hash (backward compatibility)
356
+ # @return [Hash] Returns the object in the form of hash
357
+ def to_body
358
+ to_hash
359
+ end
360
+
361
+ # Returns the object in the form of hash
362
+ # @return [Hash] Returns the object in the form of hash
363
+ def to_hash
364
+ hash = {}
365
+ self.class.attribute_map.each_pair do |attr, param|
366
+ value = self.send(attr)
367
+ if value.nil?
368
+ is_nullable = self.class.openapi_nullable.include?(attr)
369
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
370
+ end
371
+
372
+ hash[param] = _to_hash(value)
373
+ end
374
+ hash
375
+ end
376
+
377
+ # Outputs non-array value in the form of hash
378
+ # For object, use to_hash. Otherwise, just return the value
379
+ # @param [Object] value Any valid value
380
+ # @return [Hash] Returns the value in the form of hash
381
+ def _to_hash(value)
382
+ if value.is_a?(Array)
383
+ value.compact.map { |v| _to_hash(v) }
384
+ elsif value.is_a?(Hash)
385
+ {}.tap do |hash|
386
+ value.each { |k, v| hash[k] = _to_hash(v) }
387
+ end
388
+ elsif value.respond_to? :to_hash
389
+ value.to_hash
390
+ else
391
+ value
392
+ end
393
+ end
394
+ end
395
+ end