Skip to content

Managing_users

larsverp edited this page May 26, 2020 · 3 revisions

The users endpoint is used to list/update and remove users.

ALMOST ALL USERS ENDPOINT REQUIRE AN ADMIN AUTHORISATION The following/{} endpoint does not require admin authorisation.

πŸ“„ Checklist

  • Create a get method, so the user can be shown.
  • Create an update method, so users can be changed.
  • Create a remove method, so users can be removed.

πŸ“– Get users (get method)

The get endpoints do not use any body text.

  • /api/users returns all users.
[
    {
        "id": 1,
        "first_name": "Adonis",
        "insertion": "van",
        "last_name": "Dare",
        "email": "test@test.nl",
        "email_verified_at": "2020-04-28T13:19:13.000000Z",
        "postal_code": "5673RE",
        "role": "rockstar",
        "created_at": "2020-04-28T13:19:13.000000Z",
        "updated_at": "2020-04-28T13:19:13.000000Z"
    }
]
❌ Errors:
  • [] - There are no users to show
βœ”οΈ On succes:

200 OK - returns a JSON object with all users.


πŸ“ Update users(put method)

The put endpoints do not require anything in the body. Only add the fields you want to change to the body.

  • /api/users/[id] returns the entire (edited) user.
    • first_name (string, max:191) - The first name.
    • insertion (nullable, max:191) - The insertion.
    • last_name (string, max:191) - The last name.
    • postal_code (NL|DE|BE Postal code) - The postal code.
    • password (string, max:191) - The users password.
    • role (string has to be: guest, partner, rockstar or admin) - Change the users role
❌ Errors:
  • Errors are equal to the create endpoint
  • No error will be trown when the body is empty
βœ”οΈ On succes:

200 OK - returns a JSON object with the updated user data.


πŸ™… Remove users (delete method)

The delete endpoint does not require anything in the body.

  • /api/users/[id] removes the user and returns it.
❌ Errors:

404 Not found - The requested user does not exist

βœ”οΈ On succes:

200 OK - returns a JSON object with the removed user.


πŸ§‘β€πŸ€β€πŸ§‘ Get following hosts (get method)

The get endpoint does not require anything in the body.

  • /api/users/following/hosts returns the hosts followed by the user.
❌ Errors:

404 Not found - The requested user does not exist

βœ”οΈ On succes:

200 OK - returns a JSON object containing all hosts followed by the current user.


πŸ§‘β€πŸ€β€πŸ§‘ Get following categories (get method)

The get endpoint does not require anything in the body.

  • /api/users/following/categories returns the categories followed by the user.
❌ Errors:

404 Not found - The requested user does not exist

βœ”οΈ On succes:

200 OK - returns a JSON object containing all categories followed by the current user.

Clone this wiki locally