Skip to content
Vlad Stoica edited this page Mar 13, 2017 · 12 revisions

Creating a new user

To create a new user you will have to create a new POST request to the following URL: https://project-run.herokuapp.com/users. The body of the request should contain the name, email and password. A sample JSON of the request is:

{
  "name":"John Doe",
  "email":"[email protected]",
  "password":"dkjIUm21"
}

The response will be a JSON again. A sample is provided below:

{
  "id": 4,
  "name": "John Doe",
  "email": "[email protected]",
  "password_digest": "$2a$10$XtDtrOH2Pq0fV/g60yNQF.3jafd6I/TX8KeDzL94onQpbCIc53i.2",
  "created_at": "2017-02-21T20:06:44.583Z",
  "updated_at": "2017-02-21T20:06:44.583Z"
}

Editing an user (Authenticated resource) - need update at the moment

PATCH to https://project-run.herokuapp.com/users/ for updating user with. This is an authenticated resource so you will receive a 401` if the token sent doesn't have modifying permissions for that user.

The params permitted are the following

{
      "name":"John Doe",
      "email":"[email protected]",
      "password":"dkjIUm21"
}

Showing which groups the user is in and the role in that group (Authenticated resource)

GET request to https://project-run.herokuapp.com/users/mine/groups A sample response for this request:

[
  {
    "id": 1,
    "name": "Group use2",
    "creator": "[email protected]",
    "role": "admin"
  },
  {
    "id": 2,
    "name": "Group us2",
    "creator": "[email protected]",
    "role": "student"
  }
]

Showing all user's quizzes from all groups (Authenticated resource)

GET request to https://project-run.herokuapp.com/users/mine/quizzes

[
  {
    "id": 3,
    "title": "My quiz",
    "status": "not_started"
  }
]

Searching for a user

POST request at https://project-run.herokuapp.com/users/search with the following parameters:

{
  "input": "what_to_look_for"
}

The request will return the best match for name and email and alternative matched for name and email.