Class: ShopifyAPI::InventoryLevel

Inherits:
Rest::Base show all
Extended by:
T::Sig
Defined in:
lib/shopify_api/rest/resources/2022_04/inventory_level.rb,
lib/shopify_api/rest/resources/2022_07/inventory_level.rb,
lib/shopify_api/rest/resources/2022_10/inventory_level.rb,
lib/shopify_api/rest/resources/2023_01/inventory_level.rb,
lib/shopify_api/rest/resources/2023_04/inventory_level.rb,
lib/shopify_api/rest/resources/2023_07/inventory_level.rb,
lib/shopify_api/rest/resources/2023_10/inventory_level.rb,
lib/shopify_api/rest/resources/2024_01/inventory_level.rb,
lib/shopify_api/rest/resources/2024_04/inventory_level.rb,
lib/shopify_api/rest/resources/2024_07/inventory_level.rb,
lib/shopify_api/rest/resources/2024_10/inventory_level.rb

Instance Attribute Summary collapse

Attributes inherited from Rest::Base

#errors, #original_state

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Rest::Base

api_call_limit, base_find, class_name, create_instance, create_instances_from_response, #delete, get_path, get_path_ids, has_many?, has_one?, inherited, json_body_name, json_response_body_names, #method_missing, next_page?, next_page_info, prev_page?, prev_page_info, primary_key, read_only_attributes, request, #respond_to_missing?, retry_request_after, #save, #save!, #to_hash

Constructor Details

#initialize(session: ShopifyAPI::Context.active_session, from_hash: nil) ⇒ InventoryLevel

Returns a new instance of InventoryLevel.



19
20
21
22
23
24
25
26
27
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 19

def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)

  @available = T.let(nil, T.nilable(Integer))
  @inventory_item_id = T.let(nil, T.nilable(Integer))
  @location_id = T.let(nil, T.nilable(Integer))
  @updated_at = T.let(nil, T.nilable(String))

  super(session: session, from_hash: from_hash)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ShopifyAPI::Rest::Base

Instance Attribute Details

#availableObject (readonly)

Returns the value of attribute available.



40
41
42
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 40

def available
  @available
end

#inventory_item_idObject (readonly)

Returns the value of attribute inventory_item_id.



42
43
44
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 42

def inventory_item_id
  @inventory_item_id
end

#location_idObject (readonly)

Returns the value of attribute location_id.



44
45
46
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 44

def location_id
  @location_id
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



46
47
48
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 46

def updated_at
  @updated_at
end

Class Method Details

.all(inventory_item_ids: nil, location_ids: nil, limit: nil, updated_at_min: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 80

def all(
  inventory_item_ids: nil,
  location_ids: nil,
  limit: nil,
  updated_at_min: nil,
  session: ShopifyAPI::Context.active_session,
  **kwargs
)
  response = base_find(
    session: session,
    ids: {},
    params: {inventory_item_ids: inventory_item_ids, location_ids: location_ids, limit: limit, updated_at_min: updated_at_min}.merge(kwargs).compact,
  )

  T.cast(response, T::Array[InventoryLevel])
end

.delete(inventory_item_id: nil, location_id: nil, session: ShopifyAPI::Context.active_session) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 56

def delete(
  inventory_item_id: nil,
  location_id: nil,
  session: ShopifyAPI::Context.active_session
)
  request(
    http_method: :delete,
    operation: :delete,
    session: session,
    ids: {},
    params: {inventory_item_id: inventory_item_id, location_id: location_id},
  )
end

Instance Method Details

#adjust(inventory_item_id: nil, location_id: nil, available_adjustment: nil, body: nil, **kwargs) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 108

def adjust(
  inventory_item_id: nil,
  location_id: nil,
  available_adjustment: nil,
  body: nil,
  **kwargs
)
  self.class.request(
    http_method: :post,
    operation: :adjust,
    session: @session,
    ids: {},
    params: {inventory_item_id: inventory_item_id, location_id: location_id, available_adjustment: available_adjustment}.merge(kwargs).compact,
    body: body,
    entity: self,
  )
end

#connect(inventory_item_id: nil, location_id: nil, relocate_if_necessary: nil, body: nil, **kwargs) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 135

def connect(
  inventory_item_id: nil,
  location_id: nil,
  relocate_if_necessary: nil,
  body: nil,
  **kwargs
)
  self.class.request(
    http_method: :post,
    operation: :connect,
    session: @session,
    ids: {},
    params: {inventory_item_id: inventory_item_id, location_id: location_id, relocate_if_necessary: relocate_if_necessary}.merge(kwargs).compact,
    body: body,
    entity: self,
  )
end

#set(inventory_item_id: nil, location_id: nil, available: nil, disconnect_if_necessary: nil, body: nil, **kwargs) ⇒ Object



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 163

def set(
  inventory_item_id: nil,
  location_id: nil,
  available: nil,
  disconnect_if_necessary: nil,
  body: nil,
  **kwargs
)
  self.class.request(
    http_method: :post,
    operation: :set,
    session: @session,
    ids: {},
    params: {inventory_item_id: inventory_item_id, location_id: location_id, available: available, disconnect_if_necessary: disconnect_if_necessary}.merge(kwargs).compact,
    body: body,
    entity: self,
  )
end