Class: IterableRails::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/iterable_rails/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mail) ⇒ Message

Returns a new instance of Message.



7
8
9
# File 'lib/iterable_rails/message.rb', line 7

def initialize(mail)
  @mail = mail
end

Instance Attribute Details

#mail ⇒ Object (readonly)

Returns the value of attribute mail.



5
6
7
# File 'lib/iterable_rails/message.rb', line 5

def mail
  @mail
end

Instance Method Details

#attachments ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/iterable_rails/message.rb', line 11

def attachments
  mail.attachments.map do |attachment|
    {
      name: attachment.filename,
      mimeType: attachment.mime_type,
      content: Base64.encode64(attachment.body.decoded)
    }
  end
end

#data_fields ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/iterable_rails/message.rb', line 21

def data_fields
  {
    bcc_address: bcc_address,
    from_email: from_email,
    from_name: from_name,
    html: html,
    subject: subject,
    text: text,
  }
end

#metadata ⇒ Object



32
33
34
# File 'lib/iterable_rails/message.rb', line 32

def 
  get_value(:metadata) || {}
end

#to_email_address ⇒ Object



36
37
38
# File 'lib/iterable_rails/message.rb', line 36

def to_email_address
  to.address
end