Class: ShopifyAPI::InventoryLevel
- Inherits:
-
Base
- Object
- ActiveResource::Base
- Base
- ShopifyAPI::InventoryLevel
show all
- Defined in:
- lib/shopify_api/resources/inventory_level.rb
Class Method Summary
collapse
-
.element_path(prefix_options = {}, query_options = nil) ⇒ Object
The default path structure in ActiveResource for delete would result in: /admin/api/<version>/inventory_levels/#{ inventory_level.id }.json?#{ params }, but since InventoryLevels are a second class resource made up of a Where and a What (Location and InventoryItem), it does not have a resource ID.
Instance Method Summary
collapse
Methods inherited from Base
activate_session, api_version, api_version=, #as_json, clear_session, early_july_pagination?, #encode, headers, init_prefix, init_prefix_explicit, #persisted?, prefix, prefix=, prefix_source, resource_prefix, resource_prefix=, version_validation!
Methods included from Countable
#count
Class Method Details
.element_path(prefix_options = {}, query_options = nil) ⇒ Object
The default path structure in ActiveResource for delete would result in: /admin/api/<version>/inventory_levels/#{ inventory_level.id }.json?#{ params }, but since InventoryLevels are a second class resource made up of a Where and a What (Location and InventoryItem), it does not have a resource ID. Here we redefine element_path to remove the id so HTTP DELETE requests go to /admin/api/<version>/inventory_levels.json?#{ params } instead.
13
14
15
16
|
# File 'lib/shopify_api/resources/inventory_level.rb', line 13
def self.element_path(prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}"
end
|
Instance Method Details
#adjust(available_adjustment) ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/shopify_api/resources/inventory_level.rb', line 44
def adjust(available_adjustment)
body = {
location_id: location_id,
inventory_item_id: inventory_item_id,
available_adjustment: available_adjustment
}
load_attributes_from_response(
self.class.post(:adjust, {}, body.to_json)
)
end
|
#connect(relocate_if_necessary: nil) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/shopify_api/resources/inventory_level.rb', line 24
def connect(relocate_if_necessary: nil)
body = { location_id: location_id, inventory_item_id: inventory_item_id }
body[:relocate_if_necessary] = relocate_if_necessary unless relocate_if_necessary.nil?
load_attributes_from_response(
self.class.post(:connect, {}, body.to_json)
)
end
|
#destroy ⇒ Object
18
19
20
21
22
|
# File 'lib/shopify_api/resources/inventory_level.rb', line 18
def destroy
load_attributes_from_response(
self.class.delete('/', location_id: location_id, inventory_item_id: inventory_item_id)
)
end
|
#set(new_available, disconnect_if_necessary: nil) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/shopify_api/resources/inventory_level.rb', line 32
def set(new_available, disconnect_if_necessary: nil)
body = {
location_id: location_id,
inventory_item_id: inventory_item_id,
available: new_available
}
body[:disconnect_if_necessary] = disconnect_if_necessary unless disconnect_if_necessary.nil?
load_attributes_from_response(
self.class.post(:set, {}, body.to_json)
)
end
|