Users API
Description of the functionality of Users API
API
Note: The following is defined in express/routes/survey.route.js
*WIP: This actually hasn't been defined yet, the code does not exist as of 0.0.6a

Headers
Private
qmd: ng-client
<'SESSION_ID': [token] Secure Cookie>
Public
qmd: ng-client
Get All User Data for Survey
<url>/api/:id/users
i.e. http://localhost:8080/api/SomeSurveyID/users
Method
Description
Access
GET
Respond with all user data for survey {:id}
Private
Add new User Data
<url>/api/:id/addUser
i.e. http://localhost:8080/api/SomeSurveyID/addUser
Method
Description
Access
POST
Add new user data (corresponding to survey {:id}, respond with user_id
Public
Managing Individual User Data
<url>/api/ :id/user/:user_id
i.e. http://localhost:8080/api/SomeSurveyID/user/SomeUserID
Method
Description
Access
GET
Respond with user data corresponding to {:user_id} from survey {:id}
Public
POST
Update user data corresponding to {:user_id} from survey {:id}
Public*
DELETE
Remove user data corresponding to {:user_id} from survey {:id}
Private
Middleware
Access through src/app/user.service.ts
Importing Into Component
import { UserService } from '../../survey.service';
import { User} from '../../Models';
...
export class ... {
constructor( ... , private userservice: UserService)
}
Functions
src/app/user.service.ts
Adding Authorization Header
Adds api key as a HttpHeader
addAuthHeader(api_key)
Param
Type
Description
api_key
string
API Key for authentication
Adding a New User (Private)
Contacts Survey API through HTTP to add a new user to a survey in the database, returns response from server *WIP: Deciding input format
addUser(survey_id: string, registration_info: any)
Param
Type
Description
survey_id
string
String corresponding to the survey's id
registration_info
any
Registration Fields
return
HttpResponse<>
HttpErrorResponse
Response (200/400)
Get an Existing User (Public)
Queries Survey API through HTTP given a survey_id and user_id, if a user/survey with these ids is in the database, returns user corresponding to this id pair.
getUser(survey_id: string, user_id: string)
Param
Type
Description
survey_id
string
String corresponding to the survey's id
user_id
string
String corresponding to the user's id
Deleting an Existing User (Private)
Queries Survey API through HTTP to delete User corresponding to Survey corresponding to id, returns response from server.
deleteUser(survey_id: string, user_id: string)
Param
Type
Description
survey_id
string
String corresponding to the survey's id
user_id
string
String corresponding to the user's id
return
HttpResponse<>
HttpErrorResponse
Response (200/400)
Get All Users for a Survey (Private)
Queries Survey API through HTTP to get an array of all Users corresponding to the Survey corresponding to survey_id, returns User Array
getAllUsers(survey_id: string) => return User[] object array
Param
Type
Description
survey_id
string
String corresponding to the survey's id
Update User (Private)
Queries Survey API through HTTP with User data and survey ID to update the relevant User data, returns response from server.
updateUser(survey_id: string, input: any)
Param
Type
Description
survey_id
string
String corresponding to the survey's id
return
HttpResponse<>
HttpErrorResponse
Response (200/400)
Last updated