amazon_spec Pub

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

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

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)
   . (cart=(cart + {items:{sku:sku,quantity:quantity}}))

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

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

Shipping

$when shipping.package => (cart/items $map item => inv.get (item.sku,item.quantity}))

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)
   . (result="ok")
0 $mock:: warehouse.check (quantity > 3)
   . (result="nok")

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

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

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


Was this useful?    

By: Razie | 2017-04-06 .. 2017-05-01 | Tags: spec , dsl , amazon


Viewed 114 times ( | Print ) this page.

You need to log in to post a comment!

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