OS1 Services
Order Service
Order Validation and Enrichment Plugins
4 min
the order service allows the configuration of one or more external plugins or webhooks for the initiated order these plugins can be used for validating the order and/or enrichment of the order some examples of the use cases for plugins are as follows serviceability check unique location id computation for consignee address determining the client warehouse for pickup end to end sla computation for the order creating plugin to create a plugin, call the post /plugins endpoint and pass the following parameters in the request body true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type the following sample payload shows how to create a new plugin named validationtypetest post /plugins { "name" "validationtypetest", "httpurl" "http //example getos1 com", "httpmethod" "put", "httpheaders" { "x accessid" "access", "x cors" "cors" }, "httprequestbodytemplate" { "data" { "$val" { "clientid" { "$expr" "$ clientid" }, "clientorderid" { "$expr" "$ clientorderid" }, "contact" { "$val" { "details" { "$expr" "$ contact" } } } } } }, "requesttimeout" "5000", "callbacktimeout" "600" } creating plugin workflow if you have more than one external plugin or webhook for the initiated order, you need to create a plugin workflow this workflow will define the sequence in which the plugins will be executed (in case of more than one plugin) to create a plugin workflow, call the post /plugin workflows endpoint and pass the following parameters in the request body true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type the following sample request body shows how to create a new plugin workflow named test post /plugin workflows { "name" "pluginwf", "event" "event", "workflow" { "name" "workfloww", "description" "workflow for validation", "tag" \[ { "name" "team", "value" "hq" } ], "start" "plugin\ e76a9fbb f231 586c 8390 b95b8520699a", "flows" \[ { "name" "plugin1", "pluginid" "plugin\ e76a9fbb f231 586c 8390 b95b8520699a", "description" "view details of delivery", "next" \[ { "condition" { "==" \[ "$ plugin1 output success", true ] }, "plugin" "plugin2" }, { "condition" { "==" \[ "$ plugin1 output errorcode", "invalid details" ] }, "plugin" "plugin3" } ] }, { "name" "plugin2", "pluginid" "plugin\ e76a9fbb f231 586c 8390 b95b8520699a", "description" "pincode serviceability check", "next" \[ { "condition" { "==" \[ "$ plugin2 output success", true ] }, "plugin" "pluginworkflowsuccess" }, { "condition" { "==" \[ "$ plugin2 output errorcode", "pincode unavialable" ] }, "plugin" "pluginworkflowfailure" }, { "plugin" "pluginworkflowfailure" } ] }, { "name" "plugin3", "pluginid" "plugin\ e76a9fbb f231 586c 8390 b95b8520699a", "description" "enrichment", "next" \[ { "condition" { "==" \[ "$ plugin1 output success", true ] }, "plugin" "pluginworkflowsuccess" }, { "condition" { "==" \[ "$ plugin1 output errorcode", "order invalid" ] }, "plugin" "markorderfailed" }, { "plugin" "markorderfailed" } ] } ] } }