2020-03-23 16:38:43 +00:00
|
|
|
## API Documentation
|
|
|
|
___
|
|
|
|
> Values required in **`bold`**.
|
|
|
|
|
|
|
|
### **Accounts** | `account`
|
|
|
|
| field | data type | metadata |
|
|
|
|
| :-------------| :---------------- | :-------------------------------------------------- |
|
|
|
|
| id | unsigned integer | primary key, auto-increments, generated by database |
|
|
|
|
| username | string | required |
|
|
|
|
| email | string | required |
|
|
|
|
| password | string | required |
|
|
|
|
| timezone | string | |
|
|
|
|
| earliest_time | string | |
|
|
|
|
| latest_time | string | |
|
|
|
|
| created_at | datetime | generated by database |
|
|
|
|
|
2020-03-23 16:55:47 +00:00
|
|
|
#### Register an account
|
|
|
|
**`POST /api/account/register`**
|
2020-03-23 16:38:43 +00:00
|
|
|
|
|
|
|
##### Request
|
|
|
|
A json object for the user to register with **`username`**, **`email`**, **`password`**, `timezone`, `earliest_time` and `latest_time`.
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"username": "jean,
|
|
|
|
"email": "jean@example.com",
|
|
|
|
"password": "really-strong-password",
|
|
|
|
"timezone": "Europe/Brussels",
|
|
|
|
"earliest_time":"09:30 AM",
|
|
|
|
"latest_time":"10:00 PM"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
##### Response
|
|
|
|
A json object for the registered user with `id`, `username`, `email`, `timezone`, `earliest_time` and `latest_time`.
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"username": "jean",
|
|
|
|
"email": "jean@example.com",
|
|
|
|
"timezone": "Europe/Brussels",
|
|
|
|
"earliest_time":"09:30 AM",
|
|
|
|
"latest_time":"10:00 PM"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Update an account
|
2020-03-23 16:55:47 +00:00
|
|
|
**`PUT /api/account/:id/profile`**
|
2020-03-23 16:38:43 +00:00
|
|
|
|
|
|
|
##### Request
|
|
|
|
A json object for the user to register with `id` and any of `username`, `email`, `password`, `timezone`, `earliest_time`, `latest_time`.
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"id": 15,
|
|
|
|
"earliest_time":"08:30 AM",
|
|
|
|
"latest_time":"08:00 PM"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
##### Response
|
|
|
|
A json object for the registered user with `id`, `username`, `email`, `timezone`, `earliest_time` and `latest_time`.
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"username": "jean",
|
|
|
|
"email": "jean@example.com",
|
|
|
|
"timezone": "Europe/Brussels",
|
|
|
|
"earliest_time":"09:30 AM",
|
|
|
|
"latest_time":"10:00 PM"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Delete an account
|
|
|
|
**`DELETE /api/account/:id`**
|
|
|
|
|
|
|
|
##### Request
|
|
|
|
A json object for the user to delete with `id`.
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"id": 15
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
##### Response
|
|
|
|
A json object for the deleted user with `username` and `email`.
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"username": "jean",
|
|
|
|
"email": "jean@example.com"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Log in an account
|
2020-03-23 16:55:47 +00:00
|
|
|
**`POST /api/account/login`**
|
2020-03-23 16:38:43 +00:00
|
|
|
|
|
|
|
##### Request
|
|
|
|
A json object for the user to login with either **`email`** or **`username`**, and **`password`** .
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"username": "jean",
|
|
|
|
"password": "super-strong-password"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
##### Response
|
2020-03-23 16:55:47 +00:00
|
|
|
A json object for the registered user with `id`, `username`, `email`, `timezone`, `earliest_time` and `latest_time`.
|
2020-03-23 16:38:43 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"username": "jean",
|
|
|
|
"email": "jean@example.com",
|
|
|
|
"timezone": "Europe/Brussels",
|
|
|
|
"earliest_time":"09:30 AM",
|
|
|
|
"latest_time":"10:00 PM"
|
|
|
|
}
|
|
|
|
```
|