宝宝
金色童年
添加、获取、更新宝宝信息
Method and URL Structure
| Method |
Resource URL |
| POST |
/account/baby/add/ |
| PUT |
/account/baby/update/${pk} |
| GET |
/account/baby/${pk} |
Request Data
获取宝宝数据不用这些数据
| Name |
Description |
Required |
Default |
| name |
名字 |
YES |
|
| birthday |
生日 |
YES |
|
| sex |
性别: F/M/S |
YES |
|
| avatar_url |
头像 |
YES |
|
Request
{ "name": "宝宝第一", "birthday": "2015-01-01", "sex": "F", "avatar_url": "http://example.com/1.png"}
cURL Example
curl -X POST -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\-H 'Content-Type: Application/json' --data '{....}' http://localhost/account/baby/add/
Reponse
{ "pk":1, "owner":3, "avatar_url":"http://example.com/1.png", "name":"宝宝第一", "birthday":"2015-01-01", "sex":"F", "sex_display":"男"}
宝宝信息列表
Method and URL Structure
| Method |
Resource URL |
| GET |
/account/baby/ |
cURL Example
curl -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\-H 'Content-Type: Application/json' http://localhost/account/baby/
Response
{ "count":1, "next":null, "previous":null, "results":[{ "pk":1, "owner":3, "avatar_url":"http://example.com/1.png", "name":"宝宝第一", "birthday":"2015-01-01", "sex":"F", "sex_display":"男" }]}
删除宝宝信息
Method and URL Structure
| Method |
Resource URL |
| DELETE |
/account/baby/${pk} |
cURL Example
curl -X DELETE -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\-H 'Content-Type: Application/json' http://localhost/account/baby/123/