Class: Fakturoid::Api::InventoryItem
- Inherits:
-
Object
- Object
- Fakturoid::Api::InventoryItem
show all
- Includes:
- Base
- Defined in:
- lib/fakturoid/api/inventory_item.rb
Constant Summary
collapse
- INDEX_PARAMS =
[:since, :until, :updated_since, :updated_until, :page, :article_number, :sku].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/inventory_item.rb', line 10
def all(params = {})
request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
perform_request(HTTP_GET, "inventory_items.json", request_params: request_params)
end
|
#archive(id) ⇒ Object
55
56
57
58
|
# File 'lib/fakturoid/api/inventory_item.rb', line 55
def archive(id)
Utils.validate_numerical_id(id)
perform_request(HTTP_POST, "inventory_items/#{id}/archive.json")
end
|
#archived(params = {}) ⇒ Object
16
17
18
19
20
|
# File 'lib/fakturoid/api/inventory_item.rb', line 16
def archived(params = {})
request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
perform_request(HTTP_GET, "inventory_items/archived.json", request_params: request_params)
end
|
#create(payload = {}) ⇒ Object
41
42
43
|
# File 'lib/fakturoid/api/inventory_item.rb', line 41
def create(payload = {})
perform_request(HTTP_POST, "inventory_items.json", payload: payload)
end
|
#find(id) ⇒ Object
36
37
38
39
|
# File 'lib/fakturoid/api/inventory_item.rb', line 36
def find(id)
Utils.validate_numerical_id(id)
perform_request(HTTP_GET, "inventory_items/#{id}.json")
end
|
#low_quantity(params = {}) ⇒ Object
22
23
24
25
26
|
# File 'lib/fakturoid/api/inventory_item.rb', line 22
def low_quantity(params = {})
request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
perform_request(HTTP_GET, "inventory_items/low_quantity.json", request_params: request_params)
end
|
#search(params = {}) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/fakturoid/api/inventory_item.rb', line 28
def search(params = {})
Utils.validate_search_query(query: params[:query])
request_params = Utils.permit_params(params, :query, :page)
perform_request(HTTP_GET, "inventory_items/search.json", request_params: request_params)
end
|
#unarchive(id) ⇒ Object
60
61
62
63
|
# File 'lib/fakturoid/api/inventory_item.rb', line 60
def unarchive(id)
Utils.validate_numerical_id(id)
perform_request(HTTP_POST, "inventory_items/#{id}/unarchive.json")
end
|
#update(id, payload = {}) ⇒ Object
45
46
47
48
|
# File 'lib/fakturoid/api/inventory_item.rb', line 45
def update(id, payload = {})
Utils.validate_numerical_id(id)
perform_request(HTTP_PATCH, "inventory_items/#{id}.json", payload: payload)
end
|