-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplified and tested endpoints with Postman
- Loading branch information
Showing
6 changed files
with
125 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,6 @@ Available at https://venuswku.github.io/cherish-api. | |
|
||
## Endpoints | ||
### Actions | ||
GET `/actions` | ||
- Returns a list of all acts of kindness. | ||
- Optional query parameters: | ||
- `for`: who the act of kindness is for (e.g. friends, family, yourself, coworkers, strangers) | ||
|
||
GET `/actions/:id` | ||
- Returns detailed information about a single act of kindness with the specified object id. | ||
|
||
GET `/actions/random` | ||
- Returns information about a single random act of kindness. | ||
|
||
POST `/actions/suggest` | ||
- Suggests a new act of kindness, which needs to be approved before being added to our database. | ||
- Requires authentication. | ||
|
@@ -26,13 +15,38 @@ POST `/actions/suggest` | |
- `did`: whether suggester did their suggested act of kindness (required boolean) | ||
- `suggester`: id of person who suggested this act of kindness (required object id) | ||
- `img`: link to an image that relates to this act of kindness (optional string) | ||
- Example request body: | ||
```json | ||
{ | ||
"act": "Send a handwritten letter or postcard to someone", | ||
"desc": "Brighten a loved one's day by sharing what you appreciate about them!", | ||
"for": ["family", "friends", "yourself"], | ||
"like": true, | ||
"did": true, | ||
"suggester": "62957314cb99993a91f07ce8", | ||
"img": "" | ||
} | ||
``` | ||
|
||
GET `/actions` | ||
- Returns a list of all acts of kindness. | ||
- If `for` query parameters are provided, then acts of kindness containing at least one of the provided query values will be returned. | ||
- Optional query parameters: | ||
- `for`: who the act of kindness is for (e.g. friends, family, yourself, coworkers, strangers) | ||
- Example request link: http://localhost:5000/actions?for=family&for=yourself | ||
|
||
GET `/actions/get/:id` | ||
- Returns detailed information about a single act of kindness with the specified object id. | ||
|
||
POST `/actions/like/:id` | ||
GET `/actions/random` | ||
- Returns information about a single random act of kindness. | ||
|
||
PUT `/actions/like/:id` | ||
- Either adds or removes a like for the act of kindness with the specified id. | ||
- If the user's id is not in the list of people who liked the act, then it increments the number of likes by adding the id of the user. | ||
- Else it decrements the number of likes because the user's id is already in the list and would like their id to be removed. | ||
|
||
POST `/actions/done/:id` | ||
PUT `/actions/done/:id` | ||
- Either increments or decrements the number of people who did the act of kindness with the specified id. | ||
- If the user's id is not in the list of people who did the act, then it increments the number of people who did the act by adding the id of the user. | ||
- Else it decrements the number of people who did the act because the user's id is already in the list and would like their id to be removed. | ||
|
@@ -41,14 +55,23 @@ DELETE `/actions/:id` | |
- Removes the act of kindness with the specified id from our database. | ||
|
||
## Users | ||
GET `/users` | ||
- Returns a list of all users who have either suggested an act of kindness or contributed to number of likes/done. | ||
|
||
GET `/users/:id` | ||
- Returns detailed information about a single user with the specified object id. | ||
|
||
POST `/users/add` | ||
- Creates a new user in our database if they haven't been saved before. | ||
- The request body needs to be in JSON format and includes the following properties: | ||
- `email`: email of user (required string) | ||
- `name`: user's name (optional string) | ||
- `name`: user's name (optional string) | ||
- Example request body: | ||
```json | ||
{ | ||
"email": "[email protected]", | ||
"name": "Venus Ku" | ||
} | ||
``` | ||
|
||
GET `/users` | ||
- Returns a list of all users who have either suggested an act of kindness or contributed to number of likes/done. | ||
- If either one or both of the following query parameters are included in the request, returns detailed information about user(s) with the specified object id or email. | ||
- Optional query parameters: | ||
- `id`: object id of a user | ||
- `email`: email of a user | ||
- Example request link: http://localhost:5000/[email protected] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters