Class: MandrillInboundParser::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/mandrill_inbound_parser/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(raw_data) ⇒ Parser

Returns a new instance of Parser.



4
5
6
7
8
# File 'lib/mandrill_inbound_parser/parser.rb', line 4

def initialize(raw_data)
  raw = JSON.parse(raw_data)
  @raw = raw.first
  @raw
end

Instance Method Details

#attachmentsObject



58
59
60
# File 'lib/mandrill_inbound_parser/parser.rb', line 58

def attachments
  @raw["msg"]["attachments"]
end

#email_fromObject

get sender email



21
22
23
# File 'lib/mandrill_inbound_parser/parser.rb', line 21

def email_from
  @raw["msg"]["from_email"]
end

#eventObject

Get event



16
17
18
# File 'lib/mandrill_inbound_parser/parser.rb', line 16

def event
  @raw["event"]
end

#get_keysObject

Get all keys



11
12
13
# File 'lib/mandrill_inbound_parser/parser.rb', line 11

def get_keys
  @raw.keys
end

#htmlObject



50
51
52
# File 'lib/mandrill_inbound_parser/parser.rb', line 50

def html
  @raw["msg"]["html"]
end

#imagesObject



62
63
64
# File 'lib/mandrill_inbound_parser/parser.rb', line 62

def images
  @raw["msg"]["images"]
end

#recipient_emailsObject

Return to Array



36
37
38
# File 'lib/mandrill_inbound_parser/parser.rb', line 36

def recipient_emails
  @raw["msg"]["to"].map{|x| x.first}
end

#recipient_namesObject

Returns to Array



41
42
43
# File 'lib/mandrill_inbound_parser/parser.rb', line 41

def recipient_names
  @raw["msg"]["to"].map{|x| x.last}
end

#recipientsObject



54
55
56
# File 'lib/mandrill_inbound_parser/parser.rb', line 54

def recipients
  @raw["msg"]["to"]
end

#sender_nameObject

Returns the sender name



26
27
28
# File 'lib/mandrill_inbound_parser/parser.rb', line 26

def sender_name
  @raw["msg"]["from_name"]
end

#subjectObject

Returns the subject



46
47
48
# File 'lib/mandrill_inbound_parser/parser.rb', line 46

def subject
  @raw["msg"]["subject"]
end

#textObject

Message content as text



31
32
33
# File 'lib/mandrill_inbound_parser/parser.rb', line 31

def text
  @raw["msg"]["text"]
end