Class: SendcloudMailer::Base
- Inherits:
-
Object
- Object
- SendcloudMailer::Base
- Defined in:
- lib/sendcloud-mailer/base.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #deliver!(mail) ⇒ Object
-
#initialize(settings) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(settings) ⇒ Base
Returns a new instance of Base.
7 8 9 |
# File 'lib/sendcloud-mailer/base.rb', line 7 def initialize(settings) self.settings = settings end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
5 6 7 |
# File 'lib/sendcloud-mailer/base.rb', line 5 def settings @settings end |
Instance Method Details
#deliver!(mail) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sendcloud-mailer/base.rb', line 11 def deliver!(mail) @mail = mail params = { :apiUser => settings[:api_user], :apiKey => settings[:api_key], :from => from, :to => to, :cc => cc, :bcc => bcc, :subject => mail.subject, :html => html, :plain => plain, :attachments => } params.delete_if { |k, v| v.nil? } result = RestClient.post( 'http://api.sendcloud.net/apiv2/mail/send', params ) json = JSON.parse(result.force_encoding('UTF-8')) error(json) unless json["result"] unless @file.nil? File.unlink(@file.path) rescue nil end end |