پرش به مطلب اصلی

Update Coupon Code API

POST /updateCouponCode

Description

This API endpoint updates an existing coupon code with new parameters. It allows modifying details such as the start and expiry dates, discount rate, and quantity.

Request Body

The request utilizes GraphQL to perform the updateCouponCode mutation.

Mutation:

mutation updateCouponCode ($couponCodeView: CouponCodeView) {
updateCouponCode (couponCodeView: $couponCodeView) {
id
couponCode
startDate
expiryDate
discountRate
quantity
createdAt
}
}

Variables:

{
"couponCodeView": {
"couponCode": "<Coupon_Code>",
"startDate": "<Start_Date>",
"expiryDate": "<Expiry_Date>",
"discountRate": <Discount_Rate>,
"quantity": <Quantity>
}
}
  • couponCode (String): The code for the coupon to be updated.
  • startDate (String): The new start date of the coupon validity period in ISO 8601 format.
  • expiryDate (String): The new end date of the coupon validity period in ISO 8601 format.
  • discountRate (Float): The new discount rate to be applied with the coupon.
  • quantity (Int): The new number of times the coupon can be used.

Response:

  • Success (200 OK):

    • If the coupon code is successfully updated, the response will include the details of the updated coupon.
    {
    "data": {
    "updateCouponCode": {
    "id": <Coupon_Id>,
    "couponCode": "<Coupon_Code>",
    "startDate": "<Start_Date>",
    "expiryDate": "<Expiry_Date>",
    "discountRate": <Discount_Rate>,
    "quantity": <Quantity>,
    "createdAt": "<Creation_Date>"
    }
    }
    }
  • Error (4XX/5XX):

    • If there is an issue with updating the coupon code, the response will include an appropriate error message and status code.

Note:

Ensure that the couponCode exists and is correctly formatted. Update the startDate and expiryDate to valid ISO 8601 dates, and set a valid discountRate and quantity.