class TotalVoice::Conta

Inicializa o HTTP client

Constants

ROTA_CONTA
ROTA_WEBHOOK_DEFAULT

Attributes

client[R]

Public Class Methods

new(client) click to toggle source
# File lib/api/conta.rb, line 11
def initialize(client)
  @client = client
end

Public Instance Methods

atualizar(id, data) click to toggle source

Atualiza os dados da Subconta

@param [Integer] id @param [Hash] data @return [json]

# File lib/api/conta.rb, line 32
def atualizar(id, data)
  @client.put(Route.new([ROTA_CONTA, id.to_s]), data)
end
buscar(id) click to toggle source

Busca os dados da Subconta

@param [Integer] id @return [json]

# File lib/api/conta.rb, line 42
def buscar(id)
  @client.get(Route.new([ROTA_CONTA, id.to_s]))
end
criar(data) click to toggle source

Cria uma conta abaixo da sua - Subconta

@param [Hash] data @return [json]

# File lib/api/conta.rb, line 21
def criar(data)
  @client.post(Route.new([ROTA_CONTA]), data)
end
excluir(id) click to toggle source

Remove uma Subconta

@param [Integer] id @return [json]

# File lib/api/conta.rb, line 52
def excluir(id)
  @client.delete(Route.new([ROTA_CONTA, id.to_s]))
end
excluir_webhook_default(nome) click to toggle source

Apaga um webhook default

@param [String] nome @return [json]

# File lib/api/conta.rb, line 102
def excluir_webhook_default(nome)
  @client.delete(Route.new([ROTA_CONTA, ROTA_WEBHOOK_DEFAULT, nome]))
end
recarga_bonus(id, nome, valor) click to toggle source

Adiciona crédito bônus nas contas criadas por mim @param [Integer] id da conta filha @param [String] nome do plano @param [Float] valor @return [json]

# File lib/api/conta.rb, line 84
def recarga_bonus(id, nome, valor)
  @client.post(Route.new([ROTA_CONTA, id.to_s, 'bonus']), { nome: nome, valor:valor })
end
relatorio() click to toggle source

Lista todas as subconta criadas por mim @return [json]

# File lib/api/conta.rb, line 60
def relatorio()
  @client.get(Route.new([ROTA_CONTA, 'relatorio']))
end
salvar_webhook_default(nome, url) click to toggle source

Cadastra ou atualiza um webhook default

@param [String] nome @param [String] url @return [json]

# File lib/api/conta.rb, line 113
def salvar_webhook_default(nome, url)
  @client.put(Route.new([ROTA_CONTA, ROTA_WEBHOOK_DEFAULT, nome]), {
    url: url
  })
end
url_recarga(url) click to toggle source

Gera uma URL para recarga de créditos

@param [String] url @return [json]

# File lib/api/conta.rb, line 70
def url_recarga(url)
  @client.get(
    Route.new([ROTA_CONTA, 'urlrecarga']),
    Query.new({ 'url_retorno': url })
  )
end
webhooks_default() click to toggle source

Retorna a lista de webhooks default configurados para esta conta @return [json]

# File lib/api/conta.rb, line 92
def webhooks_default()
  @client.get(Route.new([ROTA_CONTA, ROTA_WEBHOOK_DEFAULT]))
end