Class: MailSlurpClient::Email
- Inherits:
-
Object
- Object
- MailSlurpClient::Email
- Defined in:
- lib/mailslurp_client/models/email.rb
Overview
Email entity (also known as EmailDto). When an SMTP email message is received by MailSlurp it is parsed. The body and attachments are written to disk and the fields such as to, from, subject etc are stored in a database. The `body` contains the email content. If you want the original SMTP message see the `getRawEmail` endpoints. The attachments can be fetched using the AttachmentController
Instance Attribute Summary collapse
-
#analysis ⇒ Object
Returns the value of attribute analysis.
-
#attachments ⇒ Object
List of IDs of attachments found in the email.
-
#bcc ⇒ Object
List of `BCC` recipients email addresses that the email was addressed to.
-
#body ⇒ Object
The body of the email message as text parsed from the SMTP message body (does not include attachments).
-
#body_excerpt ⇒ Object
An excerpt of the body of the email message for quick preview.
-
#body_md5_hash ⇒ Object
A hash signature of the email message using MD5.
-
#body_part_content_types ⇒ Object
A list of detected multipart mime message body part content types such as text/plain and text/html.
-
#cc ⇒ Object
List of `CC` recipients email addresses that the email was addressed to.
-
#charset ⇒ Object
Detected character set of the email body such as UTF-8.
-
#created_at ⇒ Object
When was the email received by MailSlurp.
-
#domain_id ⇒ Object
ID of the domain that received the email.
-
#from ⇒ Object
Who the email was sent from.
-
#headers ⇒ Object
Collection of SMTP headers attached to email.
-
#headers_map ⇒ Object
Multi-value map of SMTP headers attached to email.
-
#html ⇒ Object
Returns the value of attribute html.
-
#id ⇒ Object
ID of the email entity.
-
#inbox_id ⇒ Object
ID of the inbox that received the email.
-
#is_html ⇒ Object
Is the email body content type HTML?.
-
#is_x_amp_html ⇒ Object
Is the email body content type x-amp-html Amp4Email?.
-
#read ⇒ Object
Read flag.
-
#recipients ⇒ Object
Returns the value of attribute recipients.
-
#reply_to ⇒ Object
The `replyTo` field on the received email message.
-
#sender ⇒ Object
Returns the value of attribute sender.
-
#subject ⇒ Object
The subject line of the email message as specified by SMTP subject header.
-
#team_access ⇒ Object
Can the email be accessed by organization team members.
-
#text_excerpt ⇒ Object
An excerpt of the body of the email message for quick preview.
-
#to ⇒ Object
List of `To` recipient email addresses that the email was addressed to.
-
#updated_at ⇒ Object
When was the email last updated.
-
#user_id ⇒ Object
ID of user that email belongs to.
-
#xamp_html ⇒ Object
Returns the value of attribute xamp_html.
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Email
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Email
Initializes the object
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/mailslurp_client/models/email.rb', line 203 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::Email` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::Email`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'id') self.id = attributes[:'id'] end if attributes.key?(:'user_id') self.user_id = attributes[:'user_id'] end if attributes.key?(:'inbox_id') self.inbox_id = attributes[:'inbox_id'] end if attributes.key?(:'domain_id') self.domain_id = attributes[:'domain_id'] end if attributes.key?(:'to') if (value = attributes[:'to']).is_a?(Array) self.to = value end end if attributes.key?(:'from') self.from = attributes[:'from'] end if attributes.key?(:'sender') self.sender = attributes[:'sender'] end if attributes.key?(:'recipients') self.recipients = attributes[:'recipients'] end if attributes.key?(:'reply_to') self.reply_to = attributes[:'reply_to'] end if attributes.key?(:'cc') if (value = attributes[:'cc']).is_a?(Array) self.cc = value end end if attributes.key?(:'bcc') if (value = attributes[:'bcc']).is_a?(Array) self.bcc = value end end if attributes.key?(:'headers') if (value = attributes[:'headers']).is_a?(Hash) self.headers = value end end if attributes.key?(:'headers_map') if (value = attributes[:'headers_map']).is_a?(Hash) self.headers_map = value end end if attributes.key?(:'attachments') if (value = attributes[:'attachments']).is_a?(Array) self. = value end end if attributes.key?(:'subject') self.subject = attributes[:'subject'] end if attributes.key?(:'body') self.body = attributes[:'body'] end if attributes.key?(:'body_excerpt') self.body_excerpt = attributes[:'body_excerpt'] end if attributes.key?(:'text_excerpt') self.text_excerpt = attributes[:'text_excerpt'] end if attributes.key?(:'body_md5_hash') self.body_md5_hash = attributes[:'body_md5_hash'] end if attributes.key?(:'is_html') self.is_html = attributes[:'is_html'] end if attributes.key?(:'charset') self.charset = attributes[:'charset'] end if attributes.key?(:'analysis') self.analysis = attributes[:'analysis'] end if attributes.key?(:'created_at') self.created_at = attributes[:'created_at'] end if attributes.key?(:'updated_at') self.updated_at = attributes[:'updated_at'] end if attributes.key?(:'read') self.read = attributes[:'read'] end if attributes.key?(:'team_access') self.team_access = attributes[:'team_access'] end if attributes.key?(:'is_x_amp_html') self.is_x_amp_html = attributes[:'is_x_amp_html'] end if attributes.key?(:'body_part_content_types') if (value = attributes[:'body_part_content_types']).is_a?(Array) self.body_part_content_types = value end end if attributes.key?(:'html') self.html = attributes[:'html'] end if attributes.key?(:'xamp_html') self.xamp_html = attributes[:'xamp_html'] end end |
Instance Attribute Details
#analysis ⇒ Object
Returns the value of attribute analysis.
79 80 81 |
# File 'lib/mailslurp_client/models/email.rb', line 79 def analysis @analysis end |
#attachments ⇒ Object
List of IDs of attachments found in the email. Use these IDs with the Inbox and Email Controllers to download attachments and attachment meta data such as filesize, name, extension.
56 57 58 |
# File 'lib/mailslurp_client/models/email.rb', line 56 def @attachments end |
#bcc ⇒ Object
List of `BCC` recipients email addresses that the email was addressed to. See recipients object for names.
47 48 49 |
# File 'lib/mailslurp_client/models/email.rb', line 47 def bcc @bcc end |
#body ⇒ Object
The body of the email message as text parsed from the SMTP message body (does not include attachments). Fetch the raw content to access the SMTP message and use the attachments property to access attachments. The body is stored separately to the email entity so the body is not returned in paginated results only in full single email or wait requests.
62 63 64 |
# File 'lib/mailslurp_client/models/email.rb', line 62 def body @body end |
#body_excerpt ⇒ Object
An excerpt of the body of the email message for quick preview. Takes HTML content part if exists falls back to TEXT content part if not
65 66 67 |
# File 'lib/mailslurp_client/models/email.rb', line 65 def body_excerpt @body_excerpt end |
#body_md5_hash ⇒ Object
A hash signature of the email message using MD5. Useful for comparing emails without fetching full body.
71 72 73 |
# File 'lib/mailslurp_client/models/email.rb', line 71 def body_md5_hash @body_md5_hash end |
#body_part_content_types ⇒ Object
A list of detected multipart mime message body part content types such as text/plain and text/html. Can be used with email bodyPart endpoints to fetch individual body parts.
97 98 99 |
# File 'lib/mailslurp_client/models/email.rb', line 97 def body_part_content_types @body_part_content_types end |
#cc ⇒ Object
List of `CC` recipients email addresses that the email was addressed to. See recipients object for names.
44 45 46 |
# File 'lib/mailslurp_client/models/email.rb', line 44 def cc @cc end |
#charset ⇒ Object
Detected character set of the email body such as UTF-8
77 78 79 |
# File 'lib/mailslurp_client/models/email.rb', line 77 def charset @charset end |
#created_at ⇒ Object
When was the email received by MailSlurp
82 83 84 |
# File 'lib/mailslurp_client/models/email.rb', line 82 def created_at @created_at end |
#domain_id ⇒ Object
ID of the domain that received the email
28 29 30 |
# File 'lib/mailslurp_client/models/email.rb', line 28 def domain_id @domain_id end |
#from ⇒ Object
Who the email was sent from. An email address - see fromName for the sender name.
34 35 36 |
# File 'lib/mailslurp_client/models/email.rb', line 34 def from @from end |
#headers ⇒ Object
Collection of SMTP headers attached to email
50 51 52 |
# File 'lib/mailslurp_client/models/email.rb', line 50 def headers @headers end |
#headers_map ⇒ Object
Multi-value map of SMTP headers attached to email
53 54 55 |
# File 'lib/mailslurp_client/models/email.rb', line 53 def headers_map @headers_map end |
#html ⇒ Object
Returns the value of attribute html.
99 100 101 |
# File 'lib/mailslurp_client/models/email.rb', line 99 def html @html end |
#id ⇒ Object
ID of the email entity
19 20 21 |
# File 'lib/mailslurp_client/models/email.rb', line 19 def id @id end |
#inbox_id ⇒ Object
ID of the inbox that received the email
25 26 27 |
# File 'lib/mailslurp_client/models/email.rb', line 25 def inbox_id @inbox_id end |
#is_html ⇒ Object
Is the email body content type HTML?
74 75 76 |
# File 'lib/mailslurp_client/models/email.rb', line 74 def is_html @is_html end |
#is_x_amp_html ⇒ Object
Is the email body content type x-amp-html Amp4Email?
94 95 96 |
# File 'lib/mailslurp_client/models/email.rb', line 94 def is_x_amp_html @is_x_amp_html end |
#read ⇒ Object
Read flag. Has the email ever been viewed in the dashboard or fetched via the API with a hydrated body? If so the email is marked as read. Paginated results do not affect read status. Read status is different to email opened event as it depends on your own account accessing the email. Email opened is determined by tracking pixels sent to other uses if enable during sending. You can listened for both email read and email opened events using webhooks.
88 89 90 |
# File 'lib/mailslurp_client/models/email.rb', line 88 def read @read end |
#recipients ⇒ Object
Returns the value of attribute recipients.
38 39 40 |
# File 'lib/mailslurp_client/models/email.rb', line 38 def recipients @recipients end |
#reply_to ⇒ Object
The `replyTo` field on the received email message
41 42 43 |
# File 'lib/mailslurp_client/models/email.rb', line 41 def reply_to @reply_to end |
#sender ⇒ Object
Returns the value of attribute sender.
36 37 38 |
# File 'lib/mailslurp_client/models/email.rb', line 36 def sender @sender end |
#subject ⇒ Object
The subject line of the email message as specified by SMTP subject header
59 60 61 |
# File 'lib/mailslurp_client/models/email.rb', line 59 def subject @subject end |
#team_access ⇒ Object
Can the email be accessed by organization team members
91 92 93 |
# File 'lib/mailslurp_client/models/email.rb', line 91 def team_access @team_access end |
#text_excerpt ⇒ Object
An excerpt of the body of the email message for quick preview. Takes TEXT content part if exists
68 69 70 |
# File 'lib/mailslurp_client/models/email.rb', line 68 def text_excerpt @text_excerpt end |
#to ⇒ Object
List of `To` recipient email addresses that the email was addressed to. See recipients object for names.
31 32 33 |
# File 'lib/mailslurp_client/models/email.rb', line 31 def to @to end |
#updated_at ⇒ Object
When was the email last updated
85 86 87 |
# File 'lib/mailslurp_client/models/email.rb', line 85 def updated_at @updated_at end |
#user_id ⇒ Object
ID of user that email belongs to
22 23 24 |
# File 'lib/mailslurp_client/models/email.rb', line 22 def user_id @user_id end |
#xamp_html ⇒ Object
Returns the value of attribute xamp_html.
101 102 103 |
# File 'lib/mailslurp_client/models/email.rb', line 101 def xamp_html @xamp_html end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/mailslurp_client/models/email.rb', line 104 def self.attribute_map { :'id' => :'id', :'user_id' => :'userId', :'inbox_id' => :'inboxId', :'domain_id' => :'domainId', :'to' => :'to', :'from' => :'from', :'sender' => :'sender', :'recipients' => :'recipients', :'reply_to' => :'replyTo', :'cc' => :'cc', :'bcc' => :'bcc', :'headers' => :'headers', :'headers_map' => :'headersMap', :'attachments' => :'attachments', :'subject' => :'subject', :'body' => :'body', :'body_excerpt' => :'bodyExcerpt', :'text_excerpt' => :'textExcerpt', :'body_md5_hash' => :'bodyMD5Hash', :'is_html' => :'isHTML', :'charset' => :'charset', :'analysis' => :'analysis', :'created_at' => :'createdAt', :'updated_at' => :'updatedAt', :'read' => :'read', :'team_access' => :'teamAccess', :'is_x_amp_html' => :'isXAmpHtml', :'body_part_content_types' => :'bodyPartContentTypes', :'html' => :'html', :'xamp_html' => :'xampHtml' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
456 457 458 |
# File 'lib/mailslurp_client/models/email.rb', line 456 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/mailslurp_client/models/email.rb', line 176 def self.openapi_nullable Set.new([ :'domain_id', :'from', :'sender', :'recipients', :'reply_to', :'cc', :'bcc', :'headers', :'headers_map', :'attachments', :'subject', :'body', :'body_excerpt', :'text_excerpt', :'body_md5_hash', :'is_html', :'charset', :'analysis', :'is_x_amp_html', :'body_part_content_types', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/mailslurp_client/models/email.rb', line 140 def self.openapi_types { :'id' => :'String', :'user_id' => :'String', :'inbox_id' => :'String', :'domain_id' => :'String', :'to' => :'Array<String>', :'from' => :'String', :'sender' => :'Sender', :'recipients' => :'EmailRecipients', :'reply_to' => :'String', :'cc' => :'Array<String>', :'bcc' => :'Array<String>', :'headers' => :'Hash<String, String>', :'headers_map' => :'Hash<String, Array<String>>', :'attachments' => :'Array<String>', :'subject' => :'String', :'body' => :'String', :'body_excerpt' => :'String', :'text_excerpt' => :'String', :'body_md5_hash' => :'String', :'is_html' => :'Boolean', :'charset' => :'String', :'analysis' => :'EmailAnalysis', :'created_at' => :'DateTime', :'updated_at' => :'DateTime', :'read' => :'Boolean', :'team_access' => :'Boolean', :'is_x_amp_html' => :'Boolean', :'body_part_content_types' => :'Array<String>', :'html' => :'Boolean', :'xamp_html' => :'Boolean' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'lib/mailslurp_client/models/email.rb', line 406 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && user_id == o.user_id && inbox_id == o.inbox_id && domain_id == o.domain_id && to == o.to && from == o.from && sender == o.sender && recipients == o.recipients && reply_to == o.reply_to && cc == o.cc && bcc == o.bcc && headers == o.headers && headers_map == o.headers_map && == o. && subject == o.subject && body == o.body && body_excerpt == o.body_excerpt && text_excerpt == o.text_excerpt && body_md5_hash == o.body_md5_hash && is_html == o.is_html && charset == o.charset && analysis == o.analysis && created_at == o.created_at && updated_at == o.updated_at && read == o.read && team_access == o.team_access && is_x_amp_html == o.is_x_amp_html && body_part_content_types == o.body_part_content_types && html == o.html && xamp_html == o.xamp_html end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
# File 'lib/mailslurp_client/models/email.rb', line 484 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model MailSlurpClient.const_get(type).build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/mailslurp_client/models/email.rb', line 553 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
# File 'lib/mailslurp_client/models/email.rb', line 463 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end |
#eql?(o) ⇒ Boolean
443 444 445 |
# File 'lib/mailslurp_client/models/email.rb', line 443 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
449 450 451 |
# File 'lib/mailslurp_client/models/email.rb', line 449 def hash [id, user_id, inbox_id, domain_id, to, from, sender, recipients, reply_to, cc, bcc, headers, headers_map, , subject, body, body_excerpt, text_excerpt, body_md5_hash, is_html, charset, analysis, created_at, updated_at, read, team_access, is_x_amp_html, body_part_content_types, html, xamp_html].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/mailslurp_client/models/email.rb', line 353 def list_invalid_properties invalid_properties = Array.new if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end if @user_id.nil? invalid_properties.push('invalid value for "user_id", user_id cannot be nil.') end if @inbox_id.nil? invalid_properties.push('invalid value for "inbox_id", inbox_id cannot be nil.') end if @to.nil? invalid_properties.push('invalid value for "to", to cannot be nil.') end if @created_at.nil? invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') end if @updated_at.nil? invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.') end if @read.nil? invalid_properties.push('invalid value for "read", read cannot be nil.') end if @team_access.nil? invalid_properties.push('invalid value for "team_access", team_access cannot be nil.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
529 530 531 |
# File 'lib/mailslurp_client/models/email.rb', line 529 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
535 536 537 538 539 540 541 542 543 544 545 546 547 |
# File 'lib/mailslurp_client/models/email.rb', line 535 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
523 524 525 |
# File 'lib/mailslurp_client/models/email.rb', line 523 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
392 393 394 395 396 397 398 399 400 401 402 |
# File 'lib/mailslurp_client/models/email.rb', line 392 def valid? return false if @id.nil? return false if @user_id.nil? return false if @inbox_id.nil? return false if @to.nil? return false if @created_at.nil? return false if @updated_at.nil? return false if @read.nil? return false if @team_access.nil? true end |