Hemi API Custom work - Simplified Stock & Acknowledgement
Version | Created by | Date | Notes |
---|---|---|---|
1.0 | Danail Deltchev | 01.08.2024 | First Publish |
In the current version of the API we should create a few new calls to service a customer needs
These are Simplified Stock
and Acknowledgement
calls
The problem these two are solving are to allow for a simpler Stock update into Hemi only by SKU as opposed to the current one which needs to be provided by Item Location Quantity > ID
and to allow for insertion on the new Acknowledgement module so we can then utilise it for further updates to the MPs
Simplified Stock API
This needs to be a new call into the Hemi open API that will follow the below structure:
[
{
"productIdentifier": "PRD0001",
"locationId": 1,
"quantity": 15
},
{
"productIdentifier": "5904248195236",
"locationId": 1,
"quantity": 7
}
]
Fields are self explanatory but still below the mapping we should import just in case:
API Field | Hemi Mapping | Hemi Notes |
---|---|---|
productIdentifier | Item Location Quantity > Product Identifier | If a combination with this Product Identifier and Location does not exist it should be created. Otherwise it should be updated |
locationId | Item Location Quantity > Location | |
quantity | Item Location Quantity > Quantity | If it is the same value we should not update the Quantity OR the date_created. It will be good to still update the Magento Date so we can track when we’ve received a stock refresher. If Quantity is updated then date_created should be updated too |
Additional Information:
- It would be good to implement the following validations:
- If the SKU is not existing in “Product Details” section Skip in the API
- If Location ID is not existing in “Locations” section Skip this record in the API
- Any record that can’t be processed or is skipped for non existent SKU/LocationId should return an error in whatever format you decide but it should hold the SKU + Location ID so it is known which record is provided
- Any record that doesn’t have a SKU or Location ID should be treated as such that have nonexistent ones (If there is another good way to just return error for these let me know and I can add it instead of this)
- Any other issues should return a simple standard error as per our API
Path: https://qa3.wearepentagon.com/wap/API/en/openapi-simple-stock
Method: POST
Acknowledgement API
This needs to be a new call into the Hemi open API that will follow the below structure:
[
{
"orderId": 101472215,
"items": [
{
"SKU": "195481458188_ET",
"acceptedQuantity": 2
}
]
},
{
"orderId": 1014295553,
"items": [
{
"SKU": "PRD0001",
"acceptedQuantity": 10
},
{
"SKU": "PRD0002",
"acceptedQuantity": 10
}
]
},
{
"orderId": 10003,
"items": []
}
]
Example Mapping:
API Field | Hemi Mapping | Hemi Notes | |
---|---|---|---|
orderId | Orders > ID | This is the field we need to use to map to our order so we can store an Acknowledgement | |
items | |||
SKU | Order Acknowledgement Row > Product in Order Id | Based on the SKU provided we should map to the Hemi Product in Order (for the relevant order) and get the ID to use for the Acknowledgement Row. In this iteration of this call I don’t care for the case if there are multiple lines in Product in Order with the same SKU | |
acceptedQuantity | Order Acknowledgement Row Lines | We should use the Accepted Quantity to create the right amount of lines with Accept or Reject Acknowledgement Action . The way it should work is based on the SKU pick the right Product in Order and pick its total ordered quantity. Then based on the acceptedQuantity from the API create an Acknowledgement row line we should create a row line with Action “Accept” for every quantity in acceptedQuantity and for each that is not there (essentially such that are not accepted) create a “Reject” row line. This means that if we receive 0 acceptedQuantity we should create an Acknowledgement with all quantities for the product with Action Reject |
Additional Information:
- We should have the following validations:
- If the Order ID exists within Hemi? If not this is an error response for this message
- If the Order in Hemi is on a different than “Awaiting Acknowledgement” Hemi Order Status we should return an error response for this message
- If the Order in Hemi has an acknowledgement that is on a Pending, Sent or Completed status. If there is such we should block this and return an error response for this message
- If there is no items section at all provided we should return an error for this message
- If the SKU does not exist in Hemi for this Order we should return an error for this message
- If the acceptedQuantity is less than 0 or more than the ordered quantity for the product in Hemi we should return an error response for this message
- If we pass validations we should create an Order Acknowledgement with the following fields
- Order Acknowledgement
- Status - Pending
- Order Acknowledgement rows - a row for each “Item” provided in the API call with the following info filled in:
- Product in Order ID (as per the mapping above)
- Order Acknowledgement row lines - a line for each ordered quantity with the following information filled in:
- Order Item Line ID - picked from the Order Item Line table - having in mind we should have all quantities this means we should have all lines in here too
- Acknowledgement Action - every quantity from
acceptedQuantity
should have anAccept
action. Everything else should have aReject
action
- Order Acknowledgement
- If we receive an empty items array (
”items” : []
) we are to treat it as all products for this order have been rejected. Or in other words like all SKUs have receivedacceptedQuantity
= 0
Path: https://qa3.wearepentagon.com/wap/API/en/openapi-order-acknowledge
Method: POST