# Notification 

通知模块

## 1. 安装

```shell
composer require getuilaboratory/getui-pushapi-php-client-v2
```

## 2. 接口文档

### 1. 获取未读消息数量（不登陆返回0）

> GET: /api/notifications/counts

```json
{
    "status": "SUCCESS",
    "status_code": 200,
    "data": 16
}
```

### 2. 消息主页

> GET: /api/notifications

```json
{
    "status": "SUCCESS",
    "status_code": 200,
    "data": [
        {
            "type": "SystemNotification",
            "icon": "",
            "name": "系统通知",
            "count": 16,
            "title": "登录成功"
        },
        {
            "type": "OrderNotification",
            "icon": "",
            "name": "订单通知",
            "count": 0,
            "title": ""
        },
        {
            "type": "ActivityNotification",
            "icon": "",
            "name": "活动通知",
            "count": 0,
            "title": ""
        }
    ]
}
```

### 3. 分类消息的列表

> GET: /api/notifications/{type}/list

```json
{
    "status": "SUCCESS",
    "status_code": 200,
    "data": {
        "data": [
            {
                "notification_id": "91e31d1e-95e1-40ff-88d8-8049df974860",
                "type": "SystemNotification",
                "title": "登录成功",
                "content": "您于北京时间：2021-07-02 15:31:03，通过【账号密码】渠道，在IP：1.190.203.218成功登录系统。请注意保管好您的账号密码。",
                "read_at": "",
                "created_at": "2021-07-02 15:31:03"
            }
        ],
        "page": {
            "current": 1,
            "total_page": 2,
            "per_page": 15,
            "has_more": true,
            "total": 16
        }
    }
}
```

### 4. 消息详情

> GET: /api/notifications/{notification_id}

```json
{
    "status": "SUCCESS",
    "status_code": 200,
    "data": {
        "notification_id": "91e31d1e-95e1-40ff-88d8-8049df974860",
        "type": "SystemNotification",
        "title": "登录成功",
        "content": "您于北京时间：2021-07-02 15:31:03，通过【账号密码】渠道，在IP：1.190.203.218成功登录系统。请注意保管好您的账号密码。",
        "read_at": "2021-07-02 16:27:07",
        "created_at": "2021-07-02 15:31:03"
    }
}
```

### 5. 全部标记已读

> PUT: /api/notifications

```json
{
    "status": "SUCCESS",
    "status_code": 200,
    "data": ""
}
```

### 6. 全部标记已读(分类)

> PUT: /api/notifications/{type}

```json
{
    "status": "SUCCESS",
    "status_code": 200,
    "data": ""
}
```

### 7. 清空全部消息

> DELETE: /api/notifications

```json
{
    "status": "SUCCESS",
    "status_code": 200,
    "data": ""
}
```

### 8. 清空分类消息

> DELETE: /api/notifications/{type}

```json
{
    "status": "SUCCESS",
    "status_code": 200,
    "data": ""
}
```