Update discounts in bulk
Endpoint for updating scheduling discounts in bulk. All requests must be in JSON format. All responses are in JSON format. This is a protected route, which means that the authorization token with PUBLI API full permissions is needed to access this route.
Request
Request:HTTP Method | PUT | |||||
URL | Stage | https://api.stage.ananastest.com/payment/api/v1/merchant-integration/discounts | ||||
Production | https://api.ananas.rs/payment/api/v1/merchant-integration/discounts | |||||
HTTP Headers |
|
The request body represents an array of elements that have the following fields:
Fields name | Type | Description |
discounts | Array | List of discounts to be updated |
discountId | UUID | Discount ID |
newDiscountPrice | BigDecimal | New merchant inventory price on discount |
newDiscountPriceCurrency | String | Currency. Allowed values [ “RSD” ] |
newDateFrom | Date | New discount start date. Must be in dd/MM/yyyy format. Discount always start at 00:00. Cannot be changed if discount is already active. |
newDateTo | Date | New discount end date. Must be in dd/MM/yyyy format. Discounts always end at 23:59. |
newDiscountType | String | Allowed values [“SALE”, “SEASONAL_SALE”, “CLEARANCE_SALE”] |
When updating already active discounts, properties discountId, merchantInventoryId, newDiscountPrice and newDiscountPriceCurrency are mandaotry. The rest must be null.
When updating pending discounts, all properties are mandatory and must be supplied. For additional validations check Discount validation rules section.
Example of a JSON body request:
{
"discounts": [
{
"discountId": "43b49da5-9f9c-4458-b755-f9cb606aea85",
"newDateFrom": "20/07/2022",
"newDateTo": "29/07/2022",
"newDiscountPrice": "690",
"newDiscountPriceCurrency": "RSD",
"newDiscountType": "SALE"
},
{
"discountId": "43b49da5-9f9c-4458-b755-f9cb606aea85",
"newDateFrom": "20/07/2022",
"newDateTo": "29/07/2022",
"newDiscountPrice": "690",
"newDiscountPriceCurrency": "RSD",
"newDiscountType": "SEASONAL_SALE"
}
]
}
Response
Response will contain info about every discount and whether it was successfully updated or not. It is possible to have a partially successful response, i.e. some discounts are successfully updated and some are not. If the request body is invalid HTTP status code 400 will be returned. If the token is missing HTTP status code 401 will be returned. If the token is present, but does not have permissions for accessing this route, HTTP status code 403 will be returned.
Response Body:The response body represents an array of elements each indicating info about one discount:
Fields name | Type | Description |
updateResult | Array | Array of discounts |
success | Boolean | Indicates whether the discount has been successfully updated or not. If the value is true, data object will be present. If the value is false, error object wil be present. |
data | Object | Present if success is true. |
error | Object | Present if success is false |
discountId | UUID | Discount ID |
errorMessage | String | Message indicating why discount update failed |
Example of the response:
{
"updateResult": [
{
"success": false,
"error": {
"discountId": "43b49da5-9f9c-4458-b755-f9cb606aea85",
"errorMessage": "Active discounts can only be updated to have lower price than before the update"
}
},
{
"success": false,
"error": {
"discountId": "43b49da5-9f9c-4458-b755-f9cb606aea85",
"errorMessage": "Discounts that are ended can not be updated"
}
},
{
"success": true,
"data": {
"discountId": "43b49da5-9f9c-4458-b755-f9cb606aea85"
}
}
]
}