This application supports multiple users. Each user is a document in the database that contains the following information:
{
"_id": ObjectId,
"years": [
{
"year": Integer,
"startdate": Date,
"lastdate": Date,
"office": Integer,
"remote": {
"total": Integer,
"locations": {
String: Integer
}
},
"vacation": Integer,
"holidays": Integer,
"sick": Integer
}
]
}
Users must login in order to view and modify thir own respective work log. Once a user is logged in, they have a 20 minute session before being logged out.
Command
curl http://localhost:5000/login -H "Content-Type: application/json" -X POST -d '{"username": "<user>","password": "<password>"}'
User = Username for user.
Password = Password for user.
Response
Success: The response is a 200 status code. The response body is a JSON object containing a success message.
Not Logged In: When the user specified is not a valid username and/or the password specified is not valid/correct, the response is a 400 status code. The response body is a JSON object containing an error message.
A user must be created in order to use this application. The account information needed is a username and a password.
Command
curl http://localhost:5000/user/create -H "Content-Type: application/json" -X PUT -d '{"username": "<user>","password": "<password>"}'
User = Username for user.
Password = Password for user.
Response
Success: The response is a 200 status code. The response body is a JSON object contianing a success message.
User Already Exists: When the user specified is already a valid user in the database, the response is a 400 status code. The response body is a JSON object containing an error message.
User Not Created: When the user specified is not a valid username and/or the password specified is not valid, the response is a 400 status code. The response body is a JSON object containing an error message.
Users have the ability to reset their password.
Command
curl http://localhost:5000/user/<user>/password/reset -H "Content-Type: application/json" -X PUT -d '{"new_password": <newpassword>, "password": <password>}'
User = Username for user.
Password = Current password for user.
NewPassword = New password for user.
Response
Success: The response is a 200 status code. The response body is a JSON object contianing a success message.
Password Not Reset: When the user specified is not a valid username and/or the password specified is not valid/correct, the response is a 403 status code. The response body is a JSON object containing an error message.
Each year is a document in a years list located in each user's unique document in the database that contains the following information:
{
"year": Integer,
"startdate": Date,
"lastdate": Date,
"office": Integer,
"remote": {
"total": Integer,
"locations": {
String: Integer
}
},
"vacation": Integer,
"holidays": Integer,
"sick": Integer
}
Command
curl http://localhost:5000/user/<user>/year/<year>
User = Username for user.
Year = Year to view.
Response
Success: The response is a 200 status code. The response body is a JSON object containing all of the logged information about a given year.
No Year Found: When there is no document for the year specified, the response is a 404 status code. The response body is a JSON object containing an error message.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
The total for each year refers to the total number of days worked during a calendar year. This includes both days worked in the office and remote.
{
"total": Integer,
"startdate": Date,
"lastdate": Date
}
Command
curl http://localhost:5000/user/<user>/year/<year>/total
User = Username for user.
Year = Year to view.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the total information for a given year.
No Year Found: When there is no document for the year specified, the response is a 404 status code. The response body is a JSON object cantaining an error.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
The office for each year refers to the number of days worked in the office during a calendar year.
{
"office": Integer,
"startdate": Date,
"lastdate": Date
}
Command
curl http://localhost:5000/user/<user>/year/<year>/office
User = Username for user.
Year = Year to view.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the office information for a given year.
No Year Found: When there is no document for the year specified, the response is a 404 status code. The response body is a JSON object cantaining an error.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
Command
curl http://localhost:5000/user/<user>/year/<year>/office/<office> -X POST
User = Username for user.
Year = Year to update.
Office = Number of days to be added to the already existing office total.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the updated office total information for a given year.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Invalid Office Total: When the office variable input is invalid and not a positive number, or the total to increase by plus the already existing total is greater than the number of total days from the given year's start date to the latest date logged, the response is a 400 status code. The response body is a JSON object containing an error.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
Command
curl http://localhost:5000/user/<user>/year/<year>/office/<office> -X PUT
User = Username for user.
Year = Year to reset.
Office = Number of days to be reset to for working in the office for a given year.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the reset office total information for a given year.
No Year Found: When there is no document for the year specified, the response is a 404 status code. The response body is a JSON object cantaining an error.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Invalid Office Total: When the office variable input is invalid and not a postive number, or the reset value is greater than or equal to the existing office total, the response is a 400 status code. The response body is a JSON object containing an error.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
The remote for each year refers to the number of days worked remotely during a calendar year. In addition, the remote includes a breakdown of the locations worked remotely and the number of days worked at each location.
{
"remote": {
"total": Integer,
"locations": {
String: Integer
}
},
"startdate": Date,
"lastdate": Date
}
Command
curl http://localhost:5000/user/<user>/year/<year>/remote
User = Username for user.
Year = Year to view.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the remote information for a given year.
No Year Found: When there is no document for the year specified, the response is a 404 status code. The response body is a JSON object cantaining an error.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
Command
curl http://localhost:5000/user/<user>/year/<year>/remote/location/<location>/<remote> -X POST
User = Username for user.
Year = Year to update.
Location = Remote location worked to update.
Remote = Number of days to be added to the already existing remote total for the given location and year.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the updated remote total information for a given year.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Invalid Remote Total: When the remote variable input is invalid and not a positive number, or the total to increase by plus the already existing total is greater than the number of total days from the given year's start date to the latest date logged, the response is a 400 status code. The response body is a JSON object containing an error.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
Command
curl http://localhost:5000/user/<user>/year/<year>/remote/location/<location>/<remote> -X PUT
User = Username for user.
Year = Year to reset.
Location = Remote location worked to reset.
Remote = Number of days to be reset to for working remotely for a given year and location.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the reset remote total information for a given year.
No Year Found: When there is no document for the year specified, the response is a 404 status code. The response body is a JSON object cantaining an error.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Invalid Office Total: When the remote variable input is invalid and not a postive number, or the reset value is greater than or equal to the existing remote total, the response is a 400 status code. The response body is a JSON object containing an error.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
The vacation for each year refers to the number of vacation days used during a calendar year.
{
"vacation": Integer,
"startdate": Date,
"lastdate": Date
}
Command
curl http://localhost:5000/user/<user>/year/<year>/vacation
User = Username for user.
Year = Year to view.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the vacation information for a given year.
No Year Found: When there is no document for the year specified, the response is a 404 status code. The response body is a JSON object cantaining an error.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
Command
curl http://localhost:5000/user/<user>/year/<year>/vacation/<vacation> -X POST
User = Username for user.
Year = Year to update.
Vacation = Number of days to be added to the already existing vacation total for the given year.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the updated vacation total information for a given year.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Invalid Vacation Total: When the vacation variable input is invalid and not a positive number, or the total to increase by plus the already existing total is greater than the number of total days from the given year's start date to the latest date logged, the response is a 400 status code. The response body is a JSON object containing an error.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
Command
curl http://localhost:5000/user/<user>/year/<year>/vacation/<vacation> -X PUT
User = Username for user.
Year = Year to reset.
Vacation = Number of days to be reset to for vacation for a given year.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the reset vacation total information for a given year.
No Year Found: When there is no document for the year specified, the response is a 404 status code. The response body is a JSON object cantaining an error.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Invalid Office Total: When the vacation variable input is invalid and not a postive number, or the reset value is greater than or equal to the existing vacation total, the response is a 400 status code. The response body is a JSON object containing an error.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
The holidays for each year refers to the number of holidays used during a calendar year.
{
"holidays": Integer,
"startdate": Date,
"lastdate": Date
}
Command
curl http://localhost:5000/user/<user>/year/<year>/holidays
User = Username for user.
Year = Year to view.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the holiday information for a given year.
No Year Found: When there is no document for the year specified, the response is a 404 status code. The response body is a JSON object cantaining an error.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
Command
curl http://localhost:5000/user/<user>/year/<year>/holidays/<holidays> -X POST
User = Username for user.
Year = Year to update.
Holidays = Number of days to be added to the already existing holiday total for the given year.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the updated holiday total information for a given year.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Invalid Holiday Total: When the holidays variable input is invalid and not a positive number, or the total to increase by plus the already existing total is greater than the number of total days from the given year's start date to the latest date logged, the response is a 400 status code. The response body is a JSON object containing an error.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
Command
curl http://localhost:5000/user/<user>/year/<year>/holidays/<holidays> -X PUT
User = Username for user.
Year = Year to reset.
Holidays = Number of days to be reset to for holidays for a given year.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the reset holiday total information for a given year.
No Year Found: When there is no document for the year specified, the response is a 404 status code. The response body is a JSON object cantaining an error.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Invalid Office Total: When the holidays variable input is invalid and not a postive number, or the reset value is greater than or equal to the existing vacation total, the response is a 400 status code. The response body is a JSON object containing an error.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
The sick for each year refers to the number of sick days used during a calendar year.
{
"sick": Integer,
"startdate": Date,
"lastdate": Date
}
Command
curl http://localhost:5000/user/<user>/year/<year>/sick
User = Username for user.
Year = Year to view.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the sick information for a given year.
No Year Found: When there is no document for the year specified, the response is a 404 status code. The response body is a JSON object cantaining an error.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
Command
curl http://localhost:5000/user/<user>/year/<year>/sick/<sick> -X POST
User = Username for user.
Year = Year to update.
Sick = Number of days to be added to the already existing sick days total for the given year.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the updated sick days total information for a given year.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Invalid Sick Days Total: When the sick variable input is invalid and not a positive number, or the total to increase by plus the already existing total is greater than the number of total days from the given year's start date to the latest date logged, the response is a 400 status code. The response body is a JSON object containing an error.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.
Command
curl http://localhost:5000/user/<user>/year/<year>/sick/<sick> -X PUT
User = Username for user.
Year = Year to reset.
Sick = Number of days to be reset to for sick days for a given year.
Response
Success: The response is a 200 status code. The response body is a JSON object containing the reset sick days total information for a given year.
No Year Found: When there is no document for the year specified, the response is a 404 status code. The response body is a JSON object cantaining an error.
Invalid Year: When the year specified is not a valid integer year, the response is a 400 status code. The response body is a JSON object containing an error message.
Invalid Sick Days Total: When the sick variable input is invalid and not a postive number, or the reset value is greater than or equal to the existing vacation total, the response is a 400 status code. The response body is a JSON object containing an error.
Not Logged In: When the user specified is not a valid username or the valid user is not currently logged in, the response is a 403 status code. The response body is a JSON object containing an error message.