Post¶
Get Post¶
-
GET
/posts/
(post_id)¶ Get a single post.
Example JSON response:
{ "message": "생 마르탱 운하에서 본 할머니와 할아버지", "id": 14, "is_liked": false, "like_count": 0, "user": { "created_at": "2017-02-07T09:23:13+0000", "photo": { "id": "d7394923-cf39-4c78-891a-8714eb615ea7" }, "username": "devxoul", "id": 1 }, "created_at": "2017-01-27T19:52:32+0000", "photo": { "id": "69e892b4-7dbd-403c-92fc-07f199c2be35" } }
Response JSON Object: - id (int) –
- photo (Photo) –
- message (string) – A message (Optional)
- user (User) – Post author
- created_at (date) –
Status Codes: - 200 OK – OK
- 404 Not Found – There’s no post
Create Post¶
-
POST
/posts
¶ Create a post
Example JSON response:
{ "message": "생 마르탱 운하에서 본 할머니와 할아버지", "id": 14, "is_liked": false, "like_count": 0, "user": { "created_at": "2017-02-07T09:23:13+0000", "photo": { "id": "d7394923-cf39-4c78-891a-8714eb615ea7" }, "username": "devxoul", "id": 1 }, "created_at": "2017-01-27T19:52:32+0000", "photo": { "id": "69e892b4-7dbd-403c-92fc-07f199c2be35" } }
Form Parameters: - photo – An image file
- message – A message (Optional)
Status Codes: - 201 Created – Created
- 400 Bad Request – Required parameter is missing or invalid
- 401 Unauthorized – Not authorized
Edit Post¶
-
PUT
/posts/
(post_id)¶ Edit the post
Example JSON response:
{ "message": "생 마르탱 운하에서 본 할머니와 할아버지", "id": 14, "is_liked": false, "like_count": 0, "user": { "created_at": "2017-02-07T09:23:13+0000", "photo": { "id": "d7394923-cf39-4c78-891a-8714eb615ea7" }, "username": "devxoul", "id": 1 }, "created_at": "2017-01-27T19:52:32+0000", "photo": { "id": "69e892b4-7dbd-403c-92fc-07f199c2be35" } }
Form Parameters: - message – New message (Optional)
Status Codes: - 200 OK – OK
- 401 Unauthorized – Not authorized
- 403 Forbidden – No permission
-
PATCH
/posts/
(post_id)¶ Edit the post
Example JSON response:
{ "message": "생 마르탱 운하에서 본 할머니와 할아버지", "id": 14, "is_liked": false, "like_count": 0, "user": { "created_at": "2017-02-07T09:23:13+0000", "photo": { "id": "d7394923-cf39-4c78-891a-8714eb615ea7" }, "username": "devxoul", "id": 1 }, "created_at": "2017-01-27T19:52:32+0000", "photo": { "id": "69e892b4-7dbd-403c-92fc-07f199c2be35" } }
Form Parameters: - message – New message (Optional)
Status Codes: - 200 OK – OK
- 401 Unauthorized – Not authorized
- 403 Forbidden – No permission
Delete Post¶
-
DELETE
/posts/
(post_id)¶ Delete the post
Example JSON response:
{}
Status Codes: - 200 OK – Deleted
- 401 Unauthorized – Not authorized
- 403 Forbidden – No permission
Like Post¶
-
POST
/posts/
(post_id)/likes
¶ Like the post
Example JSON response:
{}
Status Codes: - 201 Created – Liked
- 401 Unauthorized – Not authorized
- 409 Conflict – Already liked
Unlike Post¶
-
DELETE
/posts/
(post_id)/likes
¶ Unlike the post
Example JSON response:
{}
Status Codes: - 200 OK – Unliked
- 401 Unauthorized – Not authorized
- 409 Conflict – Already unliked