Class: ShopifyAPI::InventoryItem

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

Returns a new instance of InventoryItem.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/shopify_api/rest/resources/2022_04/inventory_item.rb', line 16

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

  @cost = T.let(nil, T.nilable(String))
  @country_code_of_origin = T.let(nil, T.nilable(String))
  @country_harmonized_system_codes = T.let(nil, T.nilable(T::Array[T.untyped]))
  @created_at = T.let(nil, T.nilable(String))
  @harmonized_system_code = T.let(nil, T.nilable(Integer))
  @id = T.let(nil, T.nilable(Integer))
  @province_code_of_origin = T.let(nil, T.nilable(String))
  @requires_shipping = T.let(nil, T.nilable(T::Boolean))
  @sku = T.let(nil, T.nilable(String))
  @tracked = T.let(nil, T.nilable(T::Boolean))
  @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

#costObject (readonly)

Returns the value of attribute cost.



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

def cost
  @cost
end

#country_code_of_originObject (readonly)

Returns the value of attribute country_code_of_origin.



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

def country_code_of_origin
  @country_code_of_origin
end

#country_harmonized_system_codesObject (readonly)

Returns the value of attribute country_harmonized_system_codes.



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

def country_harmonized_system_codes
  @country_harmonized_system_codes
end

#created_atObject (readonly)

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#harmonized_system_codeObject (readonly)

Returns the value of attribute harmonized_system_code.



49
50
51
# File 'lib/shopify_api/rest/resources/2022_04/inventory_item.rb', line 49

def harmonized_system_code
  @harmonized_system_code
end

#idObject (readonly)

Returns the value of attribute id.



51
52
53
# File 'lib/shopify_api/rest/resources/2022_04/inventory_item.rb', line 51

def id
  @id
end

#province_code_of_originObject (readonly)

Returns the value of attribute province_code_of_origin.



53
54
55
# File 'lib/shopify_api/rest/resources/2022_04/inventory_item.rb', line 53

def province_code_of_origin
  @province_code_of_origin
end

#requires_shippingObject (readonly)

Returns the value of attribute requires_shipping.



55
56
57
# File 'lib/shopify_api/rest/resources/2022_04/inventory_item.rb', line 55

def requires_shipping
  @requires_shipping
end

#skuObject (readonly)

Returns the value of attribute sku.



57
58
59
# File 'lib/shopify_api/rest/resources/2022_04/inventory_item.rb', line 57

def sku
  @sku
end

#trackedObject (readonly)

Returns the value of attribute tracked.



59
60
61
# File 'lib/shopify_api/rest/resources/2022_04/inventory_item.rb', line 59

def tracked
  @tracked
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



61
62
63
# File 'lib/shopify_api/rest/resources/2022_04/inventory_item.rb', line 61

def updated_at
  @updated_at
end

Class Method Details

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



90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/shopify_api/rest/resources/2022_04/inventory_item.rb', line 90

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

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

.find(id:, session: ShopifyAPI::Context.active_session) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/shopify_api/rest/resources/2022_04/inventory_item.rb', line 70

def find(
  id:,
  session: ShopifyAPI::Context.active_session
)
  result = base_find(
    session: session,
    ids: {id: id},
    params: {},
  )
  T.cast(result[0], T.nilable(InventoryItem))
end