(888) 475-FLOW(3569)

Orders Ruby

Orders Ruby
# Create an order with two units of sku-2

require 'flowcommerce'

ORG = 'playground'
client = FlowCommerce.instance(:token => 'HlGgfflLamiTQJ')

order = client.orders.put_by_number(ORG, 'R726941',
 ::Io::Flow::V0::Models::OrderPutForm.new(
 :items => [
 { :number => "sku-2", :quantity => 2 }
 ],
 :destination => {
 :streets => ["123 Yonge Street"],
 :city => "Toronto",
 :province => "Ontario",
 :postal => "M5C 1W4",
 :country => "CAN"
 }
 ),
 :country => "CAN"
 )

puts "Order %s" % order.number
order.prices.each do |p|
 puts " - #{p.name}: #{p.label}"
end
puts " - TOTAL: #{order.total.label}"