class Postmark::Mitt

Attributes

raw[R]
source[R]

Public Class Methods

new(json) click to toggle source
# File lib/postmark/mitt.rb, line 3
def initialize(json)
  @raw = json
  @source = MultiJson.decode(json)
end

Public Instance Methods

attachments() click to toggle source
# File lib/postmark/mitt.rb, line 99
def attachments
  @attachments ||= begin
    raw_attachments = source["Attachments"] || []
    AttachmentsArray.new(raw_attachments.map{|a| Attachment.new(a)})
  end
end
bcc() click to toggle source
# File lib/postmark/mitt.rb, line 47
def bcc
  source["Bcc"]
end
bcc_email() click to toggle source
# File lib/postmark/mitt.rb, line 51
def bcc_email
  source["BccFull"]["Email"] || bcc
end
bcc_name() click to toggle source
# File lib/postmark/mitt.rb, line 55
def bcc_name
  source["BccFull"]["Name"] || bcc
end
cc() click to toggle source
# File lib/postmark/mitt.rb, line 59
def cc
  source["Cc"]
end
cc_email() click to toggle source
# File lib/postmark/mitt.rb, line 63
def cc_email
  source["CcFull"]["Email"] || cc
end
cc_name() click to toggle source
# File lib/postmark/mitt.rb, line 67
def cc_name
  source["CcFull"]["Name"] || cc
end
from() click to toggle source
# File lib/postmark/mitt.rb, line 18
def from
  source["From"].gsub('"', '')
end
from_email() click to toggle source
# File lib/postmark/mitt.rb, line 22
def from_email
  source["FromFull"]["Email"] || from
end
from_name() click to toggle source
# File lib/postmark/mitt.rb, line 26
def from_name
  source["FromFull"]["Name"] || from
end
has_attachments?() click to toggle source
# File lib/postmark/mitt.rb, line 106
def has_attachments?
  !attachments.empty?
end
headers() click to toggle source
# File lib/postmark/mitt.rb, line 91
def headers
  @headers ||= source["Headers"].inject({}){|hash,obj| hash[obj["Name"]] = obj["Value"]; hash}
end
html_body() click to toggle source
# File lib/postmark/mitt.rb, line 75
def html_body
  source["HtmlBody"]
end
inspect() click to toggle source
# File lib/postmark/mitt.rb, line 10
def inspect
  "<Postmark::Mitt: #{message_id}>"
end
mailbox_hash() click to toggle source
# File lib/postmark/mitt.rb, line 83
def mailbox_hash
  source["MailboxHash"]
end
message_id() click to toggle source
# File lib/postmark/mitt.rb, line 95
def message_id
  source["MessageID"]
end
reply_to() click to toggle source
# File lib/postmark/mitt.rb, line 71
def reply_to
  source["ReplyTo"]
end
subject() click to toggle source
# File lib/postmark/mitt.rb, line 14
def subject
  source["Subject"]
end
tag() click to toggle source
# File lib/postmark/mitt.rb, line 87
def tag
  source["Tag"]
end
text_body() click to toggle source
# File lib/postmark/mitt.rb, line 79
def text_body
  source["TextBody"]
end
to() click to toggle source
# File lib/postmark/mitt.rb, line 30
def to
  source["To"].gsub('"', '')
end
to_email() click to toggle source
# File lib/postmark/mitt.rb, line 38
def to_email
  to_full.any? ? to_full.first["Email"] : to
end
to_full() click to toggle source
# File lib/postmark/mitt.rb, line 34
def to_full
  source["ToFull"] || []
end
to_name() click to toggle source
# File lib/postmark/mitt.rb, line 42
def to_name
  to_full.any? ? to_full.first["Name"] : to
end