(888) 475-FLOW(3569)

Orders Scala

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

import io.flow.v0.{Authorization, Client}
import io.flow.v0.models._

object Main extends App {

 import scala.concurrent.ExecutionContext.Implicits.global

 val client = new Client(auth = Some(Authorization.Basic("HlGgfflLamiTQJ")))
 val org = "playground"

 client.orders.putByNumber(
 org,
 "R726941",
 orderPutForm = OrderPutForm(
 items = Seq(
 LineItemForm(number = "sku-2", quantity = 2)
 ),
 destination = Some(
 OrderAddress(
 streets = Some(Seq("123 Yonge Street")),
 city = Some("123 Yonge Street"),
 province = Some("Ontario"),
 postal = Some("M5C 1W4"),
 country = Some("CAN")
 )
 )
 ),
 country = Some("CAN")
 ).map { order =>
 
 println(s"Order ${order.number}")
 
 order.prices.foreach { p =>
 println(s" - ${p.name.getOrElse("price")}: ${p.label}")
 }
 
 println(s" - TOTAL: ${order.total.label}")
 
 client.closeAsyncHttpClient()
 }

}