Skip to content

Latest commit

 

History

History
189 lines (186 loc) · 3.19 KB

README.md

File metadata and controls

189 lines (186 loc) · 3.19 KB

justdoit

one more todo list implementation - university project

TODO list description

Each todolist consists of a title field and a list of tasks.

Task description

Each task consists of a title field and a description field.

API

API is based on vnd.api+json.

get api description

REQUEST:

GET /justdoit

RESPONSE:

Content-Type: application/json
{
	"_links": {
		"todolists": { "href": "/justdoit/todolists" },
	},
}

get todolists

REQUEST:

GET /justdoit/todolists
Accept: application/vnd.api+json

RESPONSE:

Content-Type: application/vnd.api+json
{
	"data": [
		{
			"id": "todolist id",
			"type": "todolist",
			"attributes": { "title": "title of the todolist", },
			"links": { "self: { "href": "/justdoit/todolists/{id} } },
		},
	],
}

get the todo list

REQUEST:

GET /justdoit/todolists/{id}
Accept: application/vnd.api+json

RESPONSE:

Content-Type: application/vnd.api+json
{
	"data": {
		"id": "1",
		"type": "todolist",
		"attributes": { "title": "title of the todolist", },
		"relationships": {
			"tasks": {
				"links": {
					"related": {
						"href": "/justdoit/todolists/{id}/tasks",
					},
				},
			},
		},
	},
	"links": { "self": { "href": "/justdoit/todolists/{id}" }, },
}

create new todo list

REQUEST:

POST /justdoit/todolists
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
{
	"data": {
		"type": "todolist",
		"attributes": { "title": "title of the todolist", },
	},
}

RESPONSE:

HTTP/1.1 201 Created
Location: /justdoit/todolists/{id}

remove the todo list

REQUEST:

DELETE /justdoit/todolists/{id}

RESPONSE:

HTTP/1.1 200 OK

get tasks for the todolist

REQUEST:

GET /justdoit/todolists/{id}/tasks
Accept: application/vnd.api+json

RESPONSE:

Content-Type: application/vnd.api+json
{
	"data": [
		{
			"id": "task id",
			"type": "task",
			"attributes": {
				"title": "title of the task",
				"description": "description of the task",
			},
			"links": { "self": { "href": "/justdoit/todolists/{id}/tasks/{taskId}" } },
		},
	],
	"links": { "self": { "href": "/justdoit/todolists/{id}" }, },
}

add a task to the todo list

REQUEST:

POST /justdoit/todolists/{id}/tasks
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
{
	"data": {
		"type": "task",
		"attributes": {
			"title": "title of the task",
			"description": "description of the task",
		},
	}
}

RESPONSE:

HTTP/1.1 201 Created
Location: /justdoit/todolists/{id}/tasks/{taskId}

remove the task

REQUEST:

DELETE /justdoit/todolists/{id}/tasks/{taskId}

RESPONSE:

HTTP/1.1 200 OK

modify the task

REQUEST:

PATCH /justdoit/todolists/{id}/tasks/{taskId}
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
{
	"data": {
		"id": "taskId",
		"type": "task",
		"attributes": { "description": "new description here", },
	},
}

RESPONSE:

HTTP/1.1 200 OK

modify the list

REQUEST:

PATCH /justdoit/todolists/{id}
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
{
	"data": {
		"id": "todolist id",
		"type": "todolist",
		"attributes": { "title": "new title here", },
	}
}

RESPONSE:

HTTP/1.1 200 OK