Valet order flow with API calls (advanced)
When a valet order is created, it can be managed in the admin UI https://your-account.storeganise.com/admin/valet-orders/orderid (where "your-account" is your Storganise subdomain and "orderid" the order ID)
Let's see on the API level how it's done
1. Load the order using GET https://your-account.storeganise.com/api/v1/admin/valet-orders/orderid?include=job,customFields because we will need to manipulate the order job steps
In the response, the job fields contains a list of steps, the first step not completed looks like:
{ id: "stepid", type: "order_start", state: "ready", .. }
2. Start the order using PUT https://your-account.storeganise.com/api/v1/admin/valet-orders/orderid/steps/stepid {"state": "completed"}
3. Pick boxes using PUT https://your-account.storeganise.com/api/v1/admin/items {"command":"valetOrder_add","itemSids":["itemid"],"data":{"valetOrderId":"orderid"}}
Currently the active order step looks like: { id: "stepid2", type: "items_pickEmptyBoxes", state: "ready", .. }
like in 2. confirm the step using: PUT https://your-account.storeganise.com/api/v1/admin/valet-orders/orderid/steps/stepid2 {"state": "completed"}
4. Deliver boxes using PUT https://your-account.storeganise.com/api/v1/admin/items {"command":"valetOrder_deliver","itemSids":["itemid"],"data":{"valetOrderId":"orderid"}}
and confirm using PUT https://your-account.storeganise.com/api/v1/admin/valet-orders/orderid/steps/stepid3 {"state": "completed"} where stepid3 is the step of type "items_deliver"
5. Collect items using PUT https://your-account.storeganise.com/api/v1/admin/items {"command":"valetOrder_collect","itemSids":["itemid"],"data":{"valetOrderId":"orderid"}}
and confirm using PUT https://your-account.storeganise.com/api/v1/admin/valet-orders/orderid/steps/stepid4 {"state": "completed"} where stepid4 is the step of type "items_collect"
6. Put away using PUT https://your-account.storeganise.com/api/v1/admin/items {"command":"valetOrder_store","itemSids":["itemid"],"data":{"valetOrderId":"orderid","location":"S1"}}
and confirm using PUT https://your-account.storeganise.com/api/v1/admin/valet-orders/orderid/steps/stepid5 {"state": "completed"} where stepid5 is the step of type "items_store"
Now the order is fully completed
Note: at any time before completion, you can edit the order data or add charges using PUT https://your-account.storeganise.com/api/v1/admin/valet-orders/orderid, see the docs at https://your-account.storeganise.com/api/docs/admin/valet-orders#admin_valet-orders.PUT_valetOrderId