-
Notifications
You must be signed in to change notification settings - Fork 5
Server API Doc
Ihab Zhaika edited this page Jun 4, 2016
·
29 revisions
Table of Contents
| Method | Url |
|---|---|
| POST | /api/auth/login |
| Type | Params | Values |
|---|---|---|
| BODY | String | |
| BODY | password | String |
| Status | Response |
|---|---|
| 200 | { success: true, name: String, email: String, role: String, phone: String, isOAuth: boolean, approved: boolean, signup_complete: boolean, joined_date: Date ISO String, avatar: img url, renovations: Array, tasks: Array } |
| 400 | {errMessage: "Email or Password are incorrect"} |
| 401 | {data: "Error: User is not logged in", status: 401 } |
| Method | Url |
|---|---|
| GET | /api/auth/isLoggedIn |
| Type | Params | Values |
|---|---|---|
| Status | Response |
|---|---|
| 200 | { success: true, name: String, email: String, role: String, phone: String, isOAuth: boolean, approved: boolean, signup_complete: boolean, joined_date: Date ISO String, avatar: img url, renovations: Array, tasks: Array } |
| 401 | {errMessage: "Error: User is not logged in"} |
| Method | Url |
|---|---|
| GET | /api/auth/logout |
| Type | Params | Values |
|---|---|---|
| Status | Response |
|---|---|
| 200 | {success: true} |
| 401 | {errMessage: "Error: User is not logged in"} |
| Method | Url |
|---|---|
| POST | /api/auth/signup |
| Type | Params | Values |
|---|---|---|
| BODY | String | |
| BODY | password | String |
| BODY | name | String |
| BODY | phone | String |
| BODY | area | String |
| BODY | team_leader | String |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 400 | {errMessage: "Please Provide all required fields"} |
| 400 | {errMessage: "User Already Logged In"} |
| Method | Url |
|---|---|
| POST | /api/auth/signup_oauth |
| Type | Params | Values |
|---|---|---|
| BODY | phone | String |
| BODY | area | String |
| BODY | team_leader | String |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 400 | {errMessage: "Please Provide all required fields"} |
| 400 | {errMessage: "Sign-Up Process has already been completed"} |
| Method | Url |
|---|---|
| GET | /api/auth/activation/:token |
| Type | Params | Values |
|---|---|---|
| PARAMS | token | String |
| Status | Response |
|---|---|
| -- | Redirects to error\success page |
Server assigns action id to request according to passed param
| Method | Url |
|---|---|
| GET | /api/auth/authenticate/:action |
| Type | Params | Values |
|---|---|---|
| PARAMS | action | String |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "No Action ID"} |
| Method | Url |
|---|---|
| POST | /api/auth/forgot |
| Type | Params | Values |
|---|---|---|
| BODY | String | |
| BODY | old_password | String |
| BODY | new_password | String |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 400 | {errMessage: ""} |
| 500 | {errMessage: ""} |
| Method | Url |
|---|---|
| GET | /api/auth/reset/:token |
| Type | Params | Values |
|---|---|---|
| PARAMS | token | String |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 400 | {errMessage: ""} |
| 500 | {errMessage: ""} |
| Method | Url |
|---|---|
| GET | /api/auth/changeEmail/:token |
| Type | Params | Values |
|---|---|---|
| PARAMS | token | String |
| Status | Response |
|---|---|
| 200 | redirect to /login |
| 400 | redirect to /result/error/Error has accord , please try again |
| 400 | redirect to /result/error/invalid token |
| Method | Url |
|---|---|
| POST | /api/auth/changeEmailRequest |
| Type | Params | Values |
|---|---|---|
| BODY | oldEmail | String |
| BODY | newEmail | String |
| Status | Response |
|---|---|
| 200 | redirect to /login |
| 400 | redirect to /result/error/Wrong Email |
| Method | Url |
|---|---|
| GET | /api/chat/history/:chatId |
| Type | Params | Values |
|---|---|---|
| PARAMS | chatId | String |
| Status | Response |
|---|---|
| 200 | {id: chat_id, messages: [{align: msgSide, class: msgClass, content: msgContent, timestamp: HH:mm, user: username}]} |
| 400 | {errMessage: "Invalid Chat Id"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 500 | {errMessage: "Error getting chat history"} |
Endpoints regarding ProjectHands' Referral Receiving Status
| Method | Url |
|---|---|
| POST | /api/status/update_status |
| Type | Params | Values |
|---|---|---|
| BODY | active | boolean |
| BODY | message | String |
| Status | Response |
|---|---|
| 200 | {active: boolean, message: ""} |
| 400 | {errMessage: "Invalid new status"} |
| 500 | {errMessage: "Error updating status"} |
| Method | Url |
|---|---|
| GET | /api/status/get_status |
| Type | Params | Values |
|---|---|---|
| Status | Response |
|---|---|
| 200 | {active: boolean, message: ""} |
| 500 | {errMessage: "Error getting status"} |
| Method | Url |
|---|---|
| POST | /api/dataexchange/import |
| Type | Params | Values |
|---|---|---|
| Status | Response |
|---|---|
| Method | Url |
|---|---|
| GET | /api/dataexchange/export/:collectionName&:query |
| Type | Params | Values |
|---|---|---|
| Status | Response |
|---|---|
| Method | Url |
|---|---|
| POST | /api/photos/uploads |
| Type | Params | Values |
|---|---|---|
| FILES | file | File |
| BODY | album | string |
| Status | Response |
|---|---|
| 200 | {album: string, file_id: string, web_link: string} |
| 400 | {errMessage: "Error: missing album"} |
| 400 | {errMessage: "Error: missing file"} |
| 500 | {errMessage: "Error: file not saved"} |
| Method | Url |
|---|---|
| DELETE | /api/photos/delete |
| Type | Params | Values |
|---|---|---|
| QUERY | file_id | string |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 500 | {errMessage: "Error: file not deleted"} |
| Method | Url |
|---|---|
| GET | /api/photos/album |
| Type | Params | Values |
|---|---|---|
| QUERY | album | string |
| Status | Response |
|---|---|
| 200 | [{album: string, file_id: string, web_link: string},...] |
| 500 | {errMessage: "Couldn't find album"} |
| Method | Url |
|---|---|
| GET | /api/renovation/get_info/:city/:street/:num |
| Type | Params | Values |
|---|---|---|
| PARAMS | city | String |
| PARAMS | street | String |
| PARAMS | num | int |
| Status | Response |
|---|---|
| 200 | {isRSVP: boolean, renovation: {addr: {}, created: date, updated: date, date: date, tasks: [{name: username, ... }], ...} |
| 400 | {errMessage: "No renovation matches the address"} |
| 400 | {errMessage: "Invalid renovation address"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to find renovation"} |
| 500 | {errMessage: "Failed to get renovation info"} |
| Method | Url |
|---|---|
| GET | /api/renovation/get_all |
| Type | Params | Values |
|---|---|---|
| Status | Response |
|---|---|
| 200 | [{...}, {...}, ...] |
| 400 | {errMessage: "No renovations found"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to find renovations"} |
| Method | Url |
|---|---|
| GET | /api/renovation/create |
| Type | Params | Values |
|---|---|---|
| BODY | city | String |
| BODY | street | String |
| BODY | num | int |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 400 | {errMessage: "Invalid renovation address"} |
| 400 | {errMessage: "Renovation already exists"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to create renovation"} |
Updates a user's RSVP status for a renovation.
| Method | Url |
|---|---|
| POST | /api/renovation/rsvp |
| Type | Params | Values |
|---|---|---|
| BODY | city | String |
| BODY | street | String |
| BODY | num | int |
| Status | Response |
|---|---|
| 200 | {rsvp: boolean} |
| 400 | {errMessage: "Invalid renovation address"} |
| 400 | {errMessage: "Renovation does not exists"} |
| 400 | {errMessage: "Renovation does not have a team assigned"} |
| 400 | {errMessage: "Team does not exists"} |
| 400 | {errMessage: "User is not part of renovation team"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to find renovation"} |
| 500 | {errMessage: "Failed to change rsvp status"} |
| Method | Url |
|---|---|
| POST | /api/user/get_info/:email |
| Type | Params | Values |
|---|---|---|
| PARAMS | String |
| Status | Response |
|---|---|
| 200 | {email: "", name: "", role: "", ...} |
| 400 | {errMessage: "Invalid user email"} |
| 400 | {errMessage: "User does not exists"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to find user"} |
| Method | Url |
|---|---|
| GET | /api/user/all_users |
| Type | Params | Values |
|---|---|---|
| Status | Response |
|---|---|
| 200 | [{name: "", email: "", role: "", approved: true, ...}, {...}, ...] |
| 400 | {errMessage: "No users found"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to find users"} |
| Method | Url |
|---|---|
| GET | /api/user/all_signups |
| Type | Params | Values |
|---|---|---|
| Status | Response |
|---|---|
| 200 | [{name: "", email: "", role: guest, approved: false, ...}, {...}, ...] |
| 400 | {errMessage: "No signups found"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to find signups"} |
Approve a user to join Project Hands
| Method | Url |
|---|---|
| POST | /api/user/approve |
| Type | Params | Values |
|---|---|---|
| BODY | String | |
| BODY | role | String |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 400 | {errMessage: "Invalid user email or role"} |
| 400 | {errMessage: "User does not exists"} |
| 400 | {errMessage: "User already approved"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to find user"} |
| 500 | {errMessage: "Failed to approve user"} |
| Method | Url |
|---|---|
| DELETE | /api/user/delete/:email |
| Type | Params | Values |
|---|---|---|
| PARAMS | String |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 400 | {errMessage: "Invalid user email"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to find user"} |
| 500 | {errMessage: "Failed to delete user"} |
| Method | Url |
|---|---|
| POST | /api/user/assign_role |
| Type | Params | Values |
|---|---|---|
| BODY | String | |
| BODY | newRole | String |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 400 | {errMessage: "No user or new role provided"} |
| 400 | {errMessage: "User does not exists"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to find user"} |
| 500 | {errMessage: "Failed to change user role"} |
| Method | Url |
|---|---|
| POST | /api/team/create |
| Type | Params | Values |
|---|---|---|
| BODY | teamName | String |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 400 | {errMessage: "Invalid team name"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to create team"} |
| Method | Url |
|---|---|
| DELETE | /api/team/delete/:name |
| Type | Params | Values |
|---|---|---|
| PARAMS | teamName | String |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 400 | {errMessage: "Invalid team name"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to find team"} |
| 500 | {errMessage: "Failed to delete team"} |
| Method | Url |
|---|---|
| POST | /api/team/add_members |
| Type | Params | Values |
|---|---|---|
| BODY | teamName | String |
| BODY | members | Array |
| Status | Response |
|---|---|
| 200 | {newMembersAdded: ["", "", ...], alreadyInTeam: ["", "", ...]} |
| 400 | {errMessage: "Invalid team name or members email"} |
| 400 | {errMessage: "Team does not exists"} |
| 400 | {errMessage: "Some members do not exists"} |
| 400 | {errMessage: "No new members to add"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to add members to team"} |
| Method | Url |
|---|---|
| POST | /api/team/remove_members |
| Type | Params | Values |
|---|---|---|
| BODY | teamName | String |
| BODY | members | Array |
| Status | Response |
|---|---|
| 200 | {membersRemoved: ["", "", ...], notInTeam: ["", "", ...]} |
| 400 | {errMessage: "Invalid team name or members email"} |
| 400 | {errMessage: "Team does not exists"} |
| 400 | {errMessage: "Some members do not exists"} |
| 400 | {errMessage: "Members are not part of the specified team"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to remove members from team"} |
| Method | Url |
|---|---|
| POST | /api/team/assign_to_renovation |
| Type | Params | Values |
|---|---|---|
| BODY | teamName | String |
| BODY | city | String |
| BODY | street | String |
| BODY | num | int |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 400 | {errMessage: "Invalid team name or renovation address"} |
| 400 | {errMessage: "Team does not exists"} |
| 400 | {errMessage: "Renovation does not exists"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to find team"} |
| 500 | {errMessage: "Failed to assign renovation to team"} |
| Method | Url |
|---|---|
| POST | /api/team/assign_manager |
| Type | Params | Values |
|---|---|---|
| BODY | teamName | String |
| BODY | String |
| Status | Response |
|---|---|
| 200 | {success: true} |
| 400 | {errMessage: "Invalid team name or user email"} |
| 400 | {errMessage: "Team does not exists"} |
| 400 | {errMessage: "User does not exists"} |
| 400 | {errMessage: "User is not part of team"} |
| 401 | {errMessage: "Error: User is not logged in"} |
| 403 | {errMessage: "Not Allowed"} |
| 500 | {errMessage: "Failed to find team"} |
| 500 | {errMessage: "Failed to assign manager to team"} |
Copyright (c) 2016 Netanel Draiman, Dan Draiman, Ihab Zhaika, Ruby Lichtenstien.