-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathshipment.rb
More file actions
57 lines (45 loc) · 1.32 KB
/
shipment.rb
File metadata and controls
57 lines (45 loc) · 1.32 KB
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
54
55
56
57
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
@order = Bigcommerce::Order.all[0]
# Create a shipment
@order_product = Bigcommerce::OrderProduct.all(@order.id)[0]
@order_address = Bigcommerce::OrderShippingAddress.all(@order.id)[0]
@shipment = Bigcommerce::Shipment.create(
@order.id,
tracking_number: 'ups12345',
comments: 'Notes about the shipment',
order_address_id: @order_address.id,
items: [
{
order_product_id: @order_product.id,
quantity: 1
}
]
)
puts @shipment
# List shipments
@shipments = Bigcommerce::Shipment.all(@order.id)
puts @shipments
# Get a shipment
@shipment = @shipments[0]
puts Bigcommerce::Shipment.find(@order.id, @shipment.id)
# Get a count of shipments
puts Bigcommerce::Shipment.count(@order.id)
# Get a count of all shipments for all orders
puts Bigcommerce::Shipment.count_all
# Update a shipment
puts Bigcommerce::Shipment.update(
@order.id,
@shipment.id,
tracking_number: 'fedex1245',
comments: 'Notes about the shipment',
order_address_id: @order_address.id
)
# Delete a shipment
puts Bigcommerce::Shipment.destroy(@order.id, @shipment.id)
# Delete multiple shipments
# puts Bigcommerce::Shipment.destroy_all(@order.id)