forked from bigcommerce/bigcommerce-api-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomer.rb
38 lines (30 loc) · 833 Bytes
/
customer.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
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 customers
@customers = Bigcommerce::Customer.all(page: 1)
puts @customers
# Get a customer
puts Bigcommerce::Customer.find(@customers.first.id)
# Get a count of customers
puts Bigcommerce::Customer.count
# Create a customer
@customer = Bigcommerce::Customer.create(
first_name: 'Karl',
last_name: 'The Fog',
email: "#{SecureRandom.hex(5)}@example.com"
)
puts @customer
# Update a customer
puts Bigcommerce::Customer.update(
@customer.id,
first_name: 'Karrrl'
)
# Delete a customer
puts Bigcommerce::Customer.destroy(@customer.id)
# Delete all customers
# puts Bigcommerce::Customer.destroy_all