Class: ShopifyAPI::Variant

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


12
13
14
15
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
# File 'lib/shopify_api/rest/resources/2021_07/variant.rb', line 12

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.


59
60
61
# File 'lib/shopify_api/rest/resources/2021_07/variant.rb', line 59

def barcode
  @barcode
end

#compare_at_priceObject (readonly)

Returns the value of attribute compare_at_price.


61
62
63
# File 'lib/shopify_api/rest/resources/2021_07/variant.rb', line 61

def compare_at_price
  @compare_at_price
end

#created_atObject (readonly)

Returns the value of attribute created_at.


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

def created_at
  @created_at
end

#fulfillment_serviceObject (readonly)

Returns the value of attribute fulfillment_service.


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

def fulfillment_service
  @fulfillment_service
end

#gramsObject (readonly)

Returns the value of attribute grams.


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

def grams
  @grams
end

#idObject (readonly)

Returns the value of attribute id.


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

def id
  @id
end

#image_idObject (readonly)

Returns the value of attribute image_id.


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

def image_id
  @image_id
end

#inventory_item_idObject (readonly)

Returns the value of attribute inventory_item_id.


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

def inventory_item_id
  @inventory_item_id
end

#inventory_managementObject (readonly)

Returns the value of attribute inventory_management.


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

def inventory_management
  @inventory_management
end

#inventory_policyObject (readonly)

Returns the value of attribute inventory_policy.


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

def inventory_policy
  @inventory_policy
end

#inventory_quantityObject (readonly)

Returns the value of attribute inventory_quantity.


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

def inventory_quantity
  @inventory_quantity
end

#inventory_quantity_adjustmentObject (readonly)

Returns the value of attribute inventory_quantity_adjustment.


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

def inventory_quantity_adjustment
  @inventory_quantity_adjustment
end

#old_inventory_quantityObject (readonly)

Returns the value of attribute old_inventory_quantity.


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

def old_inventory_quantity
  @old_inventory_quantity
end

#optionObject (readonly)

Returns the value of attribute option.


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

def option
  @option
end

#positionObject (readonly)

Returns the value of attribute position.


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

def position
  @position
end

#presentment_pricesObject (readonly)

Returns the value of attribute presentment_prices.


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

def presentment_prices
  @presentment_prices
end

#priceObject (readonly)

Returns the value of attribute price.


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

def price
  @price
end

#product_idObject (readonly)

Returns the value of attribute product_id.


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

def product_id
  @product_id
end

#requires_shippingObject (readonly)

Returns the value of attribute requires_shipping.


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

def requires_shipping
  @requires_shipping
end

#skuObject (readonly)

Returns the value of attribute sku.


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

def sku
  @sku
end

#tax_codeObject (readonly)

Returns the value of attribute tax_code.


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

def tax_code
  @tax_code
end

#taxableObject (readonly)

Returns the value of attribute taxable.


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

def taxable
  @taxable
end

#titleObject (readonly)

Returns the value of attribute title.


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

def title
  @title
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.


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

def updated_at
  @updated_at
end

#weightObject (readonly)

Returns the value of attribute weight.


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

def weight
  @weight
end

#weight_unitObject (readonly)

Returns the value of attribute weight_unit.


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

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


164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/shopify_api/rest/resources/2021_07/variant.rb', line 164

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


189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/shopify_api/rest/resources/2021_07/variant.rb', line 189

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


139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/shopify_api/rest/resources/2021_07/variant.rb', line 139

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


119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/shopify_api/rest/resources/2021_07/variant.rb', line 119

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