Class: Esendex::Accounts
- Inherits:
-
Object
- Object
- Esendex::Accounts
- 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
- #each {|Account| ... } ⇒ Object
-
#get(id) ⇒ Account
Returns the account with the given id.
-
#initialize(credentials) ⇒ Accounts
constructor
private
A new instance of Accounts.
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.
9 10 11 |
# File 'lib/xednese/accounts.rb', line 9 def initialize(credentials) @credentials = credentials end |
Instance Method Details
#each {|Account| ... } ⇒ Object
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| Account.new(@credentials, account) end }.each(&block) end |
#get(id) ⇒ 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 |