# Promotion Pages API

## List All Promotion Pages

`GET /api/promotion-pages`

Get all promotion pages.

### Headers

| Header | Value |
|--------|-------|
| Content-Type | application/json |

### Response

```json
{
  "success": true,
  "message": "Read Promotion Page Successfully.",
  "data": [
    {
      "_id": "...",
      "title": "Summer Sale",
      "sub_title": "Up to 50% off",
      "image": "https://cherryk.s3.ap-southeast-1.amazonaws.com/promotions/1712345678900-promo.jpg",
      "description": "Enjoy our biggest sale of the year",
      "isDeleted": false
    }
  ]
}
```

### Errors

- `500` — Server error

---

## Create Promotion Page

`POST /api/promotion-pages`

Create a new promotion page with S3 image upload.

### Headers

| Header | Value |
|--------|-------|
| Content-Type | multipart/form-data |

### Body (multipart/form-data)

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| promotions | file | No | Promotion image (max 1). Allowed: png, jpg, jpeg, gif, webp, avif. Max 10MB |
| title | string | Yes | Promotion page title |
| sub_title | string | No | Subtitle text |
| description | string | No | Description text |

### Response

```json
{
  "success": true,
  "message": "Created Promotion Page Successfully.",
  "data": {
    "_id": "...",
    "title": "Summer Sale",
    "sub_title": "Up to 50% off",
    "image": "https://cherryk.s3.ap-southeast-1.amazonaws.com/promotions/1712345678900-promo.jpg",
    "description": "Enjoy our biggest sale of the year",
    "isDeleted": false
  }
}
```

### Errors

- `400` — Validation error
- `413` — File too large (exceeds 10MB)
- `500` — Server error

---

## Get Promotion Page By ID

`GET /api/promotion-page/:id`

Get a specific promotion page by its ID.

### Headers

| Header | Value |
|--------|-------|
| Content-Type | application/json |

### Parameters

| Param | Type | Required | Description |
|-------|------|----------|-------------|
| id | string | Yes | Promotion page MongoDB ObjectID |

### Response

```json
{
  "success": true,
  "message": "Read Promotion Page By Id Successfully.",
  "data": {
    "_id": "...",
    "title": "Summer Sale",
    "sub_title": "Up to 50% off",
    "image": "https://cherryk.s3.ap-southeast-1.amazonaws.com/promotions/1712345678900-promo.jpg",
    "description": "Enjoy our biggest sale of the year",
    "isDeleted": false
  }
}
```

### Errors

- `500` — Server error

---

## Update Promotion Page

`PUT /api/promotion-page/:id`

Update a promotion page with new image and/or information.

### Headers

| Header | Value |
|--------|-------|
| Content-Type | multipart/form-data |

### Parameters

| Param | Type | Required | Description |
|-------|------|----------|-------------|
| id | string | Yes | Promotion page MongoDB ObjectID |

### Body (multipart/form-data)

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| promotions | file | No | New promotion image (replaces existing). Allowed: png, jpg, jpeg, gif, webp, avif. Max 10MB |
| title | string | No | New title |
| sub_title | string | No | New subtitle |
| description | string | No | New description |

### Response

```json
{
  "success": true,
  "message": "Updated Promotion Page By Id Successfully.",
  "data": {
    "_id": "...",
    "title": "Winter Sale",
    "sub_title": "Up to 70% off",
    "image": "https://cherryk.s3.ap-southeast-1.amazonaws.com/promotions/1712345678901-new-promo.jpg",
    "description": "New season, new deals",
    "isDeleted": false
  }
}
```

### Errors

- `400` — Validation error
- `404` — Promotion page not found
- `413` — File too large (exceeds 10MB)
- `500` — Server error

---

## Delete Promotion Page

`DELETE /api/promotion-page/:id`

Soft delete a promotion page (sets `isDeleted` to `true`).

### Headers

| Header | Value |
|--------|-------|
| Content-Type | application/json |

### Parameters

| Param | Type | Required | Description |
|-------|------|----------|-------------|
| id | string | Yes | Promotion page MongoDB ObjectID |

### Response

```json
{
  "success": true,
  "message": "Deleted Promotion Page By Id Successfully.",
  "data": {
    "_id": "...",
    "title": "Summer Sale",
    "sub_title": "Up to 50% off",
    "image": "https://cherryk.s3.ap-southeast-1.amazonaws.com/promotions/1712345678900-promo.jpg",
    "description": "Enjoy our biggest sale of the year",
    "isDeleted": true
  }
}
```

### Errors

- `400` — Invalid ID format
- `404` — Promotion page not found
- `500` — Server error
