-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathorder.rb
More file actions
48 lines (39 loc) · 1.01 KB
/
order.rb
File metadata and controls
48 lines (39 loc) · 1.01 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
require 'veeqo'
Veeqo.configure do |config|
config.api_key = ENV['VEEQO_API_KEY']
end
# List order
@orders = Veeqo::Order.all
puts @orders
# Get a order
@order = @orders[0]
puts Veeqo::Order.find(@order.id)
# Create a order
customer = Veeqo::Customer.create(email: 'example@email.com')
channel = Veeqo::Channel.create(name: 'Example')
product = Veeqo::Product.all.last
@tag = Veeqo::Tag.all.first
@order = Veeqo::Order.create(
order: {
channel_id: channel.id,
customer_id: customer.id,
line_items_attributes: [
{
quantity: 5,
sellable_id: product.sellables.first[:id]
}
]
}
)
puts @order
# Update a order
puts Veeqo::Order.update(@order.id, notes: 'example')
# Set tag to order(orders)
# Params:
# order_ids - array of order ids
# tags_ids - id of tags that would be assigned to those orders
Veeqo::Order.bulk_tagging([@order.id], [@tag.id])
# Delete a order
puts Veeqo::Order.destroy(@order.id)
# Orders quantity by params
puts Veeqo::Order.count(status: 'awaiting_fulfillment')