sample-ordering-spec Pub Share

0 $mock:: catalog.addProduct (name, sku)
   . (productId=1234)

$when:: cust.addToCart
   cart.get
   warehouse.check
   $ifc:: (payload == "ok") cart.addItem
   $ifc:: (payload != "ok") . (error="Not enough items in the inventory")

msg cart.get  (customer)

msg cart.addItem  (sku, quantity, customer)

CART

$when:: cart.create (app? ?= "diesel", customer, metadata)
   . (cart={app:app,id:customer,metadata:metadata,items:[]})

$when:: cart.get (customer)
   . (cart=(cart || {id:customer,items:[]}))

0 $mock:: cart.addItem (sku, quantity, customer)
   cart.get
   . (cart=(cart + {items:{sku:sku,quantity:quantity}}))

$when:: cart.checkout
   order.create
   ctx.foreach (list=cart[="ite..., item="item"="item", msg="warehouse.check"="warehouse...)
   warehouse.check
   billing.charge
   shipping.package
   shipping.send

0 $mock:: cart.total
   . (total=45)

Shipping

Warehouse

msg warehouse.check  (productId, quantity)

msg warehouse.reserve  (productId, quantity, cartId)

msg warehouse.provision  (reservationId)

Let's say we don't have mor than 3 of anything...

0 $mock:: warehouse.check (quantity <= 3)
   . (payload="ok")
0 $mock:: warehouse.check (quantity > 3)
   . (payload="nok")

0 $mock:: warehouse.reserve (productId, quantity, cartId)
   . (reservationId="123")

0 $mock:: warehouse.provision (reservationId)
   $ifc:: (reservationId == "123") . (payload="ok")
   $ifc:: (reservationId != "123") . (payload="nope")

0 $mock:: warehouse.get (sku, quantity)
   .


Was this useful?    

By: Razie | 2017-04-06 .. 2022-06-21 | Tags: spec , dsl , amazon , private


Viewed 848 times ( | History | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2024, all rights reserved.