forked from bigcommerce/bigcommerce-api-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
brand.rb
36 lines (28 loc) · 722 Bytes
/
brand.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
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 brands
@brands = Bigcommerce::Brand.all(page: 1)
# Get a brand
puts Bigcommerce::Brand.find(@brands.first.id)
# Get a count of brands
puts Bigcommerce::Brand.count
# Create a brand
@brand = Bigcommerce::Brand.create(
name: SecureRandom.hex,
page_title: "Title #{SecureRandom.hex}"
)
puts @brand
# Update a brand
puts Bigcommerce::Brand.update(
@brand.id,
name: 'Foobar'
)
# Delete a brand
puts Bigcommerce::Brand.destroy(@brand.id)
# Delete all brands
# Bigcommerce::Brand.destroy_all