Calculate Discounted Price by Duration API
POST /calculateDiscountedPriceByDuration
Description
This endpoint calculates the discounted price for a package based on the provided group ID and duration in months. It returns the discounted price, saving rate, discount rate, and duration in months.
Request
Endpoint: /calculateDiscountedPriceByDuration
Method: POST
Body:
query calculateDiscountedPriceByDuration ($groupId: Int!) {
calculateDiscountedPriceByDuration (groupId: $groupId) {
discountedPrice
savingRate
discountRate
durationMonths
}
}
GraphQL Variables:
{
"groupId": 0
}
Example Request
cURL:
curl --location 'YOUR_API_ENDPOINT' \
--header 'Content-Type: application/json' \
--data '{"query":"query calculateDiscountedPriceByDuration ($groupId: Int!) {\n calculateDiscountedPriceByDuration (groupId: $groupId) {\n discountedPrice\n savingRate\n discountRate\n durationMonths\n }\n}","variables":{"groupId":0}}'
Response
The response will include the following details:
discountedPrice
: The price after applying the discount for the specified duration.savingRate
: The rate of savings compared to the standard price.discountRate
: The percentage of discount applied.durationMonths
: The duration in months for which the discount is calculated.
Errors
- 404 Not Found: The provided
groupId
does not exist. - 500 Internal Server Error: Server error while processing the request.
- 400 Bad Request: Invalid
groupId
or other input issues.
Notes
- Ensure that the
groupId
is valid and corresponds to an existing package. - The calculation considers the specified duration and applies the discount accordingly.
- Verify that the duration provided is supported by the pricing model.
- The
discountedPrice
reflects the final price after applying the discount for the given duration. - The
savingRate
anddiscountRate
provide insights into the financial benefits of choosing the discounted option.