@fuyb1986
2016-06-24T03:30:29.000000Z
字数 5074
阅读 622
欣略
当前用户向接受者发送通知消息
| Method | Resource URL |
|---|---|
| POST | /notification/send/ |
| Name | Description | Required | Default |
|---|---|---|---|
| title | 通知的标题 | Yes | |
| content | 通知内容 | No | |
| receiver | 接收者账号 | Yes | |
| question | 某一问题资源pk/id | No | |
| answer | 某一答案资源pk/id | No |
选填字段question/answer,如果该字段值为空,就不传该字段
| Name | Description | Required | Default |
|---|---|---|---|
| Authorization | Token 7309fabd207c22e0a00eada158989b89ffe839ef | Yes |
*Authorization的值为登录成功后返回值
{"title":"老师问好","content":"你好吗","question":1,"answer":1,"receiver":"student",}
curl -X POST -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' -d 'title=老师问好&receiver=student&content=你好吗?&question=1&answer=1' http://127.0.0.1:8000/notification/send/
{"pk": 3,"sender": "teacher","receiver": "student","title": "老师问好","content": "你好吗?","read": false,"question": 1,"answer": 1,"create_time": "2016-04-14T09:03:33.302410Z"}
用户所收到的通知信息
| Method | Resource URL |
|---|---|
| GET | /notification/inbox/ |
默认分页取数据库中最新的10条数据
| Name | Description | Required | Default |
|---|---|---|---|
| read | 课程名 | No | |
| page | page Number | Yes | 1 |
- read参数有值且不为空时,获取的是所有已读消息
- read参数为空值时,获取的是未读消息
- read参数字段缺失时,获取的是所有消息
| Name | Description | Required | Default |
|---|---|---|---|
| Authorization | Token 7309fabd207c22e0a00eada158989b89ffe839ef | Yes |
*Authorization的值为登录成功后返回值
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' -d 'page=1&read=true' http://127.0.0.1:8000/notification/inbox/
{"count": 2,"next": null,"previous": null,"results": [{"pk": 3,"sender": "root","receiver": "teacher","title": "teacher-receiver-read","content": "","read": true,"question": 5,"answer": 4,"create_time": "2016-04-14T07:16:10.627632Z"},{"pk": 2,"sender": "root","receiver": "teacher","title": "teacher-receiver-read","content": "","read": true,"question": 5,"answer": 4,"create_time": "2016-04-14T07:16:10.627632Z"}]}
用户获取所有自己发出的通知信息
| Method | Resource URL |
|---|---|
| GET | /notification/sent/ |
默认分页取数据库中最新的10条数据
| Name | Description | Required | Default |
|---|---|---|---|
| read | 课程名 | No | |
| page | page Number | Yes | 1 |
- read参数有值且不为空时,获取的是所有已读消息
- read参数为空值时,获取的是未读消息
- read参数字段缺失时,获取的是所有消息
| Name | Description | Required | Default |
|---|---|---|---|
| Authorization | Token 7309fabd207c22e0a00eada158989b89ffe839ef | Yes |
*Authorization的值为登录成功后返回值
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' -d 'page=1&read=' http://127.0.0.1:8000/notification/sent/
{"count": 2,"next": null,"previous": null,"results": [{"pk": 1,"sender": "teacher","receiver": "student","title": "d","content": "","read": false,"question": 5,"answer": 2,"create_time": "2016-04-14T07:03:34.769930Z"},{"pk": 4,"sender": "teacher","receiver": "student","title": "teacher-sender","content": "","read": false,"question": 5,"answer": 4,"create_time": "2016-04-14T07:32:08.978551Z"}]}
用户查询某一通知信息
| Method | Resource URL |
|---|---|
| GET | /notification/${pk}/ |
| Name | Description | Required | Default |
|---|---|---|---|
| Authorization | Token 7309fabd207c22e0a00eada158989b89ffe839ef | Yes |
*Authorization的值为登录成功后返回值
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/notification/1/
{"pk": 1,"sender": "teacher","receiver": "student","title": "d","content": "","read": false,"question": 5,"answer": 2,"create_time": "2016-04-14T07:03:34.769930Z"}
用户创建支付通知
| Method | Resource URL |
|---|---|
| POST | /notification/payment_notification_list/ |
| Name | Description | Required | Default |
|---|---|---|---|
| title | 支付标题 | Yes | |
| content | 支付内容 | No |
| Name | Description | Required | Default |
|---|---|---|---|
| Authorization | Token 7309fabd207c22e0a00eada158989b89ffe839ef | Yes |
*Authorization的值为登录成功后返回值
curl -X POST -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' -d 'title=你收到10美元' http://127.0.0.1:8000/notification/payment_notification_list/
{"pk": 1,"receiver": "teacher","title": "你收到10美元","content": null,"read": false,"create_time": "2016-04-14T07:53:55.081723Z"}
用户查看所收到的支付通知
| Method | Resource URL |
|---|---|
| GET | /notification/payment_notification_list/ |
默认分页取数据库中最新的10条数据
| Name | Description | Required | Default |
|---|---|---|---|
| page | page Number | Yes | 1 |
| Name | Description | Required | Default |
|---|---|---|---|
| Authorization | Token 7309fabd207c22e0a00eada158989b89ffe839ef | Yes |
*Authorization的值为登录成功后返回值
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/notification/payment_notification_list/
{"count": 2,"next": null,"previous": null,"results": [{"pk": 1,"receiver": "teacher","title": "你收到10美元","content": null,"read": false,"create_time": "2016-04-14T07:53:55.081723Z"},{"pk": 2,"receiver": "teacher","title": "你收到10美元","content": null,"read": false,"create_time": "2016-04-14T08:02:50.383718Z"}]}
用户查看具体的支付通知
| Method | Resource URL |
|---|---|
| GET | /notification/payment_notification/${pk} |
| Name | Description | Required | Default |
|---|---|---|---|
| Authorization | Token 7309fabd207c22e0a00eada158989b89ffe839ef | Yes |
*Authorization的值为登录成功后返回值
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/notification/payment_notification/1/
{"pk": 1,"receiver": "teacher","title": "你收到10美元","content": null,"read": false,"create_time": "2016-04-14T07:53:55.081723Z"}