Class: Esendex::Messages

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

Constant Summary collapse

PAGE_COUNT =
25

Instance Method Summary collapse

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.

See Also:



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.

Parameters:

  • id (String)

    the id of the message to get

Returns:



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

#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.



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).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.



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).message_headers
    end
  end
end