-
Notifications
You must be signed in to change notification settings - Fork 124
/
option_value.rb
43 lines (35 loc) · 970 Bytes
/
option_value.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
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
@option = Bigcommerce::Option.create(
name: SecureRandom.hex,
type: 'CS'
)
# Create an option value
@option_value = Bigcommerce::OptionValue.create(
@option.id,
label: SecureRandom.hex,
sort_order: 0,
value: '#FFFFFF'
)
puts @option_value
# List option values
puts Bigcommerce::OptionValue.all(@option.id)
# Get an option value
puts Bigcommerce::OptionValue.find(@option.id, @option_value.id)
# Update an option value
puts Bigcommerce::OptionValue.update(
@option.id,
@option_value.id,
label: SecureRandom.hex,
sort_order: 0,
value: '#000000'
)
# Delete an option value
puts Bigcommerce::OptionValue.destroy(@option.id, @option_value.id)
# Delete multiple option values
# puts Bigcommerce::OptionValue.destroy_all(@option.id)