# Voucher

> Base URL: `https://pos.pages.fm/api/v1`. Authenticate with the `api_key` query parameter.

## List of voucher

`GET /shops/{SHOP_ID}/vouchers`

Get list of vouchers

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Shop ID |

### Responses

- `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"
    }
  ]
}
```

## Create voucher

`POST /shops/{SHOP_ID}/vouchers`

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Shop ID |

### Request body

Request body containing voucher information to create

- `name` (string, required): Voucher name
- `promo_code_info` (object, required): Voucher promo code information
  - `discount` (integer, required): Discount value
  - `is_percent` (boolean, required): Is percent
  - `max_discount_by_percent` (integer): Maximum discount by percent
- `is_free_shipping` (boolean): Is free shipping
- `is_activated` (boolean): Is activated
- `customer_tags` (string[]): Customer tags
- `start_time` (string (date-time), required): Voucher start time
- `end_time` (string (date-time), required): Voucher end time

```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"
}
```

### Responses

- `200` Success (object)

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

## Get voucher info

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

Get voucher information

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Shop ID |
| `VOUCHER_ID` | path | string | yes | Voucher ID |

### Responses

- `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"
  }
}
```
