Audit APIs ########## GreyMatter allows performing inventory audits in which manual count of selected inventory can be performed. Audits can be created either from the Manager Dashboard or via API. But, they can be started only from the Manager Dashboard. Audit Lifecycle *************** .. mermaid:: graph TD A[created] --> |Start Audit from MD| B[processing_start] B --> C[auditlines_created] C --> |Ongoing operations on
selected inventory/slot| D[waiting_on_conflict] C --> E[queued] D --> E E --> F[started] F --> |Some discrepancy found| G[pending_approval] F --> |No discrepancy| H[completed] G --> I[approved] G --> J[rejected] J --> K[sent_for_reaudit] Any --> L[cancelled] B --> |No matching
inventory found| M[aborted] A --> N[deleted] Any --> O[paused] class G node-failure class H node-success class I node-success class J node-failure class K node-success class L node-success class M node-failure class N node-success Audit Object ************ Audits can be of two types: location audit or SKU audit: * In a location audit, a list of slots or MSUs are specified which have to be audited, and all inventory present in those slots are audited. * In an SKU audit, product parameters are given, and all products matching those parameters are audited. All slots which have those products are brought to the audit station for this purpose. .. gm:data:: audit_id A unique auto-generated string that identifies the audit .. gm:data:: audit_param_name *required string, not unique* A string that will be displayed against the audit in manager dashboard .. gm:data:: audit_param_type Can be either ``location`` or ``sku``. .. gm:data:: audit_param_value .. gm:data:: locations_list *In case of a location audit* A list of strings denoting locations (either slot ids or MSU ids) **Example** .. sourcecode:: json { "locations_list": [ "014", "039", "001", "039.1.E.02", "014.1.E.05" ] } .. gm:data:: attributes_list *In case of SKU audit* A list of SKU selector objects. Each object has two properties: ``sku`` and ``attributes_sets``. **Example** .. sourcecode:: json { "attributes_list": [{ "attributes_sets": [{ "product_color": [ "Green" ] }], "sku": "3001" }] } Creating an Audit ***************** .. http:post:: /api-gateway/integration-service/wms-integration/butler/api/audit :reqheader Content-Type: the request's content-type has to be passed in this header :reqheader Accept: the response content type depends on :mailheader:`Accept` header :reqheader Authorization: OAuth token to authenticate :statuscode 200: No error :statuscode 400: Bad data :json string audit_id: Unique auto-generated id of the created audit. This can be used for further requests related to the audit. .. container:: toggle .. container:: header **Example: Audit by Location** .. compound:: Request .. sourcecode:: http POST /api-gateway/integration-service/wms-integration/butler/api/audit HTTP/1.1 Host: example.com Content-Type: application/json Accept: application/json, text/javascript .. literalinclude:: create_audit_location_request.json :language: JSON Response .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 .. literalinclude:: create_audit_location_response.json :language: JSON .. container:: toggle .. container:: header **Example: Audit by SKU** .. compound:: Request .. sourcecode:: http POST /api-gateway/integration-service/wms-integration/butler/api/audit HTTP/1.1 Host: example.com Content-Type: application/json Accept: application/json, text/javascript .. literalinclude:: create_audit_sku_request.json :language: JSON Response .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 .. literalinclude:: create_audit_sku_response.json :language: JSON Delete an Audit *************** An audit can only be deleted before it is started. .. http:delete:: /api-gateway/integration-service/wms-integration/butler/api/audit/delete/(audit_id) :param audit_id: Id of the audit to be deleted. :reqheader Authorization: OAuth token to authenticate :statuscode 200: No error :statuscode 404: Audit id not found Audit Notifications ******************* All Audit notifications follow the generic notification format (see :ref:`Event Notifications`), and contain the relevant payload in the :gm:data:`notification.notification_data` attribute. Audit notifications are generated for most :ref:`Audit Lifecycle` events. Audit Created Notification -------------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: audit_created_notification.json :language: JSON Auditlines Created Notification ------------------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: auditlines_created_notification.json :language: JSON Waiting on Conflict Notification -------------------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: waiting_on_conflict_notification.json :language: JSON Queued Notification ------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: queued_notification.json :language: JSON Started Notification -------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: started_notification.json :language: JSON Completed Notification ---------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: completed_notification.json :language: JSON Pending Approval Notification ----------------------------- .. container:: toggle .. container:: header Example with 1 auditline started and 1 pending approval .. literalinclude:: pending_approval_notification_1.json :language: JSON .. container:: toggle .. container:: header Example with 1 auditline completed and 1 pending approval .. literalinclude:: pending_approval_notification_2.json :language: JSON Rejected Notification --------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: rejected_notification.json :language: JSON Approved Notification --------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: approved_notification.json :language: JSON Sent for Re-audit Notification ------------------------------ .. container:: toggle .. container:: header Show/Hide .. literalinclude:: sent_for_reaudit_notification.json :language: JSON Cancelled Notification ---------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: cancelled_notification.json :language: JSON Deleted Notification -------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: deleted_notification.json :language: JSON Aborted Notification -------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: aborted_notification.json :language: JSON