class MailSlurpClient::Email

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

Attributes

analysis[RW]
attachments[RW]

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.

bcc[RW]

List of `BCC` recipients email addresses that the email was addressed to. See recipients object for names.

body[RW]

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.

body_excerpt[RW]

An excerpt of the body of the email message for quick preview .

body_md5_hash[RW]

A hash signature of the email message using MD5. Useful for comparing emails without fetching full body.

cc[RW]

List of `CC` recipients email addresses that the email was addressed to. See recipients object for names.

charset[RW]

Detected character set of the email body such as UTF-8

created_at[RW]

When was the email received by MailSlurp

from[RW]

Who the email was sent from. An email address - see fromName for the sender name.

headers[RW]

Collection of SMTP headers attached to email

id[RW]

ID of the email entity

inbox_id[RW]

ID of the inbox that received the email

is_html[RW]

Is the email body HTML

read[RW]

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.

recipients[RW]
reply_to[RW]

The `replyTo` field on the received email message

sender[RW]
subject[RW]

The subject line of the email message as specified by SMTP subject header

team_access[RW]

Can the email be accessed by organization team members

to[RW]

List of `To` recipient email addresses that the email was addressed to. See recipients object for names.

updated_at[RW]

When was the email last updated

user_id[RW]

ID of user that email belongs to

Public Class Methods

attribute_map() click to toggle source

Attribute mapping from ruby-style variable name to JSON key.

# File lib/mailslurp_client/models/email.rb, line 85
def self.attribute_map
  {
    :'analysis' => :'analysis',
    :'attachments' => :'attachments',
    :'bcc' => :'bcc',
    :'body' => :'body',
    :'body_excerpt' => :'bodyExcerpt',
    :'body_md5_hash' => :'bodyMD5Hash',
    :'cc' => :'cc',
    :'charset' => :'charset',
    :'created_at' => :'createdAt',
    :'from' => :'from',
    :'headers' => :'headers',
    :'id' => :'id',
    :'inbox_id' => :'inboxId',
    :'is_html' => :'isHTML',
    :'read' => :'read',
    :'recipients' => :'recipients',
    :'reply_to' => :'replyTo',
    :'sender' => :'sender',
    :'subject' => :'subject',
    :'team_access' => :'teamAccess',
    :'to' => :'to',
    :'updated_at' => :'updatedAt',
    :'user_id' => :'userId'
  }
end
build_from_hash(attributes) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/mailslurp_client/models/email.rb, line 324
def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash

# File lib/mailslurp_client/models/email.rb, line 150
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?(:'analysis')
    self.analysis = attributes[:'analysis']
  end

  if attributes.key?(:'attachments')
    if (value = attributes[:'attachments']).is_a?(Array)
      self.attachments = value
    end
  end

  if attributes.key?(:'bcc')
    if (value = attributes[:'bcc']).is_a?(Array)
      self.bcc = value
    end
  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?(:'body_md5_hash')
    self.body_md5_hash = attributes[:'body_md5_hash']
  end

  if attributes.key?(:'cc')
    if (value = attributes[:'cc']).is_a?(Array)
      self.cc = value
    end
  end

  if attributes.key?(:'charset')
    self.charset = attributes[:'charset']
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  end

  if attributes.key?(:'from')
    self.from = attributes[:'from']
  end

  if attributes.key?(:'headers')
    if (value = attributes[:'headers']).is_a?(Hash)
      self.headers = value
    end
  end

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.key?(:'inbox_id')
    self.inbox_id = attributes[:'inbox_id']
  end

  if attributes.key?(:'is_html')
    self.is_html = attributes[:'is_html']
  end

  if attributes.key?(:'read')
    self.read = attributes[:'read']
  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?(:'sender')
    self.sender = attributes[:'sender']
  end

  if attributes.key?(:'subject')
    self.subject = attributes[:'subject']
  end

  if attributes.key?(:'team_access')
    self.team_access = attributes[:'team_access']
  end

  if attributes.key?(:'to')
    if (value = attributes[:'to']).is_a?(Array)
      self.to = value
    end
  end

  if attributes.key?(:'updated_at')
    self.updated_at = attributes[:'updated_at']
  end

  if attributes.key?(:'user_id')
    self.user_id = attributes[:'user_id']
  end
end
openapi_nullable() click to toggle source

List of attributes with nullable: true

# File lib/mailslurp_client/models/email.rb, line 143
def self.openapi_nullable
  Set.new([
  ])
end
openapi_types() click to toggle source

Attribute type mapping.

# File lib/mailslurp_client/models/email.rb, line 114
def self.openapi_types
  {
    :'analysis' => :'EmailAnalysis',
    :'attachments' => :'Array<String>',
    :'bcc' => :'Array<String>',
    :'body' => :'String',
    :'body_excerpt' => :'String',
    :'body_md5_hash' => :'String',
    :'cc' => :'Array<String>',
    :'charset' => :'String',
    :'created_at' => :'DateTime',
    :'from' => :'String',
    :'headers' => :'Hash<String, String>',
    :'id' => :'String',
    :'inbox_id' => :'String',
    :'is_html' => :'Boolean',
    :'read' => :'Boolean',
    :'recipients' => :'EmailRecipients',
    :'reply_to' => :'String',
    :'sender' => :'Sender',
    :'subject' => :'String',
    :'team_access' => :'Boolean',
    :'to' => :'Array<String>',
    :'updated_at' => :'DateTime',
    :'user_id' => :'String'
  }
end

Public Instance Methods

==(o) click to toggle source

Checks equality by comparing each attribute. @param [Object] Object to be compared

# File lib/mailslurp_client/models/email.rb, line 281
def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      analysis == o.analysis &&
      attachments == o.attachments &&
      bcc == o.bcc &&
      body == o.body &&
      body_excerpt == o.body_excerpt &&
      body_md5_hash == o.body_md5_hash &&
      cc == o.cc &&
      charset == o.charset &&
      created_at == o.created_at &&
      from == o.from &&
      headers == o.headers &&
      id == o.id &&
      inbox_id == o.inbox_id &&
      is_html == o.is_html &&
      read == o.read &&
      recipients == o.recipients &&
      reply_to == o.reply_to &&
      sender == o.sender &&
      subject == o.subject &&
      team_access == o.team_access &&
      to == o.to &&
      updated_at == o.updated_at &&
      user_id == o.user_id
end
_deserialize(type, value) click to toggle source

Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data

# File lib/mailslurp_client/models/email.rb, line 352
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) click to toggle source

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash

# File lib/mailslurp_client/models/email.rb, line 421
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) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/mailslurp_client/models/email.rb, line 331
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) click to toggle source

@see the `==` method @param [Object] Object to be compared

# File lib/mailslurp_client/models/email.rb, line 311
def eql?(o)
  self == o
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Integer] Hash code

# File lib/mailslurp_client/models/email.rb, line 317
def hash
  [analysis, attachments, bcc, body, body_excerpt, body_md5_hash, cc, charset, created_at, from, headers, id, inbox_id, is_html, read, recipients, reply_to, sender, subject, team_access, to, updated_at, user_id].hash
end
list_invalid_properties() click to toggle source

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons

# File lib/mailslurp_client/models/email.rb, line 268
def list_invalid_properties
  invalid_properties = Array.new
  invalid_properties
end
to_body() click to toggle source

to_body is an alias to to_hash (backward compatibility) @return [Hash] Returns the object in the form of hash

# File lib/mailslurp_client/models/email.rb, line 397
def to_body
  to_hash
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# File lib/mailslurp_client/models/email.rb, line 403
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() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/mailslurp_client/models/email.rb, line 391
def to_s
  to_hash.to_s
end
valid?() click to toggle source

Check to see if the all the properties in the model are valid @return true if the model is valid

# File lib/mailslurp_client/models/email.rb, line 275
def valid?
  true
end