forked from bigcommerce/bigcommerce-api-ruby
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoption_set_option.rb
48 lines (39 loc) · 1.16 KB
/
option_set_option.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
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_set = Bigcommerce::OptionSet.create(
name: SecureRandom.hex
)
@option = Bigcommerce::Option.create(
name: SecureRandom.hex,
type: 'CS'
)
# Create an option set option
@option_set_option = Bigcommerce::OptionSetOption.create(
@option_set.id,
option_id: @option.id,
display_name: SecureRandom.hex,
sort_order: 1,
is_required: true
)
puts @option_set_option
# List option set options
puts Bigcommerce::OptionSetOption.all(@option_set.id)
# Get an option set option
puts Bigcommerce::OptionSetOption.find(@option_set.id, @option_set_option.id)
# Update an option set option
puts Bigcommerce::OptionSetOption.update(
@option_set.id,
@option_set_option.id,
display_name: 'Pick a color...',
sort_order: 2,
is_required: false
)
# Delete an option set option
puts Bigcommerce::OptionSetOption.destroy(@option_set.id, @option_set_option.id)
# Delete multiple option set options
# puts Bigcommerce::OptionSetOption.destroy_all(@option_set.id)