# Export

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

## List of exports

`GET /shops/{SHOP_ID}/export`

Get list of exports

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Shop ID |
| `page` | query | integer |  | Page number |
| `page_size` | query | integer |  | Page size |
| `status` | query | integer |  | Status Values: `-1` All status, `0` New, `1` Completed, `2` Canceled. |
| `type` | query | integer |  | Type of export Values: `0` Normal export, `1` Product defect export. |

### Responses

- `200` Success (object)

```json
{
  "success": true,
  "data": [
    {
      "id": "8095ca3c-a485-4378-9914-5013e1179d55",
      "display_id": 472,
      "status": 0,
      "type": 0,
      "total": 1,
      "total_price": 0,
      "note": "Xuất bán hàng",
      "warehouse_id": "c52e67ad-d9d0-4276-abe4-e0c9f1f7d2da",
      "supplier_products_id": 400037328,
      "tags": [
        1
      ],
      "export_items": [
        {
          "id": "78dfe47a-a3dd-4d47-8f8b-16eb1ccd69ee",
          "imported_price": 0,
          "quantity": 1,
          "variation_id": "76887a5b-8a27-472c-a15a-661ea59434dd",
          "display_id": 0,
          "inserted_at": "2024-01-25T16:18:20Z"
        }
      ],
      "images": [
        "https://content.pancake.vn/user-content-dev2.pancake.vn/2022/7/7/eb376f0bf90f47d25396d49e4d547700f182981b.jpg"
      ],
      "user_id": "d6e6a545-f102-439e-9943-8ac8369f9735",
      "user": {
        "id": "d6e6a545-f102-439e-9943-8ac8369f9735",
        "name": "vudzung12",
        "fb_id": "1286585024855632",
        "avatar_url": null
      },
      "inserted_at": "2024-01-25T16:18:20Z",
      "updated_at": "2024-01-25T16:18:20Z"
    }
  ]
}
```

## Create export

`POST /shops/{SHOP_ID}/export`

### Parameters

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

### Request body

Request body containing export information to create

- `export_list` (object, required): 
  - `note` (string): Note
  - `supplier_products_id` (integer): Supplier products ID
  - `tags` (integer[]): Export tags
  - `status` (integer, required): Export status Values: `0` New (type 0) / Defect export (type 1), `1` Completed (type 0) / Elimination export (type 1), `2` Canceled.
  - `type` (integer): Type of export Values: `0` Normal export, `1` Product defect export.
  - `shop_id` (integer): Shop ID
  - `warehouse_id` (string, required): Warehouse ID
  - `change_inserted_at` (boolean): Change date of create export
  - `inserted_at` (integer): Date of create export (unix timestamp)
  - `images` (string (uri)[]): Export images
  - `export_items` (object[], required): List of products

```json
{
  "export_list": {
    "note": "",
    "supplier_products_id": 169,
    "tags": [
      1
    ],
    "status": 0,
    "type": 0,
    "shop_id": 20,
    "warehouse_id": "c52e67ad-d9d0-4276-abe4-e0c9f1f7d2da",
    "change_inserted_at": true,
    "inserted_at": 1651683600,
    "images": [
      "https://statics.pancake.vn/user-content-dev2.pancake.vn/2021/12/27/18c4500c320cb2e993b3ff4b3be81165df64d3ba.png"
    ],
    "export_items": [
      {
        "id": "13d7ddf6-4cd9-4e1f-a5c1-ac3cd7a7fc17",
        "imported_price": 100000,
        "quantity": 1,
        "variation_id": "29044dcf-2f4c-492f-a0a9-e447b20e21da"
      }
    ]
  }
}
```

### Responses

- `200` Success (object)

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

## Get export

`GET /shops/{SHOP_ID}/export/{EXPORT_ID}`

Get one export by ID or display ID, in the same shape as an item of the export list. Exports in warehouses the caller cannot view are reported as not found.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Shop ID |
| `EXPORT_ID` | path | string | yes | Export ID (UUID) or display ID |

### Responses

- `200` Success (object)
- `404` The export does not exist or is not visible to the caller (ErrorResponse)

```json
{
  "success": true,
  "data": {
    "id": "8095ca3c-a485-4378-9914-5013e1179d55",
    "display_id": 472,
    "status": 0,
    "type": 0,
    "total": 1,
    "total_price": 0,
    "note": "Xuất bán hàng",
    "warehouse_id": "c52e67ad-d9d0-4276-abe4-e0c9f1f7d2da",
    "supplier_products_id": 400037328,
    "tags": [
      1
    ],
    "export_items": [
      {
        "id": "78dfe47a-a3dd-4d47-8f8b-16eb1ccd69ee",
        "imported_price": 0,
        "quantity": 1,
        "variation_id": "76887a5b-8a27-472c-a15a-661ea59434dd",
        "display_id": 0,
        "inserted_at": "2024-01-25T16:18:20Z"
      }
    ],
    "user_id": "d6e6a545-f102-439e-9943-8ac8369f9735",
    "inserted_at": "2024-01-25T16:18:20Z",
    "updated_at": "2024-01-25T16:18:20Z"
  }
}
```

## Update export

`PUT /shops/{SHOP_ID}/export/{EXPORT_ID}`

### Parameters

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

### Request body

Request body containing export information to create

- `export_list` (object, required): 
  - `images` (string (uri)[]): Export images
  - `inserted_at` (integer): Date of create export (unix timestamp)
  - `note` (string): Note
  - `status` (integer): Export status Values: `0` New (type 0) / Defect export (type 1), `1` Completed (type 0) / Elimination export (type 1), `2` Canceled.
  - `supplier_products_id` (integer): Supplier products ID
  - `tags` (integer[]): Export tags
  - `type` (integer): Type of export Values: `0` Normal export, `1` Product defect export.
  - `export_items` (object[]): List of products

```json
{
  "export_list": {
    "images": [
      "https://content.pancake.vn/user-content-dev2.pancake.vn/2022/5/27/ee3be79d1574735ed35539ca48f7f6e9d7137706.jpg"
    ],
    "inserted_at": 1695142800,
    "note": "xuất bán hàng",
    "status": 0,
    "supplier_products_id": 319,
    "tags": [
      1
    ],
    "export_items": [
      {
        "id": "13d7ddf6-4cd9-4e1f-a5c1-ac3cd7a7fc17",
        "imported_price": 1000,
        "quantity": 1,
        "variation_id": "d1e522eb-2f6f-4d22-b8a1-ec25df4a33a4"
      }
    ]
  }
}
```

### Responses

- `200` Success (object)

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