Class: Moip2::InvoiceApi
- Inherits:
-
Object
- Object
- Moip2::InvoiceApi
- Defined in:
- lib/moip2/invoice_api.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #base_path ⇒ Object
- #create(invoice) ⇒ Object
- #find_all(email: nil, begin_date: nil, end_date: nil, limit: 20, offset: 0, q: nil, filters: nil) ⇒ Object
-
#initialize(client) ⇒ InvoiceApi
constructor
A new instance of InvoiceApi.
- #list(begin_date, end_date) ⇒ Object
- #show(invoice_external_id) ⇒ Object
- #update(invoice_external_id, invoice) ⇒ Object
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
#client ⇒ Object (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_path ⇒ Object
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, q: nil, filters: nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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) ⇒ 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 |