Class: ShopifyAPI::InventoryLevel

Inherits:
Rest::Base show all
Extended by:
T::Sig
Defined in:
lib/shopify_api/rest/resources/2021_07/inventory_level.rb,
lib/shopify_api/rest/resources/2021_10/inventory_level.rb,
lib/shopify_api/rest/resources/2022_01/inventory_level.rb,
lib/shopify_api/rest/resources/2022_04/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, #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.


12
13
14
15
16
17
18
19
# File 'lib/shopify_api/rest/resources/2021_07/inventory_level.rb', line 12

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.


32
33
34
# File 'lib/shopify_api/rest/resources/2021_07/inventory_level.rb', line 32

def available
  @available
end

#inventory_item_idObject (readonly)

Returns the value of attribute inventory_item_id.


34
35
36
# File 'lib/shopify_api/rest/resources/2021_07/inventory_level.rb', line 34

def inventory_item_id
  @inventory_item_id
end

#location_idObject (readonly)

Returns the value of attribute location_id.


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

def location_id
  @location_id
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.


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

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


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/shopify_api/rest/resources/2021_07/inventory_level.rb', line 72

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


48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/shopify_api/rest/resources/2021_07/inventory_level.rb', line 48

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


100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/shopify_api/rest/resources/2021_07/inventory_level.rb', line 100

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


127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/shopify_api/rest/resources/2021_07/inventory_level.rb', line 127

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


155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/shopify_api/rest/resources/2021_07/inventory_level.rb', line 155

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