Class: MessagePub::Recipient

Inherits:
Object
  • Object
show all
Defined in:
lib/messagepub/recipient.rb

Overview

Represents a MessagePub recipient. For more info, visit messagepub.com/documentation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Recipient

Returns a new instance of Recipient.



24
25
26
27
28
29
30
# File 'lib/messagepub/recipient.rb', line 24

def initialize(options={})
  @position = options[:position]
  @channel = options[:channel]
  @address = options[:address]
  @id = options[:id]
  @status = options[:status]
end

Instance Attribute Details

#addressObject

The address for recipient. Depending on the channel, this can be a phone number, an email, a username, etc…



16
17
18
# File 'lib/messagepub/recipient.rb', line 16

def address
  @address
end

#channelObject

The communication channel for the recipient. It can be one of: sms, phone, email, twitter, aim, gchat



12
13
14
# File 'lib/messagepub/recipient.rb', line 12

def channel
  @channel
end

#idObject

The unique id for this recipient for that particular notification.



19
20
21
# File 'lib/messagepub/recipient.rb', line 19

def id
  @id
end

#positionObject

The position of this recipient in the list of recipients for the notification.



8
9
10
# File 'lib/messagepub/recipient.rb', line 8

def position
  @position
end

#statusObject

The status of this recipient. Can be one of: sending, scheduled, sent, received, or failed



22
23
24
# File 'lib/messagepub/recipient.rb', line 22

def status
  @status
end

Instance Method Details

#to_xmlObject

Returns an XML representation of the recipient.



33
34
35
36
37
38
39
40
# File 'lib/messagepub/recipient.rb', line 33

def to_xml
value = '<recipient>'
value += '<position>' + self.position.to_s + '</position>'
value += '<channel>' + self.channel + '</channel>'
value += '<address>' + self.address + '</address>'                
value += '</recipient>'
value
end