Class: ShopifyAPI::Variant

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

Returns a new instance of Variant.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 16

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

  @barcode = T.let(nil, T.nilable(String))
  @compare_at_price = T.let(nil, T.nilable(String))
  @created_at = T.let(nil, T.nilable(String))
  @fulfillment_service = T.let(nil, T.nilable(String))
  @grams = T.let(nil, T.nilable(Integer))
  @id = T.let(nil, T.nilable(Integer))
  @image_id = T.let(nil, T.nilable(Integer))
  @inventory_item_id = T.let(nil, T.nilable(Integer))
  @inventory_management = T.let(nil, T.nilable(String))
  @inventory_policy = T.let(nil, T.nilable(String))
  @inventory_quantity = T.let(nil, T.nilable(Integer))
  @inventory_quantity_adjustment = T.let(nil, T.nilable(Integer))
  @old_inventory_quantity = T.let(nil, T.nilable(Integer))
  @option = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
  @position = T.let(nil, T.nilable(Integer))
  @presentment_prices = T.let(nil, T.nilable(T::Array[T.untyped]))
  @price = T.let(nil, T.nilable(String))
  @product_id = T.let(nil, T.nilable(Integer))
  @requires_shipping = T.let(nil, T.nilable(T::Boolean))
  @sku = T.let(nil, T.nilable(String))
  @tax_code = T.let(nil, T.nilable(String))
  @taxable = T.let(nil, T.nilable(T::Boolean))
  @title = T.let(nil, T.nilable(String))
  @updated_at = T.let(nil, T.nilable(String))
  @weight = T.let(nil, T.nilable(Float))
  @weight_unit = 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

#barcodeObject (readonly)

Returns the value of attribute barcode.



63
64
65
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 63

def barcode
  @barcode
end

#compare_at_priceObject (readonly)

Returns the value of attribute compare_at_price.



65
66
67
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 65

def compare_at_price
  @compare_at_price
end

#created_atObject (readonly)

Returns the value of attribute created_at.



67
68
69
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 67

def created_at
  @created_at
end

#fulfillment_serviceObject (readonly)

Returns the value of attribute fulfillment_service.



69
70
71
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 69

def fulfillment_service
  @fulfillment_service
end

#gramsObject (readonly)

Returns the value of attribute grams.



71
72
73
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 71

def grams
  @grams
end

#idObject (readonly)

Returns the value of attribute id.



73
74
75
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 73

def id
  @id
end

#image_idObject (readonly)

Returns the value of attribute image_id.



75
76
77
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 75

def image_id
  @image_id
end

#inventory_item_idObject (readonly)

Returns the value of attribute inventory_item_id.



77
78
79
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 77

def inventory_item_id
  @inventory_item_id
end

#inventory_managementObject (readonly)

Returns the value of attribute inventory_management.



79
80
81
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 79

def inventory_management
  @inventory_management
end

#inventory_policyObject (readonly)

Returns the value of attribute inventory_policy.



81
82
83
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 81

def inventory_policy
  @inventory_policy
end

#inventory_quantityObject (readonly)

Returns the value of attribute inventory_quantity.



83
84
85
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 83

def inventory_quantity
  @inventory_quantity
end

#inventory_quantity_adjustmentObject (readonly)

Returns the value of attribute inventory_quantity_adjustment.



85
86
87
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 85

def inventory_quantity_adjustment
  @inventory_quantity_adjustment
end

#old_inventory_quantityObject (readonly)

Returns the value of attribute old_inventory_quantity.



87
88
89
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 87

def old_inventory_quantity
  @old_inventory_quantity
end

#optionObject (readonly)

Returns the value of attribute option.



89
90
91
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 89

def option
  @option
end

#positionObject (readonly)

Returns the value of attribute position.



91
92
93
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 91

def position
  @position
end

#presentment_pricesObject (readonly)

Returns the value of attribute presentment_prices.



93
94
95
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 93

def presentment_prices
  @presentment_prices
end

#priceObject (readonly)

Returns the value of attribute price.



95
96
97
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 95

def price
  @price
end

#product_idObject (readonly)

Returns the value of attribute product_id.



97
98
99
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 97

def product_id
  @product_id
end

#requires_shippingObject (readonly)

Returns the value of attribute requires_shipping.



99
100
101
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 99

def requires_shipping
  @requires_shipping
end

#skuObject (readonly)

Returns the value of attribute sku.



101
102
103
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 101

def sku
  @sku
end

#tax_codeObject (readonly)

Returns the value of attribute tax_code.



103
104
105
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 103

def tax_code
  @tax_code
end

#taxableObject (readonly)

Returns the value of attribute taxable.



105
106
107
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 105

def taxable
  @taxable
end

#titleObject (readonly)

Returns the value of attribute title.



107
108
109
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 107

def title
  @title
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



109
110
111
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 109

def updated_at
  @updated_at
end

#weightObject (readonly)

Returns the value of attribute weight.



111
112
113
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 111

def weight
  @weight
end

#weight_unitObject (readonly)

Returns the value of attribute weight_unit.



113
114
115
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 113

def weight_unit
  @weight_unit
end

Class Method Details

.all(product_id: nil, limit: nil, presentment_currencies: nil, since_id: nil, fields: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 168

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

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

.count(product_id: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 193

def count(
  product_id: nil,
  session: ShopifyAPI::Context.active_session,
  **kwargs
)
  request(
    http_method: :get,
    operation: :count,
    session: session,
    ids: {product_id: product_id},
    params: {}.merge(kwargs).compact,
    body: {},
    entity: nil,
  )
end

.delete(id:, product_id: nil, session: ShopifyAPI::Context.active_session) ⇒ Object



143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 143

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

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



123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/shopify_api/rest/resources/2022_04/variant.rb', line 123

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