Sha256: db6c6f68830eaccd47811bc0e77b0e86dc4f14884b7b1c6ca3abc2e2b020918d

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module CTM
  class Account < Base
    attr_reader :id
    attr_accessor :name, :status, :stats, :balance

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

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

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

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

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

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

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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ctm-0.4.2 lib/ctm/account.rb