Class: TotalVoice::Ura

Inherits:
Object
  • Object
show all
Defined in:
lib/api/ura.rb

Overview

Inicializa o HTTP client

Constant Summary collapse

ROTA_URA =
"/ura"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Ura

Returns a new instance of Ura.



10
11
12
# File 'lib/api/ura.rb', line 10

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/api/ura.rb', line 7

def client
  @client
end

Instance Method Details

#atualizar(id, data) ⇒ json

Atualiza uma ura

Parameters:

  • id (Integer)
  • data (Hash)

Returns:

  • (json)


55
56
57
# File 'lib/api/ura.rb', line 55

def atualizar(id, data)
  @client.put(Route.new([ROTA_URA, id.to_s]), data)
end

#buscar(id) ⇒ json

Busca uam URA pelo seu ID

Parameters:

  • id (Integer)

Returns:

  • (json)


44
45
46
# File 'lib/api/ura.rb', line 44

def buscar(id)
  @client.get(Route.new([ROTA_URA, id.to_s]))
end

#criar(nome, data) ⇒ json

Cria um nova URA

Parameters:

  • nome (String)
  • data (Hash)

Returns:

  • (json)


21
22
23
24
25
26
# File 'lib/api/ura.rb', line 21

def criar(nome, data)
  @client.post(Route.new([ROTA_URA]), {
    nome: nome,
    dados: data
  })
end

#excluir(id) ⇒ json

Remove uma Ura

Parameters:

  • id (Integer)

Returns:

  • (json)


34
35
36
# File 'lib/api/ura.rb', line 34

def excluir(id)
  @client.delete(Route.new([ROTA_URA, id.to_s]))
end

#relatorio(data_inicio, data_fim) ⇒ json

Gera relatório de todas as URAs da conta

Parameters:

  • data_inicio (DateTime|String)
  • data_fim (DateTime|String)

Returns:

  • (json)


66
67
68
69
70
71
# File 'lib/api/ura.rb', line 66

def relatorio(data_inicio, data_fim)
  @client.get(
    Route.new([ROTA_URA, 'relatorio']),
    Query.new({ 'data_inicio': Time.parse(data_inicio.to_s).utc, 'data_fim': Time.parse(data_fim.to_s).utc })
  )
end