Class: Moip2::InvoiceApi

Inherits:
Object
  • Object
show all
Defined in:
lib/moip2/invoice_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ InvoiceApi

Returns a new instance of InvoiceApi.



5
6
7
# File 'lib/moip2/invoice_api.rb', line 5

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/moip2/invoice_api.rb', line 3

def client
  @client
end

Instance Method Details

#base_pathObject



9
10
11
# File 'lib/moip2/invoice_api.rb', line 9

def base_path
  "/v2/invoices"
end

#create(invoice) ⇒ Object



17
18
19
# File 'lib/moip2/invoice_api.rb', line 17

def create(invoice)
  Resource::Invoice.new client, client.post(base_path, invoice)
end

#find_all(email: nil, begin_date: nil, end_date: nil, limit: 20, offset: 0) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/moip2/invoice_api.rb', line 29

def find_all(email: nil, begin_date: nil, end_date: nil, limit: 20, offset: 0)
  Resource::Invoice.new(
    client,
    client.get("#{base_path}?email=#{email}&begin=#{begin_date}"\
               "&end=#{end_date}&limit=#{limit}&offset=#{offset}"),
  )
end

#list(begin_date, end_date) ⇒ Object



25
26
27
# File 'lib/moip2/invoice_api.rb', line 25

def list(begin_date, end_date)
  find_all(begin_date: begin_date, end_date: end_date)
end

#show(invoice_external_id) ⇒ Object



13
14
15
# File 'lib/moip2/invoice_api.rb', line 13

def show(invoice_external_id)
  Resource::Invoice.new client, client.get("#{base_path}/#{invoice_external_id}")
end

#update(invoice_external_id, invoice) ⇒ Object



21
22
23
# File 'lib/moip2/invoice_api.rb', line 21

def update(invoice_external_id, invoice)
  Resource::Invoice.new client, client.put("#{base_path}/#{invoice_external_id}", invoice)
end