-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathallocation.rb
More file actions
27 lines (22 loc) · 832 Bytes
/
allocation.rb
File metadata and controls
27 lines (22 loc) · 832 Bytes
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
require 'veeqo'
Veeqo.configure do |config|
config.api_key = ENV['VEEQO_API_KEY']
end
@order = Veeqo::Order.all.first
@warehouse = Veeqo::Warehouse.all.first
@sellable = @order[:line_items].first[:sellable]
# Create allocation
@allocation = Veeqo::Allocation.create(@order.id, warehouse_id: @warehouse.id, connection: connection)
# Update allocation
Veeqo::Allocation.update(@order.id,
@allocation.id,
warehouse_id: @warehouse.id,
line_items_attributes:
[
{
sellable_id: @sellable.id,
quantity: 3
}
])
# Destroy allocation
Veeqo::Allocation.destroy(@order.id, @allocation.id)