Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

User Endpoints

tigermli edited this page Feb 20, 2021 · 8 revisions

The following endpoints cover how to list, view, create, and delete Users.

To populate your table with test users:
docker-compose run web rake db:seed

List users
GET localhost:3000/users/?room_id=2
Returns (room_id is optional)

[
    {
        "id": 1,
        "is_auth": true,
        "username": "Ryan X.",
        "name": "Ryan",
        "password": "password",
        "created_at": "2021-02-18T08:18:25.843Z",
        "updated_at": "2021-02-18T08:18:25.843Z"
    },
    {
        "id": 2,
        "is_auth": true,
        "username": "aprilsanchez",
        "name": "April",
        "password": "password",
        "created_at": "2021-02-18T08:18:25.865Z",
        "updated_at": "2021-02-18T08:18:25.865Z"
    },
    {
        "id": 3,
        "is_auth": true,
        "username": "Laboni",
        "name": "Laboni",
        "password": "password",
        "created_at": "2021-02-18T08:18:25.872Z",
        "updated_at": "2021-02-18T08:18:25.872Z"
    }
]

Get a user
GET localhost:3000/user/?id=3
Returns

{
    "id": 3,
    "is_auth": true,
    "username": "Laboni",
    "name": "Laboni",
    "password": "password",
    "created_at": "2021-02-18T08:18:25.872Z",
    "updated_at": "2021-02-18T08:18:25.872Z"
}

Create a user
POST localhost:3000/user
Request Body:

{
    "username": "BBoe",
    "password": "password",
    "name": "Bryce"
}

Returns (is_auth = true if password provided)

{
    "id": 8,
    "is_auth": true,
    "username": "BBoe",
    "name": Bryce,
    "password": password,
    "created_at": "2021-02-18T08:47:00.809Z",
    "updated_at": "2021-02-18T08:47:00.809Z"
}

Delete a user
DELETE localhost:3000/user/?id=3
Returns (if id exists)

{
    "id": 3,
    "is_auth": true,
    "username": "Laboni",
    "name": "Laboni",
    "password": "password",
    "created_at": "2021-02-18T08:18:25.872Z",
    "updated_at": "2021-02-18T08:18:25.872Z"
}

Returns (if id does not exist)

{
    "status": 404
}
Clone this wiki locally