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

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

base_find, class_name, create_instance, create_instances_from_response, #delete, get_path, has_many?, has_one?, 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?, #save, #save!, #to_hash

Constructor Details

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

Returns a new instance of InventoryLevel.



16
17
18
19
20
21
22
23
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 16

def initialize(session: ShopifyAPI::Context.active_session)
  super(session: session)

  @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))
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.



36
37
38
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 36

def available
  @available
end

#inventory_item_idObject (readonly)

Returns the value of attribute inventory_item_id.



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

def inventory_item_id
  @inventory_item_id
end

#location_idObject (readonly)

Returns the value of attribute location_id.



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

def location_id
  @location_id
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



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

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



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 76

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



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 52

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



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 104

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



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 131

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



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/shopify_api/rest/resources/2022_04/inventory_level.rb', line 159

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