Schedule discounts in bulk
Endpoint for 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 authorization token with PUBLIC API full permissions is needed to access this route.
Request
Request:HTTP Method | POST | |||||
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 |
|
Request Body:
The request body represents an array of elements that have the following fields:
Fields name | Type | Description |
discounts | Array | List of discounts to be scheduled |
merchantInventoryId | Long | Inventory ID |
discountPrice | BigDecimal | Merchant inventory price on discount |
discountPriceCurrency | String | Currency. Allowed values [ "RSD" ] |
dateFrom | Date | Discount start date. Must be in dd/MM/yyyy format. The discount will be applied immediately after a successful service call if the specified date is today; otherwise, it will be applied starting from 00:01 on the specified day. |
dateTo | Date | Discount end date. Must be in dd/MM/yyyy format. Discounts always end at 23:59. |
discountType | String | Allowed values [“SALE”, “SEASONAL_SALE”, “CLEARANCE_SALE”] |
Example of a JSON body request:
{
"discounts": [
{
"merchantInventoryId": 1194,
"discountPrice": "800",
"discountPriceCurrency": "RSD",
"dateFrom": "22/07/2022",
"dateTo": "29/07/2022",
"discountType": "SALE"
},
{
"merchantInventoryId": 1195,
"discountPrice": "12000",
"discountPriceCurrency": "RSD",
"dateFrom": "15/05/2022",
"dateTo": "15/06/2022",
"discountType": "SEASONAL_SALE"
},
{
"merchantInventoryId": 1196,
"discountPrice": "9000",
"discountPriceCurrency": "RSD",
"dateFrom": "14/04/2022",
"discountType": "CLEARANCE_SALE"
}
]
}
Response
Response will contain info about every discount and whether it was successfully scheduled or not. It is possible to have a partially successful response, i.e. some discounts are successfully scheduled 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 BodyThe response body represents an array of elements each indicating info about one discount:
Fields name | Type | Description |
scheduleResult | Array | Array of discounts |
success | Boolean | Indicates whether the discount has been successfully scheduled or not. If the value is true, data object will be present. If the value is false, an error object will be present. |
data | Object | Present when the discount has been successfully scheduled. Contains information about scheduled discounts. |
error | Object | Present when the discount has not been successfully scheduled. Contains validation error that prevented discount scheduling. |
merchantInventoryId | Long | Merchant Inventory ID |
discountId | UUID | ID of the newly scheduled discount |
errorMessage | String | Validation error that prevented the discount from being scheduled |
Example of the response:
{
"scheduleResult": [
{
"success": false,
"error": {
"merchantInventoryId": 1194,
"errorMessage": "Discount start date can not be after end date "
}
},
{
"success": false,
"error": {
"merchantInventoryId": 1195,
"errorMessage": " Discount interval overlaps with present discount ee7c907d-b2cc-48f8-9226-1ba6e4db1055"
}
},
{
"success": false,
"error": {
"merchantInventoryId": 1196,
"errorMessage": " Seasonal sale must begin between 1st July & 15th July for summer sales or 25th December & 10th January for winter sales"
}
},
{
"success": true,
"data": {
"merchantInventoryId": 1197,
"discountId": "ee7c907d-b2cc-48f8-9226-1ba6e4db1055"
}
}
]
}
Discount validation rules
When setting discounts there are validation rules that need to satisfiedfor the discount to be valid. In this section we’re going to cover all those rules.
There are three discount types: sale, seasonal sale and clearance sale. Sale discounts must not be longer than 31 days. Seasonal sale discount duration must not exceed 60 days and it has to start between 1stJuly & 15thJuly (for summer sale) or 25thDecember & 10thJanuary (for winter sale).For clearance sale, only start Date must be sent. Clerance sale does not have an end date, it lasts until all goods on promotion are sold out. While a product is on clearance sale, its stock can’t be changed.
Additional discount validations:
1. The discount price can be reduced to 95% percent of the regular price.
2. Discounts can’t overlap, I.e., two discounts can’t be active at the same time
3. When the discount is running, it is only possible to decrease discount Price. Changing start date, end date, discount type or increasing the price is not possible.