Skip to content

API Documentation

Matt Eden edited this page Apr 24, 2020 · 11 revisions

Get a user

Get a users information based off email

URL : /user/get

Method : GET

Auth required : NO

Data constraints

{
	"Username" : "[Unique email address]",
}

Data example:

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

Success response

Code : 200 OK

Content examples

{

	"name" : "Someone",
        "email" : "[email protected]",
        "password"  : "sfasfasf",
        "_id" : "325235",
        "_v" : ""

}

Notes:

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

Update a user

Update a users information

URL : /user/update

Method : PUT

Auth required : YES

Data constraints

{
	"Username" : "[Unique email address]",
}

Data example:

{
	"name" : "Someone",
        "email" : "[email protected]",
        "password"  : "sfasfasf",
        "_id" : "",
        "_v" : ""
}

Success response

Code : 200 OK

Content examples

{
	"Success" : "OK",
}

Get all users

Get users registered

URL : /user/email

Method : GET

Auth required : NO

Success response

Code : 200 OK

Content examples

Returns all registered users

{

	"name" : "Someone",
        "email" : "[email protected]",
        "password"  : "",
        "_id" : "325235",
        "_v" : ""

}

Schedule a task

Used to schedule a task

URL : /task/post

Method : POST

Auth required : NO

Data constraints:

{
	"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

{
	"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

{
	"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

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

For an unsuccessful task scheduled

{
    "task_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:

{
    	"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:

{
    	"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

{

	"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"
},
{
        "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"
}

Get Google Authentication

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

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