OS1 Services
Order Service
Order Validation and Enrichment Plugins
4min
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 parameter description remarks name name of the plugin data type string character length 3 50 httpurl url endpoint to be called when the plugin is executed data type string httpmethod api method with which the endpoint is called data type stringvalid values post, get, and put httpheaders (optional) headers used to make the api call httprequestbodytemplate request payload body with which the api needs to be called requesttimeout (optional) data type string callbacktimeout (optional) data type string 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 parameter description remarks name name of the plugin data type string character length 3 50 event type of plugin data type string character length 3 50 workflow workflow details workflow name name of the workflow data type string character length 3 50 workflow start the plugin with which the workflow begins executing data type string workflow description description of the workflow data type string character length 3 256 workflow tag tags of the workflow with tag name and value data type string character length 3 50 flows name name of the flow data type string character length 3 50 flows pluginid the id of the plugin to be executed data type string flows description description of the flow data type string character length 3 256 flows next the next flow for execution flows next plugin the plugin that will come into action data type string character length 3 256 flows next condition condition on which this next plugin will be executed 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" } ] } ] } }