Class: AngieCoreApi::DeliveryMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/angie-core-api/delivery_method.rb

Instance Method Summary collapse

Constructor Details

#initialize(mail) ⇒ DeliveryMethod

Returns a new instance of DeliveryMethod.



5
# File 'lib/angie-core-api/delivery_method.rb', line 5

def initialize(mail) end

Instance Method Details

#deliver!(mail) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/angie-core-api/delivery_method.rb', line 7

def deliver!(mail)
  Notification.email(
    from: mail[:from].formatted.first,
    to: mail.to,
    cc: mail.cc,
    bcc: mail.bcc,
    subject: mail.subject,
    text: mail.text_part ? mail.text_part.body&.raw_source : mail.body.raw_source,
    html: mail.html_part ? mail.html_part.body&.raw_source : mail.body.raw_source,
    attachments: mail.attachments.map do |a|
      {
        filename: a.filename,
        content: a.body.raw_source,
        mime_type: a.mime_type,
        encoding: a.body.encoding,
      }
    end
  )
end