Class: CTM::Account

Inherits:
Base
  • Object
show all
Defined in:
lib/ctm/account.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#account_id, #token

Instance Method Summary collapse

Methods inherited from Base

create, #release!, #save

Constructor Details

#initialize(data, token = nil) ⇒ Account

Returns a new instance of Account.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ctm/account.rb', line 6

def initialize(data, token=nil)
  super(data, token)
  puts data.inspect
  @id = data['id']
  @name = data['name']
  @status = data['status']
  @stats = data['stats']['calls']
  if data['balance']
    @balance = "$" + (data['balance']['cents'].to_i / 100).to_s + "." + (data['balance']['cents'].to_i % 100).to_s
  end
end

Instance Attribute Details

#balanceObject

Returns the value of attribute balance.



4
5
6
# File 'lib/ctm/account.rb', line 4

def balance
  @balance
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/ctm/account.rb', line 3

def id
  @id
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/ctm/account.rb', line 4

def name
  @name
end

#statsObject

Returns the value of attribute stats.



4
5
6
# File 'lib/ctm/account.rb', line 4

def stats
  @stats
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/ctm/account.rb', line 4

def status
  @status
end

Instance Method Details

#calls(options = {}) ⇒ Object



38
39
40
# File 'lib/ctm/account.rb', line 38

def calls(options={})
  CTM::List.new('Call', options.merge(account_id: @id), @token)
end

#messages(options = {}) ⇒ Object



42
43
44
# File 'lib/ctm/account.rb', line 42

def messages(options={})
  CTM::MessageList.new(options.merge(account_id: @id), @token)
end

#numbers(options = {}) ⇒ Object



18
19
20
# File 'lib/ctm/account.rb', line 18

def numbers(options={})
  CTM::NumberList.new(options.merge(account_id: @id), @token)
end

#receiving_numbers(options = {}) ⇒ Object



22
23
24
# File 'lib/ctm/account.rb', line 22

def receiving_numbers(options={})
  CTM::List.new('ReceivingNumber', options.merge(account_id: @id), @token)
end

#sources(options = {}) ⇒ Object



26
27
28
# File 'lib/ctm/account.rb', line 26

def sources(options={})
  CTM::List.new('Source', options.merge(account_id: @id), @token)
end

#users(options = {}) ⇒ Object



30
31
32
# File 'lib/ctm/account.rb', line 30

def users(options={})
  CTM::List.new('User', options.merge(account_id: @id), @token)
end

#webhooks(options = {}) ⇒ Object



34
35
36
# File 'lib/ctm/account.rb', line 34

def webhooks(options={})
  CTM::List.new('Webhook', options.merge(account_id: @id), @token)
end