forked from bigcommerce/bigcommerce-api-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.rb
53 lines (45 loc) · 996 Bytes
/
order.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
49
50
51
52
53
require 'bigcommerce'
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 orders
@orders = Bigcommerce::Order.all
puts @orders
# Get an order
@order = @orders[0]
puts Bigcommerce::Order.find(@order.id)
# Get a count of orders
puts Bigcommerce::Order.count
# Create an order
@order = Bigcommerce::Order.create(
billing_address: {
first_name: 'Karl',
last_name: 'The Fog',
street_1: '685 Market St.',
city: 'San Francisco',
state: 'California',
zip: '94019',
country: 'United States',
email: 'test@example.com'
},
products: [
{
product_id: 5,
quantity: 2
}
]
)
puts @order
# Update an order
puts Bigcommerce::Order.update(
@order.id,
billing_address: {
last_name: 'TheFog'
}
)
# Delete an order
puts Bigcommerce::Order.destroy(@order.id)
# Delete all orders
# puts Bigcommerce::Order.destroy_all