Users

Users are the principal model implemented here. It is needed to perform any other task in this API.

Create User

Users can be created by issuing a POST request to the /users endpoint. An user is required to have a name. Users with same name are allowed to coexist.

Attributes
  • name string

  • Name of the user being created

API will return the new user record, using the provided name, and a generated ID:

Response Values
  • ID string

  • Unique ID for the created user

  • name string

  • The user’s name, as provided through the request

Request

1POST /users
2
3name=Fefo

Response

1{ 
2  "id": "FA3901CC-F667-4AA0-8CFE-B6B1C5058DFA", 
3  "name": "Fefo" 
4}

Get Users

To get all known users, issue a GET request to /users. The endpoint will return a list containing all users, together with their IDs

Attributes
  • ID string

  • Unique ID for the created user

  • name string

  • The user’s name

Request

1GET /users

Response

 1[
 2  {
 3	"id": "FA3901CC-F667-4AA0-8CFE-B6B1C5058DFA", 
 4	"name": "Fefo"
 5  },
 6  { 
 7	"id": "BA77D274-12B1-487D-8C9E-72F0D37BAC05", 
 8	"name": "Vito"
 9  }
10]

Tasks

Create Task

In order to create a Task, one must know the User ID to whom the task will belong to. Knowing that information, issue a POST request to /users/:id/tasks, :id being replaced with the user’s ID.

Attributes
  • title string

  • A descriptive name for the task. For example, But milk.

The value returned will represent te internal Task object used by the API, which will contain two extra fields besides title:

Attributes
  • id string

  • A unique value to identify this task among all other tasks

  • title string

  • The Task’s title

  • done bool

  • Value indicating whether the task has been completed (true) or not (false)

Request

1POST /users/8CD63BEE-CEF3-4CEC-83FD-6E3C2C2A0B47/tasks
2
3title=Buy+Milk

Response

1{ 
2  "id": "B0FA0790-9CB0-473F-8E0B-7BD36D6CE867",
3  "title": "Buy Milk",
4  "done": false
5}

Marking as Complete

Marking a task as completed consists in issuing a PATCH request to /users/:uid/tasks/:id, which will mark a task with id :id belonging to User :uid as done.

Request

1PATCH /users/8CD63BEE-CEF3-4CEC-83FD-6E3C2C2A0B47/tasks/B0FA0790-9CB0-473F-8E0B-7BD36D6CE867

Response

1{ 
2  "id": "B0FA0790-9CB0-473F-8E0B-7BD36D6CE867",
3  "title": "Buy Milk",
4  "done": true
5}

Listing Tasks

The endpoint /users/:id/tasks is responsible for listing all tasks for a given user. It also accepts an optional status querystring parameter, used to filter which kind of tasks to list.

QueryString
  • status optional string

  • Optional parameter to only show tasks in a specific condition.

    Enum values
    • all

    • Shows all tasks, independent of their status.

    • pending

    • Shows only tasks not marked as completed.

    • done

    • Shows only completed tasks.

Response

 1[
 2  { 
 3    "id": "B0FA0790-9CB0-473F-8E0B-7BD36D6CE867",
 4    "title": "Buy Milk",
 5    "done": true
 6  },
 7  { 
 8    "id": "97FF0CC1-BC1C-4415-ABEA-39666F759EAD",
 9    "title": "Check for mail",
10    "done": false
11  },
12]