Class: Esendex::Account::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/xednese/account/messages.rb

Constant Summary collapse

PAGE_COUNT =
25

Instance Method Summary collapse

Constructor Details

#initialize(credentials, reference) ⇒ 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.


8
9
10
11
# File 'lib/xednese/account/messages.rb', line 8

def initialize(credentials, reference)
  @credentials = credentials
  @reference = reference
end

Instance Method Details

#receivedEnumerable<Responses::MessageHeader>

Returns an Enumerable that iterates over all received messages. Requests are made for fixed size pages when required.

Returns:

  • (Enumerable<Responses::MessageHeader>)

    an Enumerable that iterates over all received messages. Requests are made for fixed size pages when required.


33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/xednese/account/messages.rb', line 33

def received
  Seq::Paged.new do |page|
    params = {
      startIndex: PAGE_COUNT * page,
      count: PAGE_COUNT
    }

    Client.get(@credentials, "v1.0/inbox/#{@reference}/messages", params) do |status, data|
      Responses::MessageHeaders.deserialise(data).message_headers
    end
  end
end

#sentEnumerable<Responses::MessageHeader>

Returns an Enumerable that iterates over all sent messages. Requests are made for fixed size pages when required.

Returns:

  • (Enumerable<Responses::MessageHeader>)

    an Enumerable that iterates over all sent messages. Requests are made for fixed size pages when required.


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/xednese/account/messages.rb', line 16

def sent
  Seq::Paged.new do |page|
    params = {
      startIndex: PAGE_COUNT * page,
      count: PAGE_COUNT,
      accountReference: @reference
    }

    Client.get(@credentials, 'v1.0/messageheaders', params) do |status, data|
      Responses::MessageHeaders.deserialise(data).message_headers
    end
  end
end