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 MethodPUT
URLStagehttps://api.stage.ananastest.com/payment/api/v1/merchant-integration/discounts
Productionhttps://api.ananas.rs/payment/api/v1/merchant-integration/discounts
HTTP Headers
Header nameHeader value
AuthorizationBearer {access_token}
Request Body:

The request body represents an array of elements that have the following fields:

Fields nameTypeDescription
discountsArrayList of discounts to be updated
discountIdUUIDDiscount ID
newDiscountPriceBigDecimalNew merchant inventory price on discount
newDiscountPriceCurrencyStringCurrency. Allowed values [ “RSD” ]
newDateFromDateNew discount start date. Must be in dd/MM/yyyy format. Discount always start at 00:00. Cannot be changed if discount is already active.
newDateToDateNew discount end date. Must be in dd/MM/yyyy format. Discounts always end at 23:59.
newDiscountTypeStringAllowed 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:

Click to copy
Success!
{
  "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 nameTypeDescription
updateResultArrayArray of discounts
successBooleanIndicates 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.
dataObjectPresent if success is true.
errorObjectPresent if success is false
discountIdUUIDDiscount ID
errorMessageStringMessage indicating why discount update failed

Example of the response:

Click to copy
Success!
{
  "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"
      }
    }
  ]
}
Copyright © Ananas 2023. All right reserved.