Class: MessagePub::Notification
- Inherits:
-
Object
- Object
- MessagePub::Notification
- Defined in:
- lib/messagepub/notification.rb
Overview
Represents a MessagePub notification. For more info, visit messagepub.com/documentation
Instance Attribute Summary collapse
-
#body ⇒ Object
The body of the message to send.
-
#escalation ⇒ Object
The amount of time (in minutes) to wait before sending to the next recipient in the list.
-
#id ⇒ Object
The unique id for the notification.
-
#postback_url ⇒ Object
If postback_url is set in your account settings, this is the URL where MessagePub will post any replies it gets for this notification.
-
#recipients ⇒ Object
readonly
The array of recipients to which this notification will go to.
-
#send_at ⇒ Object
The time in UTC at which the notification will be sent.
-
#subject ⇒ Object
The subject of the message to send (for emails only).
Instance Method Summary collapse
- #add_recipient(rcpt) ⇒ Object
-
#initialize(options = {}) ⇒ Notification
constructor
A new instance of Notification.
-
#to_xml ⇒ Object
Returns an XML representation of the notification that can be POSTed to the REST API.
Constructor Details
#initialize(options = {}) ⇒ Notification
Returns a new instance of Notification.
30 31 32 33 34 35 36 37 38 |
# File 'lib/messagepub/notification.rb', line 30 def initialize(={}) @body = [:body] @subject = [:subject] @escalation = [:escalation] @postback_url = [:postback_url] @send_at = [:send_at] @recipients = [] @id = nil end |
Instance Attribute Details
#body ⇒ Object
The body of the message to send.
8 9 10 |
# File 'lib/messagepub/notification.rb', line 8 def body @body end |
#escalation ⇒ Object
The amount of time (in minutes) to wait before sending to the next recipient in the list.
14 15 16 |
# File 'lib/messagepub/notification.rb', line 14 def escalation @escalation end |
#id ⇒ Object
The unique id for the notification.
25 26 27 |
# File 'lib/messagepub/notification.rb', line 25 def id @id end |
#postback_url ⇒ Object
If postback_url is set in your account settings, this is the URL where MessagePub will post any replies it gets for this notification. For more info, visit messagepub.com/documentation/replies.
19 20 21 |
# File 'lib/messagepub/notification.rb', line 19 def postback_url @postback_url end |
#recipients ⇒ Object (readonly)
The array of recipients to which this notification will go to.
28 29 30 |
# File 'lib/messagepub/notification.rb', line 28 def recipients @recipients end |
#send_at ⇒ Object
The time in UTC at which the notification will be sent.
22 23 24 |
# File 'lib/messagepub/notification.rb', line 22 def send_at @send_at end |
#subject ⇒ Object
The subject of the message to send (for emails only)
11 12 13 |
# File 'lib/messagepub/notification.rb', line 11 def subject @subject end |
Instance Method Details
#add_recipient(rcpt) ⇒ Object
40 41 42 |
# File 'lib/messagepub/notification.rb', line 40 def add_recipient(rcpt) @recipients << rcpt if rcpt.class == Recipient end |
#to_xml ⇒ Object
Returns an XML representation of the notification that can be POSTed to the REST API.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/messagepub/notification.rb', line 45 def to_xml value = '<notification>' value += '<body>' + self.body + '</body>' value += '<subject>' + self.subject + '</subject>' unless self.subject.blank? value += '<escalation>' + self.escalation.to_s + '</escalation>' if self.escalation value += '<postback_url>' + self.postback_url + '</postback_url>' if self.postback_url value += '<send_at>' + self.send_at + '</send_at>' if self.send_at value += '<recipients>' self.recipients.each do |rcpt| value += rcpt.to_xml end value += '</recipients></notification>' value end |