Class: Esendex::Messages
- Inherits:
-
Object
- Object
- Esendex::Messages
- Defined in:
- lib/xednese/messages.rb
Constant Summary collapse
- PAGE_COUNT =
25
Instance Method Summary collapse
-
#get(id) ⇒ Responses::MessageHeader
The MessageHeader specified by the id given.
-
#initialize(credentials) ⇒ Messages
constructor
private
A new instance of Messages.
-
#received ⇒ Enumerable<Responses::MessageHeader>
An Enumerable that iterates over all received messages.
-
#sent ⇒ Enumerable<Responses::MessageHeader>
An Enumerable that iterates over all sent messages.
Constructor Details
#initialize(credentials) ⇒ Messages
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Messages.
7 8 9 |
# File 'lib/xednese/messages.rb', line 7 def initialize(credentials) @credentials = credentials end |
Instance Method Details
#get(id) ⇒ Responses::MessageHeader
Returns the MessageHeader specified by the id given.
46 47 48 49 50 |
# File 'lib/xednese/messages.rb', line 46 def get(id) Client.get(@credentials, "v1.0/messageheaders/#{id}") do |status, data| Responses::MessageHeader.deserialise(data) end end |
#received ⇒ Enumerable<Responses::MessageHeader>
Returns an Enumerable that iterates over all received messages. Requests are made for fixed size pages when required.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/xednese/messages.rb', line 30 def received Seq::Paged.new do |page| params = { startIndex: PAGE_COUNT * page, count: PAGE_COUNT } Client.get(@credentials, "v1.0/inbox/messages", params) do |status, data| Responses::MessageHeaders.deserialise(data). end end end |
#sent ⇒ Enumerable<Responses::MessageHeader>
Returns an Enumerable that iterates over all sent messages. Requests are made for fixed size pages when required.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/xednese/messages.rb', line 14 def sent Seq::Paged.new do |page| params = { startIndex: PAGE_COUNT * page, count: PAGE_COUNT } Client.get(@credentials, 'v1.0/messageheaders', params) do |status, data| Responses::MessageHeaders.deserialise(data). end end end |