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

Use Token Code API

POST /useTokenCode

Description

This API endpoint allows users to use a previously generated token code. The token code can be applied for discounts or other benefits.

Request Body

The request utilizes GraphQL to perform the useTokenCode mutation.

Mutation:

mutation useTokenCode ($code: String) {
useTokenCode (code: $code) {
id
userId
tokenCode
discountRate
isActive
usedTimestamp
createdAt
}
}

Variables:

{
"code": "<Token_Code>"
}
  • code (String): The token code to be used.

Response:

  • Success (200 OK):

    • If the token code is successfully used, the response will include details about the token code, including its ID, associated user ID, discount rate, activation status, and timestamps.
    {
    "data": {
    "useTokenCode": {
    "id": <Token_Code_ID>,
    "userId": <User_ID>,
    "tokenCode": "<Token_Code>",
    "discountRate": <Discount_Rate>,
    "isActive": <Is_Active>,
    "usedTimestamp": "<Used_Timestamp>",
    "createdAt": "<Creation_Timestamp>"
    }
    }
    }
  • Error (4XX/5XX):

    • If there is an issue using the token code, such as an invalid or already used code, the response will include an appropriate error message and status code.

Note:

Ensure the code provided is valid and has not been used before. If the token code has already been used or is inactive, the response will reflect that status.