Class: Esendex::Accounts

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/xednese/accounts.rb

Overview

Provides methods for working with Accounts. An Accounts instance is an Enumerable, and will only make requests when needed.

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ Accounts

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

See Also:



9
10
11
# File 'lib/xednese/accounts.rb', line 9

def initialize(credentials)
  @credentials = credentials
end

Instance Method Details

#each {|Account| ... } ⇒ Object

Yields:

  • (Account)

    Calls the provided block with each account the user has access to



15
16
17
18
19
20
21
# File 'lib/xednese/accounts.rb', line 15

def each(&block)
  Client.get(@credentials, 'v1.0/accounts') {|status, data|
    Responses::Accounts.deserialise(data).accounts.map do ||
      Account.new(@credentials, )
    end
  }.each(&block)
end

#get(id) ⇒ Account

Returns the account with the given id.

Parameters:

  • id (String)

    the id of the account to return

Returns:

  • (Account)

    Returns the account with the given id.



27
28
29
30
31
# File 'lib/xednese/accounts.rb', line 27

def get(id)
  Client.get(@credentials, "v1.0/accounts/#{id}") do |status, data|
    Account.new @credentials, Responses::Account.deserialise(data)
  end
end