Class: MandrillInboundParser::Parser
- Inherits:
-
Object
- Object
- MandrillInboundParser::Parser
- Defined in:
- lib/mandrill_inbound_parser/parser.rb
Instance Method Summary collapse
- #attachments ⇒ Object
-
#email_from ⇒ Object
get sender email.
-
#event ⇒ Object
Get event.
-
#get_keys ⇒ Object
Get all keys.
- #html ⇒ Object
- #images ⇒ Object
-
#initialize(raw_data) ⇒ Parser
constructor
A new instance of Parser.
-
#recipient_emails ⇒ Object
Return to Array.
-
#recipient_names ⇒ Object
Returns to Array.
- #recipients ⇒ Object
-
#sender_name ⇒ Object
Returns the sender name.
-
#subject ⇒ Object
Returns the subject.
-
#text ⇒ Object
Message content as text.
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
#attachments ⇒ Object
58 59 60 |
# File 'lib/mandrill_inbound_parser/parser.rb', line 58 def @raw["msg"]["attachments"] end |
#email_from ⇒ Object
get sender email
21 22 23 |
# File 'lib/mandrill_inbound_parser/parser.rb', line 21 def email_from @raw["msg"]["from_email"] end |
#event ⇒ Object
Get event
16 17 18 |
# File 'lib/mandrill_inbound_parser/parser.rb', line 16 def event @raw["event"] end |
#get_keys ⇒ Object
Get all keys
11 12 13 |
# File 'lib/mandrill_inbound_parser/parser.rb', line 11 def get_keys @raw.keys end |
#html ⇒ Object
50 51 52 |
# File 'lib/mandrill_inbound_parser/parser.rb', line 50 def html @raw["msg"]["html"] end |
#images ⇒ Object
62 63 64 |
# File 'lib/mandrill_inbound_parser/parser.rb', line 62 def images @raw["msg"]["images"] end |
#recipient_emails ⇒ Object
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_names ⇒ Object
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 |
#recipients ⇒ Object
54 55 56 |
# File 'lib/mandrill_inbound_parser/parser.rb', line 54 def recipients @raw["msg"]["to"] end |
#sender_name ⇒ Object
Returns the sender name
26 27 28 |
# File 'lib/mandrill_inbound_parser/parser.rb', line 26 def sender_name @raw["msg"]["from_name"] end |
#subject ⇒ Object
Returns the subject
46 47 48 |
# File 'lib/mandrill_inbound_parser/parser.rb', line 46 def subject @raw["msg"]["subject"] end |
#text ⇒ Object
Message content as text
31 32 33 |
# File 'lib/mandrill_inbound_parser/parser.rb', line 31 def text @raw["msg"]["text"] end |