Skip to content

API Documentation

emzoo16 edited this page Mar 19, 2020 · 11 revisions

Add new User

Used to register the user for the application

URL : /auth/register/post

Method : POST

** Auth required** : NO

Data constraints

{
	"Username" : "[Unique email address]",
	"Password" : "[Password the user chooses]"
}

Data example:

{
	"Username" : "[email protected]",
	"Password"  : "softwareengineering"	
}

Success response

Code : 200 OK

Content examples

For user that wants to register their account without doing it before

{
    "_id": "1234",
    "Successful": "True"
}

For user that wants to register their account again

{
    "_id": " ",
    "Successful": "False"
}

Notes:

User should not be able to register twice, and the username (email) of the account must be unique

Login

Used to log the user into the application

URL : /auth/login

Method : POST

Auth required : YES

Data constraints:

{
	"Username" : "[Unique email address]",
	"Password"  : "[Password the user chooses]"
}

Data example:

{
	"Username" : "[email protected]",
	"Password"  : "softwareengineering"	
}

Success response

Code : 200 OK

Content examples

For a user with ID 1234 on the database where the user has saved their login information:

{
    	"name": "Jason",
    	"email": "[email protected]",
    	"_id": "1234", 
        "Picture": "imgur.com/ao12r",
        "Preferences": "blue",
    	"__v": "0"
}

Notes:

User first has to register

Get user info

Get the user information such as email, id, profile pic string etc

URL : /user/:username

URL parameters : username = the username (email) of the current login

Method : GET

Auth required : YES

Success response

Code : 200 OK

Content examples

Returns the information of the user

{
	"_id" : "1234",
	"email": "[email protected]", 
	"name": "Lucy", 
}

UpdateUser

Used to update a user’s task

URL : /user/:name

URL parameters : name = the email of the user that needs update

Method : PUT

Auth required : YES

Data constraints:

{
	"email": "[email]", 
	"name": "[name]", 
	"picture": "[pic]", 
	"themePreference": "[theme]"
}

Success response

Code : 200 OK

Content examples

For a successful update

{
    "email" : "1234",
    "Successful" : "True"
}

For an unsuccessful update

{
    "email" : "1234",
    "Successful" : "False"
}

Schedule a task

Used to schedule a task

URL : /task/post

Method : POST

Auth required : NO

Data constraints:

{
        "Task_id": [unique task id string],	
        "Title" : "Name for schedule task",
	"Description"  : "[Description for task]",
	"Start_Date" : "[Time of creation]",
	"End_Date" : "[Time to finish task by]",
	"User_id" : "[Users google ID]",
	"Location" : "[Location of their task]",
	"Color" : "[Preferences of task color]"
}

Data example:

With all fields filled

{
        "Task_id": 1234,	
        "Title" : "Eat dinner",
	"Description"  : "Eat dinner for tonight",
	"Start_Date" : "2020-03-12T09:50:00.000",
	"End_Date" : "2020-03-19T10:55:00.000",
	"User_id" : "[email protected]",
	"Location" : "Home",
	"Color" : "Red"
}

With only mandatory fields filled

{
	"Task_id": 1234,
        "Title" : "Eat dinner",
	"Description"  : "Eat dinner for tonight",
	"Start_Date" : "2020-03-12T09:50:00.000",
	"End_Date" : "2020-03-19T10:55:00.000",
	"User_id" : "[email protected]",
	"Location" : "Home",
	"Color" : " "
}

Success response

Code : 200 OK

Content examples

For a successful task scheduled

{
    "_id" : "1234",
    "Successful" : "True"
}

For an unsuccessful task scheduled

{
    "_id" : "1234",
    "Successful" : "False"
}

UpdateTask

Used to update a user’s task

URL : /task/:taskid

URL parameters : taskid = the id of the task the user wants to change

Method : PUT

Auth required : NO

Data Constraints:

{
    	"task_id" : "1234",
	"Title" : "[Name for schedule task]",
	"Description"  : "[Description for task]",
	"Start_Date" : "[Time of creation]",
	"End_Date" : "[Time to finish task by]",
	"Location" : "[Location of their task]",
	"Color" : "[Preferences of task color]"
}

Data example:

{
    	"task_id" : "1234",
	"Title" : "Eat breakfast",
	"Description" : "Eat breakfast for today",
	"Start_Date" : "2020-03-12T08:50:00.000",
	"End_Date" : "2020-03-19T09:55:00.000",
	"Location" : "Home",
	"Color" : "Red"
}

Success response

Code : 200 OK

Content examples

If the user enters a valid update and task ID

{
    "task_id" : "1234",
    "Successful" : "True"
}

GetTasks

Get the tasks of a user

URL : /task/get/:username

URL parameters : username = the username of the current login

Method : GET

Auth required : YES

Success response

Code : 200 OK

Content examples

Returns all the tasks the current user has

{

	"task_id" : "1234",
        "Title" : "Eat dinner",
        "Description"  : "Eat dinner for tonight",
        "Start_Date" : "2020-03-12T21:50:00.000",
        "End_Date" : "2020-03-12T22:55:00.000",
        "User_id" : "[email protected]",
        "Location" : "Home",
        "Color" : "Red"
},
{
        "task_id" : "1231241244",
        "Title" : "Eat lunch",
        "Description"  : "Eat lunch for today",
        "Start_Date" : "2020-03-12T13:50:00.000",
        "End_Date" : "2020-03-12T11:55:00.000",
        "User_id" : "[email protected]",
        "Location" : "Home",
        "Color" : "Red"
}

DeleteTask

Used to delete a user’s task

URL : /task/:taskid

URL parameters : taskid = the id of the task the user wants to change

Method : DELETE

Auth required : NO

Data Constraints:

{
    "id" : "[ID of the task]"
}

Data example:

{
    "id" : "1234"
}

Success response

Code : 200 OK

Content examples

If the user enters a valid task ID

{
    "task_id" : "1234",
    "Deleted" : "True"
}

If the user enters an invalid task ID

{
    "task_id" : "1234",
    "Deleted" : "False"
}

Authenticate with Google

Takes user to google sign in page. Upon sign in redirects user to main calendar page.

URL : /api/auth/google

Method : GET

Auth required : NO

Success response

Content examples

Redirects user to the /calendar page with the following URL parameters

email : base 64 encoded email of signed in user

accessToken : bearer token to be passed in header of subsequent requests to authorise user

Clone this wiki locally