Class: Hermes::SendgridProvider
- Defined in:
- lib/providers/sendgrid/sendgrid_provider.rb
Instance Attribute Summary
Attributes inherited from Provider
#credentials, #defaults, #deliverer, #weight
Instance Method Summary collapse
Methods inherited from Provider
#initialize, #message_failure, #message_success, #provider_name, required_credentials
Methods included from Extractors
#complex_extract, #extract_from, #extract_html, #extract_text, #extract_to
Constructor Details
This class inherits a constructor from Hermes::Provider
Instance Method Details
#client ⇒ Object
39 40 41 42 43 44 |
# File 'lib/providers/sendgrid/sendgrid_provider.rb', line 39 def client SendGrid::Client.new({ api_user: self.credentials[:api_user], api_key: self.credentials[:api_key] }) end |
#payload(rails_message) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/providers/sendgrid/sendgrid_provider.rb', line 15 def payload() # requireds = SendGrid::Mail.new({ from: extract_from(, :address), from_name: extract_from(, :name), to: extract_to(, :address), to_name: extract_to(, :name), subject: .subject, html: extract_html(), text: extract_text(), }) # optionals .reply_to = [:reply_to].formatted.first if [:reply_to] . = [:message_id].value if . # and any attachments ..try(:each) do || .(Hermes::EmailAttachment.new()) end return end |
#send_message(rails_message) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/providers/sendgrid/sendgrid_provider.rb', line 5 def () payload = payload() if self.deliverer.should_deliver? client.send(payload) end self.() end |