Class: Fakturoid::Api::Invoice
- Inherits:
-
Object
- Object
- Fakturoid::Api::Invoice
show all
- Includes:
- Base
- Defined in:
- lib/fakturoid/api/invoice.rb
Constant Summary
collapse
- INDEX_PARAMS =
[:since, :until, :updated_since, :updated_until, :page, :subject_id, :custom_id, :number, :status, :document_type].freeze
Instance Attribute Summary
Attributes included from Base
#client
Instance Method Summary
collapse
Methods included from Base
#initialize, #perform_request
Instance Method Details
#all(params = {}) ⇒ Object
10
11
12
13
14
|
# File 'lib/fakturoid/api/invoice.rb', line 10
def all(params = {})
request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
perform_request(HTTP_GET, "invoices.json", request_params: request_params)
end
|
#create(payload = {}) ⇒ Object
47
48
49
|
# File 'lib/fakturoid/api/invoice.rb', line 47
def create(payload = {})
perform_request(HTTP_POST, "invoices.json", payload: payload)
end
|
#download_attachment(invoice_id, id) ⇒ Object
#download_pdf(id) ⇒ Object
29
30
31
32
|
# File 'lib/fakturoid/api/invoice.rb', line 29
def download_pdf(id)
Utils.validate_numerical_id(id)
perform_request(HTTP_GET, "invoices/#{id}/download.pdf", headers: { content_type: "application/pdf" })
end
|
#fire(id, event) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/fakturoid/api/invoice.rb', line 40
def fire(id, event)
request_params = { event: event }
Utils.validate_numerical_id(id)
perform_request(HTTP_POST, "invoices/#{id}/fire.json", request_params: request_params)
end
|
#search(params = {}) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/fakturoid/api/invoice.rb', line 16
def search(params = {})
Utils.validate_search_query(query: params[:query], tags: params[:tags], allow_tags: true)
request_params = Utils.permit_params(params, :query, :tags, :page)
perform_request(HTTP_GET, "invoices/search.json", request_params: request_params)
end
|
#update(id, payload = {}) ⇒ Object
51
52
53
54
|
# File 'lib/fakturoid/api/invoice.rb', line 51
def update(id, payload = {})
Utils.validate_numerical_id(id)
perform_request(HTTP_PATCH, "invoices/#{id}.json", payload: payload)
end
|