Class: MultiMail::Message::Postmark
- Defined in:
- lib/multi_mail/postmark/message.rb
Overview
Instance Attribute Summary collapse
-
#mailboxhash ⇒ Object
Returns the value of attribute mailboxhash.
-
#messageid ⇒ Object
Returns the value of attribute messageid.
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
-
#postmark_attachments ⇒ Array<Hash>
Returns the message's attachments in Postmark format.
-
#postmark_headers ⇒ Array<Hash>
Returns the message headers in Postmark format.
-
#to_postmark_hash ⇒ Hash
Returns the message as parameters to POST to Postmark.
Constructor Details
This class inherits a constructor from MultiMail::Message::Base
Instance Attribute Details
#mailboxhash ⇒ Object
Returns the value of attribute mailboxhash.
5 6 7 |
# File 'lib/multi_mail/postmark/message.rb', line 5 def mailboxhash @mailboxhash end |
#messageid ⇒ Object
Returns the value of attribute messageid.
5 6 7 |
# File 'lib/multi_mail/postmark/message.rb', line 5 def @messageid end |
#tag ⇒ Object
Returns the value of attribute tag.
5 6 7 |
# File 'lib/multi_mail/postmark/message.rb', line 5 def tag @tag end |
Instance Method Details
#postmark_attachments ⇒ Array<Hash>
Returns the message's attachments in Postmark format.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/multi_mail/postmark/message.rb', line 27 def .map do || hash = { 'ContentType' => .content_type, 'Name' => .filename, 'Content' => Base64.encode64(.body.decoded) } if .content_type.start_with?('image/') hash['ContentID'] = .filename end hash end end |
#postmark_headers ⇒ Array<Hash>
Returns the message headers in Postmark format.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/multi_mail/postmark/message.rb', line 10 def postmark_headers array = [] header_fields.each do |field| key = field.name.downcase # @see https://github.com/wildbit/postmark-gem/blob/master/lib/postmark/message_extensions/mail.rb#L74 # @see https://github.com/wildbit/postmark-gem/pull/36#issuecomment-22298955 unless %w(from to cc bcc reply-to subject tag content-type date).include?(key) || (Array === field.value && field.value.size > 1) array << {'Name' => field.name, 'Value' => field.value} end end array end |
#to_postmark_hash ⇒ Hash
Returns the message as parameters to POST to Postmark.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/multi_mail/postmark/message.rb', line 44 def to_postmark_hash hash = {} %w(from subject).each do |field| if self[field] hash[postmark_key(field)] = self[field].value end end %w(to cc bcc reply_to).each do |field| if self[field] value = self[field].value hash[postmark_key(field)] = value.respond_to?(:join) ? value.join(', ') : value end end hash['TextBody'] = body_text hash['HtmlBody'] = body_html hash['Headers'] = postmark_headers hash['Attachments'] = hash['Tag'] = .first normalize(hash) end |