-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathcategory.rb
More file actions
37 lines (29 loc) · 771 Bytes
/
category.rb
File metadata and controls
37 lines (29 loc) · 771 Bytes
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
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
# List categories
@categories = Bigcommerce::Category.all
puts @categories
# Get a category
@category = @categories[0]
puts Bigcommerce::Category.find(@category.id)
# Get a count of categories
puts Bigcommerce::Category.count
# Create a category
@category = Bigcommerce::Category.create(
name: SecureRandom.hex
)
puts @category
# Update a category
puts Bigcommerce::Category.update(
@category.id,
name: 'Foobar'
)
# Delete a category
puts Bigcommerce::Category.destroy(@category.id)
# Delete all categories
# Bigcommerce::Category.destroy_all