# Coupon List Screen

## **Coupon APIs**

The Coupon APIs facilitate the management of discount coupons within the e-commerce platform. These APIs allow users to view, add, and remove coupons from their accounts.

<figure><img src="https://3686328336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd1Iq7THDAagTQzeC9rTN%2Fuploads%2FO58QFdnJ98HH3PPCEiwi%2Fimage.png?alt=media&#x26;token=71e974d5-bab2-4774-9922-34e9d4153290" alt=""><figcaption><p><strong>Coupon Listing interface</strong></p></figcaption></figure>

### **1. Get Coupons API**&#x20;

The Get Coupons API retrieves a list of available coupons for the authenticated user. It provides information about various coupons, including their codes, discount percentages, and validity.

### **Endpoint**

* `{{baseurl}}/api/v1/coupons`

### **Method**

* **GET**

### **Request Parameters:**

* **lang\_code (optional):** A two-letter language code (e.g., "en" for English, "es" for Spanish, etc.) to support language-based localization. If provided, the API returns coupon names and details in the specified language.
* **page (optional):** The page number to retrieve when using pagination. If not specified, the API defaults to the first page.

### **Request Body**

None

### **Authorization:**

The API requires a bearer token in the request header for authentication. Users need to include their valid bearer token in the "Authorization" header of the HTTP request to access the available coupons.

### **Response Format:**&#x20;

The API responds with a JSON object containing a list of coupon objects. Each coupon object represents a specific coupon and includes details such as code, discount percentage, validity, and more.

```json
 "success": true,
    "data": {
        "coupons": [
            {
                "id": 10,
                "name": "Rc",
                "description": "testinggg",
                "offerpercentage": "20",
                "minpurchase": "100",
                "maxredeem": "10",
                "couponcode": "ADCS",
                "banner": "https://majarat-developemt.s3.ap-southeast-1.wasabisys.com/uploads/all/716QX%2ByA-TL._SL1456_.jpg",
                "icon": "https://majarat-developemt.s3.ap-southeast-1.wasabisys.com/uploads/all/81KWO7Q1n7L._SL1500_.jpg",
                "expired": false
            },
            {
                "id": 4,
                "name": "Rc",
                "description": "gdd",
                "offerpercentage": "10",
                "minpurchase": "10",
                "maxredeem": "10",
                "couponcode": "aed",
                "banner": "https://majarat-developemt.s3.ap-southeast-1.wasabisys.com/uploads/all/MicrosoftTeams-image%20%288%29.png",
                "icon": "https://majarat-developemt.s3.ap-southeast-1.wasabisys.com/uploads/all/MicrosoftTeams-image%20%2810%29.png",
                "expired": false
            }
        ],
        "pagination": {
            "total": 2,
            "count": 2,
            "limit": 15,
            "current_page": 1,
            "total_pages": 1
        }
    },
    "message": "Success",
    "status_code": 200
}
```

###

###

###

### **2. Add Coupon API**&#x20;

The Add Coupon API allows users to apply a coupon code to their account to avail discounts during the checkout process.

### **Endpoint:**

* `{{baseurl}}/api/v1/coupons/addCoupon`

### **Method**

* **POST**

### **Request Parameters:**

None

### **Request Body:**

The request body should include the user's ID and the coupon code they want to add as follows:

```json
{
    "user_id": "user_id_here",
    "coupon_code": "your_coupon_code_here"
}
```

### **Authorization:**

The API requires a bearer token in the request header for authentication. Users need to include their valid bearer token in the "Authorization" header of the HTTP request to add a coupon to their account.

### **Response Format:**&#x20;

The API responds with a success message or appropriate status code indicating that the coupon has been successfully added to the user's account.

```json
{
    "success": true,
    "message": "Coupon added successfully",
    "status_code": 200
}
```

###

###

###

### **3. Remove Coupon API**&#x20;

The Remove Coupon API allows users to remove a coupon from their account if they no longer wish to use it during the checkout process.

### **Endpoint**

* `{{baseurl}}/api/v1/coupons/removeCoupon`

### **Method**

* **POST**

### **Request Parameters:**

None

### **Request Body:**

The request body should include the user's ID and the coupon code they want to remove as follows:

```json
{
    "user_id": "user_id_here",
    "coupon_code": "your_coupon_code_here"
}
```

### **Authorization:**

The API requires a bearer token in the request header for authentication. Users need to include their valid bearer token in the "Authorization" header of the HTTP request to remove a coupon from their account.

### **Response Format:**&#x20;

The API responds with a success message or appropriate status code indicating that the coupon has been successfully removed from the user's account.

```json
{
    "success": true,
    "message": "Coupon removed successfully",
    "status_code": 200
}
```
