Class: Fakturoid::Api::Expense
- Inherits:
-
Object
- Object
- Fakturoid::Api::Expense
show all
- Includes:
- Base
- Defined in:
- lib/fakturoid/api/expense.rb
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
8
9
10
11
12
|
# File 'lib/fakturoid/api/expense.rb', line 8
def all(params = {})
request_params = Utils.permit_params(params, :since, :updated_since, :page, :subject_id, :custom_id, :number, :variable_symbol, :status) || {}
perform_request(HTTP_GET, "expenses.json", request_params: request_params)
end
|
#create(payload = {}) ⇒ Object
40
41
42
|
# File 'lib/fakturoid/api/expense.rb', line 40
def create(payload = {})
perform_request(HTTP_POST, "expenses.json", payload: payload)
end
|
#download_attachment(expense_id, id) ⇒ Object
#fire(id, event) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/fakturoid/api/expense.rb', line 33
def fire(id, event)
request_params = { event: event }
Utils.validate_numerical_id(id)
perform_request(HTTP_POST, "expenses/#{id}/fire.json", request_params: request_params)
end
|
#search(params = {}) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/fakturoid/api/expense.rb', line 14
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, "expenses/search.json", request_params: request_params)
end
|
#update(id, payload = {}) ⇒ Object
44
45
46
47
|
# File 'lib/fakturoid/api/expense.rb', line 44
def update(id, payload = {})
Utils.validate_numerical_id(id)
perform_request(HTTP_PATCH, "expenses/#{id}.json", payload: payload)
end
|