lib/alegra/invoices.rb in alegra-0.1.2.3 vs lib/alegra/invoices.rb in alegra-0.4.1

- old
+ new

@@ -1,23 +1,30 @@ module Alegra - class Invoices - attr_reader :client - - def initialize(client) - @client = client - end - - # @param id [ Interger ] + class Invoices < Alegra::Record + # @param id [ Integer ] # @return [ Hash ] def find(id) - client.get("invoices/#{ id }") + client.get("invoices/#{id}") end # Returs all invoices + # @param params [ Hash ] + # - start [ Integer ] + # - limit [ Integer ] + # - order_direction [ String ] + # - order_field [ string ] + # - metadata [ Boolean ] + # - id [ Integer ] + # - date [ String ] + # - due_date [ String ] + # - status [ String ] + # - client_name [ String ] + # - client_identification [ String ] + # - number_template_full_number # @return [ Array ] - def list() - client.get('invoices') + def list(params = {}) + client.get('invoices', params) end # Creates a invoice # @param params [ Hash ] # - date [ String ] @@ -34,12 +41,12 @@ # - number_template [ String ] # - retenctions [ Array ] # - seller [ String ] # @return [ Hash ] def create(params) - _params = params.deep_camel_case_lower_keys - client.post('invoices', _params) + sanitize_params = params.deep_camel_case_lower_keys + client.post('invoices', sanitize_params) end # Creates a invoice # @param params [ Hash ] # - date [ String ] @@ -56,22 +63,22 @@ # - number_template [ String ] # - retenctions [ Array ] # - seller [ String ] # @return [ Hash ] def update(id, params) - _params = params.deep_camel_case_lower_keys - client.put("invoices/#{ id }", _params) + sanitize_params = params.deep_camel_case_lower_keys + client.put("invoices/#{id}", sanitize_params) end # @param id [ Integer ] # @param params [ Hash ] # - emails [ Array ] # - send_copy_to_user [ Boolean ] # - invoiceType [ String ] # @return [ Hash ] def send_by_email(id, params) - _params = params.deep_camel_case_lower_keys - client.post("invoices/#{ id }/email", _params) + sanitize_params = params.deep_camel_case_lower_keys + client.post("invoices/#{id}/email", sanitize_params) end end end