API Documentation for Coupon System
Overview
This API allows for the creation and management of coupons in a system defined by a specific Python schema. The /create endpoint is used to create a new coupon.
Openapi
CheckCoupon
Endpoint: Create Coupon
- URL:
<url>/create - Method:
POST - Description: Creates a new coupon in the system.
- Request Body: The body should contain a payload corresponding to a
Couponobject.
Schema Definitions
Coupon Object
- couponCodes (
List[CouponCode]): A list of coupon codes. - couponId (
CouponId): Unique identifier for the coupon. - type_ (
Type): The type of coupon (e.g., BOGO, DISC). - bogo (
Optional[Bogo]): Specifics for BOGO-type coupons. - two4 (
Optional[Two4]): Specifics for TWO4-type coupons. - disc (
Optional[Disc]): Specifics for DISC-type coupons. - freeShip (
Optional[FreeShip]): Specifics for free shipping discounts. - specificDiscount (
Optional[SpecificSkuDiscount]): Specifics for SKU-based discounts. - conditions (
Optional[Conditions]): Conditions applicable to the coupon. - currentCouponCode (
Optional[str]): The current active coupon code. - currentOwner (
Optional[str]): The current owner of the coupon. - description (
str): A description of the coupon. - isPromotion (
bool): Indicates if the coupon is a promotion.
Supporting Objects
- Bogo, Two4, Disc, FreeShip, SpecificSkuDiscount, Conditions: Objects that define various aspects of a coupon based on its type and applicable conditions.
Example Request
POST <url>/create
Content-Type: application/json
{
"couponCodes": ["CODE123", "CODE456"],
"couponId": 12345,
"type_": "DISC",
"disc": {
"products": [101, 102],
"exclude": [201],
"cash": 10,
"percentage": 5
},
"conditions": {
"noCombine": ["BOGO"],
"cartTotal": 100,
"endDate": 20231231,
"firstTimerOnly": false,
"isActive": true
},
"description": "10% off on products 101 and 102, excluding product 201",
"isPromotion": true
}
Response
The response will include details of the created coupon, including its ID and applicable conditions.
Error Handling
- 400 Bad Request: If the request body does not match the
Couponobject schema. - 500 Internal Server Error: For server-side issues.
Security and Authentication
Please ensure appropriate authentication mechanisms are in place to secure this endpoint, as it can modify the coupon system’s state.
This documentation provides a basic guideline for interacting with the coupon creation endpoint. Further details can be added based on specific requirements and additional functionalities of the system.