Sha256: ebc8cbb274c54c4eeaf4343b133a7e6b8ecf9e1f7f540118771f7f07d3f7c910
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
module Moip2 class InvoiceApi attr_reader :client def initialize(client) @client = client end def base_path "/v2/invoices" end def show(invoice_external_id) Resource::Invoice.new client, client.get("#{base_path}/#{invoice_external_id}") end def create(invoice) Resource::Invoice.new client, client.post(base_path, invoice) end def update(invoice_external_id, invoice) Resource::Invoice.new client, client.put("#{base_path}/#{invoice_external_id}", invoice) end def list(begin_date, end_date) find_all(begin_date: begin_date, end_date: end_date) end 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 = { 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
moip2-1.2.0 | lib/moip2/invoice_api.rb |