Class: MadMimiMail
- Inherits:
-
Object
- Object
- MadMimiMail
- Defined in:
- lib/mad_mimi_mail.rb,
lib/mad_mimi_mail.rb
Defined Under Namespace
Modules: Configuration
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #deliver!(mail) ⇒ Object
-
#initialize(options) ⇒ MadMimiMail
constructor
A new instance of MadMimiMail.
Constructor Details
#initialize(options) ⇒ MadMimiMail
Returns a new instance of MadMimiMail.
7 8 9 10 11 12 |
# File 'lib/mad_mimi_mail.rb', line 7 def initialize() check_api_settings @_mimi = MadMimi.new(api_settings[:email], api_settings[:api_key]) self.settings = end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
6 7 8 |
# File 'lib/mad_mimi_mail.rb', line 6 def settings @settings end |
Instance Method Details
#deliver!(mail) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mad_mimi_mail.rb', line 14 def deliver!(mail) mail_settings = { :recipients => extract_header(mail, :to), :raw_html => mail.html_part.body, :raw_plain_text => mail.text_part.body} [:name, :from, :subject, :promotion_name, :list_name, :raw_yaml].inject(mail_settings) do |hash, header_name| hash.merge!(header_name => extract_header(mail, header_name)) end mimi_response = @_mimi.send_mail(mail_settings.merge(self.settings), {}.to_yaml) #FIXME: (Dirty Hack) Need access to the transaction id from the api call, so # we're defining a new method #transaction_id onto the mail object containing the integer value # DANGER, DANGER! METAPROGRAMMING! transaction_id = mimi_response.to_i add_transaction_id_attribute(mail, transaction_id) #if the message isn't an integer, something went wrong and we want to capture it in the mail errors mail.errors << mimi_response if transaction_id.zero? end |