Class: Internode::Account

Inherits:
Resource show all
Defined in:
lib/internode/account.rb

Constant Summary collapse

PATH =
"/api/v1.5"

Instance Attribute Summary

Attributes inherited from Resource

#client, #path

Instance Method Summary collapse

Methods inherited from Resource

#content, content_attr

Constructor Details

#initialize(options = {}) ⇒ Account

Returns a new instance of Account.



5
6
7
8
9
# File 'lib/internode/account.rb', line 5

def initialize(options = {})
  client = options.fetch(:client){ Client.new(username: options[:username], password: options[:password]) }
  path = options.fetch(:path){ PATH }
  super(client: client, path: path)
end

Instance Method Details

#detailsObject



17
18
19
# File 'lib/internode/account.rb', line 17

def details
  concurrent_map(&:details)
end

#servicesObject



11
12
13
14
15
# File 'lib/internode/account.rb', line 11

def services
  @services ||= content.css("services service").map do |node|
    Service.new(client: client, path: node.attr("href").text)
  end
end

#usageObject



21
22
23
# File 'lib/internode/account.rb', line 21

def usage
  concurrent_map(&:usage)
end