---
# System prepended metadata

title: 設備配對

---

* **新增設備配對**  [POST /device/pair](#新增設備配對)
* **取得設備配對**  [POST /device/list](#取得設備配對)
* **移除設備配對**  [POST /device/delete](#移除設備配對)
# 設備配對

| Name        | Tags     | 建立時傳入 |說明      |
| ------------| -------- | -------- | -------- |
| deviceName  | String   | Y | 裝置名稱    |
| uuid        | String| Y | uuid    |
| deviceType      | String| Y | ANDROID/IOS    |
| lastUpdateTime      | Long| N | 上次同步資料時間(若未曾同步則不回傳)    |

# API

## 新增設備配對

Request:
```url=
    POST /device/pair
```

Header:

```json=
{
    "Authorization": "token"
}
```

Payload:

```json=
{
    "details":[
        {
            "deviceName":"Osmile",
            "uuid":"OO:XX:YY:ZZ",
            "deviceType":"ANDROID"
        },
        {
            "deviceName":"血糖計",
            "uuid":"OO:XX:YY:SS",
            "deviceType":"ANDROID"
        }
    ]
}
```

Response (成功):

```json=
{
    "httpCode": 200,
    "result": {
        "data": [
            {
                "deviceName": "Osmile",
                "uuid": "OO:XX:YY:ZZ",
                "deviceType": "ANDROID",
                "lastUpdateTime": null
            },
            {
                "deviceName": "血糖計",
                "uuid": "OO:XX:YY:SS",
                "deviceType": "ANDROID",
                "lastUpdateTime": null
            }
        ]
    }
}
```

## 取得設備配對
Request:

    POST /device/list

Header:

```json=
{
    "Authorization": "token"
}
```

Payload:

```json=
{
    "deviceType":"ANDROID"
}
```

Response (成功):

```json=
{
    "httpCode": 200,
    "result": {
        "data": [
            {
                "id":"fd8ca4ff-3b8b-4d1e-824e-3c9fb9be2d78",
                "deviceName": "Osmile",
                "uuid": "OO:XX:YY:ZZ",
                "deviceType": "ANDROID",
                "lastUpdateTime": null
            },
            {
                "id": "121fe51a-bf8a-4c22-b9af-0ec6b0260273",
                "deviceName": "血糖計",
                "uuid": "OO:XX:YY:SS",
                "deviceType": "ANDROID",
                "lastUpdateTime": null
            }
        ]
    }
}
```
## 移除設備配對

Request:
```url=
    POST /device/delete
```

Header:

```json=
{
    "Authorization": "token"
}
```

Payload:

```json=
{
    "details":[
        {
            "deviceName":"Osmile",
            "deviceType":"ANDROID"
        },
        {
            "deviceName":"血糖計",
            "deviceType":"ANDROID"
        }
    ]
}
```

Response (成功):

```json=
{
    "httpCode": 200,
    "result": {
        "data": 2
    }
}
```
