Class: ShopifyAPI::InventoryItem

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


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/shopify_api/rest/resources/2021_07/inventory_item.rb', line 12

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.


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

def cost
  @cost
end

#country_code_of_originObject (readonly)

Returns the value of attribute country_code_of_origin.


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

def country_code_of_origin
  @country_code_of_origin
end

#country_harmonized_system_codesObject (readonly)

Returns the value of attribute country_harmonized_system_codes.


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

def country_harmonized_system_codes
  @country_harmonized_system_codes
end

#created_atObject (readonly)

Returns the value of attribute created_at.


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

def created_at
  @created_at
end

#harmonized_system_codeObject (readonly)

Returns the value of attribute harmonized_system_code.


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

def harmonized_system_code
  @harmonized_system_code
end

#idObject (readonly)

Returns the value of attribute id.


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

def id
  @id
end

#province_code_of_originObject (readonly)

Returns the value of attribute province_code_of_origin.


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

def province_code_of_origin
  @province_code_of_origin
end

#requires_shippingObject (readonly)

Returns the value of attribute requires_shipping.


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

def requires_shipping
  @requires_shipping
end

#skuObject (readonly)

Returns the value of attribute sku.


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

def sku
  @sku
end

#trackedObject (readonly)

Returns the value of attribute tracked.


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

def tracked
  @tracked
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.


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

def updated_at
  @updated_at
end

Class Method Details

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


86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/shopify_api/rest/resources/2021_07/inventory_item.rb', line 86

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


66
67
68
69
70
71
72
73
74
75
76
# File 'lib/shopify_api/rest/resources/2021_07/inventory_item.rb', line 66

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