class Moip2::InvoiceApi
Attributes
client[R]
Public Class Methods
new(client)
click to toggle source
# File lib/moip2/invoice_api.rb, line 5 def initialize(client) @client = client end
Public Instance Methods
base_path()
click to toggle source
# File lib/moip2/invoice_api.rb, line 9 def base_path "/v2/invoices" end
create(invoice)
click to toggle source
# 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, q: nil, filters: nil)
click to toggle source
# File lib/moip2/invoice_api.rb, line 29 def find_all(email: nil, begin_date: nil, end_date: nil, limit: 20, offset: 0, q: nil, filters: nil) encoded_filters = Moip2::Util::FiltersEncoder.encode(filters) # `URI.encode...` will accept nil params, but they will pollute the URI params = { email: email, begin_date: begin_date, end_date: end_date, limit: limit, offset: offset, q: q, filters: encoded_filters, }.reject { |_, value| value.nil? } query_string = URI.encode_www_form(params) Resource::Invoice.new( client, client.get("#{base_path}?#{query_string}"), ) end
list(begin_date, end_date)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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