# Mã giảm giá

> Base URL: `https://pos.pages.fm/api/v1`. Xác thực bằng tham số truy vấn `api_key`.

## Danh sách phiếu giảm giá

`GET /shops/{SHOP_ID}/vouchers`

Lấy danh sách phiếu giảm giá

### Tham số

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Mã shop |

### Phản hồi

- `200` Success (object)

```json
{
  "success": true,
  "data": [
    {
      "id": "9589b791-013f-4a5b-b8d1-164fad73d84e",
      "display_id": 7,
      "name": "d5IvGYtj",
      "type": "discount_by_coupon_id",
      "start_time": "2021-12-09T04:27:23Z",
      "end_time": "2021-12-10T04:27:26Z",
      "promo_code_info": {
        "discount": 4534,
        "is_percent": false,
        "max_discount_by_percent": 0
      },
      "is_free_shipping": false,
      "is_activated": true,
      "is_used": null,
      "customer_tags": [
        "Tiềm năng"
      ],
      "shop_id": 3,
      "creator_id": "d6e6a545-f102-439e-9943-8ac8369f9735",
      "inserted_at": "2021-12-06T04:27:40Z",
      "updated_at": "2021-12-10T02:26:59Z"
    }
  ]
}
```

## Tạo phiếu giảm giá

`POST /shops/{SHOP_ID}/vouchers`

### Tham số

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Mã shop |

### Nội dung yêu cầu

Thông tin yêu cầu chứa thông tin voucher cần tạo

- `name` (string, required): Mã giảm giá
- `promo_code_info` (object, required): Thông tin giảm giá
  - `discount` (integer, required): Số tiền giảm giá
  - `is_percent` (boolean, required): Giảm giá theo phần trăm
  - `max_discount_by_percent` (integer): Phần trăm giảm tối đa
- `is_free_shipping` (boolean): Miễn phí vận chuyển
- `is_activated` (boolean): Đã kích hoạt
- `customer_tags` (string[]): Thẻ khách hàng
- `start_time` (string (date-time), required): Ngày bắt đầu áp dụng
- `end_time` (string (date-time), required): Ngày kết thúc áp dụng

```json
{
  "name": "test_voucher_5",
  "promo_code_info": {
    "discount": 53635,
    "is_percent": false
  },
  "is_free_shipping": false,
  "is_activated": true,
  "customer_tags": [
    "New tag"
  ],
  "start_time": "2021-12-09T04:27:23",
  "end_time": "2021-12-10T04:27:26"
}
```

### Phản hồi

- `200` Success (object)

```json
{
  "success": true
}
```

## Lấy thông tin phiếu giảm giá

`GET /shops/{SHOP_ID}/vouchers/{VOUCHER_ID}`

### Tham số

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Mã shop |
| `VOUCHER_ID` | path | string | yes | Id phiếu giảm giá |

### Phản hồi

- `200` Success (object)

```json
{
  "success": true,
  "data": {
    "id": "9589b791-013f-4a5b-b8d1-164fad73d84e",
    "display_id": 7,
    "name": "d5IvGYtj",
    "type": "discount_by_coupon_id",
    "start_time": "2021-12-09T04:27:23Z",
    "end_time": "2021-12-10T04:27:26Z",
    "promo_code_info": {
      "discount": 4534,
      "is_percent": false,
      "max_discount_by_percent": 0
    },
    "is_free_shipping": false,
    "is_activated": true,
    "is_used": null,
    "customer_tags": [
      "Tiềm năng",
      "Hay hoàn"
    ],
    "shop_id": 3,
    "creator_id": "d6e6a545-f102-439e-9943-8ac8369f9735",
    "inserted_at": "2021-12-06T04:27:40Z",
    "updated_at": "2021-12-06T04:27:40Z"
  }
}
```
