Class: Alegra::Invoices

Inherits:
Record
  • Object
show all
Defined in:
lib/alegra/invoices.rb

Instance Attribute Summary

Attributes inherited from Record

#client

Instance Method Summary collapse

Methods inherited from Record

#initialize

Constructor Details

This class inherits a constructor from Alegra::Record

Instance Method Details

#create(params) ⇒ Hash

Creates a invoice

Parameters:

  • params (Hash)
    • date [ String ]

    • due_date [ String ]

    • price_list [ Array ]

    • currency [ Array ]

    • payments [ Array ]

    • client [ Integer ] or [ Hash ]

    • items [ Array ]

    • observations [ Array ]

    • anotations [ Array ]

    • terms_conditions [ Array ]

    • status [ String ]

    • number_template [ String ]

    • retenctions [ Array ]

    • seller [ String ]

Returns:



45
46
47
48
# File 'lib/alegra/invoices.rb', line 45

def create(params)
  sanitize_params = params.deep_camel_case_lower_keys
  client.post('invoices', sanitize_params)
end

#find(id) ⇒ Hash

Parameters:

  • id (Integer)

Returns:



5
6
7
# File 'lib/alegra/invoices.rb', line 5

def find(id)
  client.get("invoices/#{id}")
end

#list(params = {}) ⇒ Array

Returs all invoices

Parameters:

  • params (Hash) (defaults to: {})
    • 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

Returns:



24
25
26
# File 'lib/alegra/invoices.rb', line 24

def list(params = {})
  client.get('invoices', params)
end

#send_by_email(id, params) ⇒ Hash

Parameters:

  • id (Integer)
  • params (Hash)
    • emails [ Array ]

    • send_copy_to_user [ Boolean ]

    • invoiceType [ String ]

Returns:



78
79
80
81
# File 'lib/alegra/invoices.rb', line 78

def send_by_email(id, params)
  sanitize_params = params.deep_camel_case_lower_keys
  client.post("invoices/#{id}/email", sanitize_params)
end

#update(id, params) ⇒ Hash

Creates a invoice

Parameters:

  • params (Hash)
    • date [ String ]

    • due_date [ String ]

    • price_list [ Array ]

    • currency [ Array ]

    • payments [ Array ]

    • client [ Integer ] or [ Hash ]

    • items [ Array ]

    • observations [ Array ]

    • anotations [ Array ]

    • terms_conditions [ Array ]

    • status [ String ]

    • number_template [ String ]

    • retenctions [ Array ]

    • seller [ String ]

Returns:



67
68
69
70
# File 'lib/alegra/invoices.rb', line 67

def update(id, params)
  sanitize_params = params.deep_camel_case_lower_keys
  client.put("invoices/#{id}", sanitize_params)
end