Class: Moip::Assinaturas::Invoice

Inherits:
Object
  • Object
show all
Defined in:
lib/moip-assinaturas/invoice.rb

Class Method Summary collapse

Class Method Details

.details(id, opts = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/moip-assinaturas/invoice.rb', line 21

def details(id, opts={})
  response = Moip::Assinaturas::Client.details_invoice(id, opts)
  hash     = JSON.load(response.body)
  hash     = hash.with_indifferent_access if hash

  case response.code
  when 200
    return {
      success:  true,
      invoice:  hash
    }
  when 404
    return {
      success: false,
      message: 'not found'
    }
  else
    raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice")
  end
end

.list(subscription_code, opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/moip-assinaturas/invoice.rb', line 6

def list(subscription_code, opts={})
  response = Moip::Assinaturas::Client.list_invoices(subscription_code, opts)
  hash     = JSON.load(response.body).with_indifferent_access

  case response.code
  when 200
    return {
      success:  true,
      invoices: hash[:invoices]
    }
  else
    raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice")
  end
end