forked from bigcommerce/bigcommerce-api-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sku.rb
51 lines (41 loc) · 1.02 KB
/
sku.rb
1
2
3
4
5
6
7
8
9
10
11
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
42
43
44
45
46
47
48
49
50
51
require 'bigcommerce'
require 'securerandom'
Bigcommerce.configure do |config|
config.store_hash = ENV['BC_STORE_HASH']
config.client_id = ENV['BC_CLIENT_ID']
config.access_token = ENV['BC_ACCESS_TOKEN']
end
@product = Bigcommerce::Product.all[0]
# Create a product sku
@sku = Bigcommerce::Sku.create(
@product.id,
sku: SecureRandom.hex,
options: [
product_option_id: 3,
option_value_id: 73
]
)
puts @sku
# List product skus
@skus = Bigcommerce::Sku.all(@product.id)
puts @skus
# Get a count of product skus
puts Bigcommerce::Sku.count(@product.id)
# Get a count of all product skus
puts Bigcommerce::Sku.count_all
# Get a product sku
puts Bigcommerce::Sku.find(@product.id, @sku.id)
# Update a product sku
puts Bigcommerce::Sku.update(
@product.id,
@sku.id,
sku: SecureRandom.hex,
options: [
product_option_id: 3,
option_value_id: 73
]
)
# Delete a product image
puts Bigcommerce::Sku.destroy(@product.id, @sku.id)
# Delete all product skus
# puts Bigcommerce::Sku.destroy_all(@product.id)