-
Notifications
You must be signed in to change notification settings - Fork 1
API v1
Get information about the account, bound to the token provided.
| Method | Address |
|---|---|
| GET | /api/v1/accounts/<token> |
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | true | Authorization token of the account |
Response:
{
"result": {
"firstName": null,
"lastName": null,
"patronymic": null,
"role": "ghost",
"studyGroup": null,
"tgId": null,
"username": "max",
"id": "575b3581aa87dd1cd0e137ab",
"email": "max@innopolis.ru"
},
"status": "ok"
}
Create new account.
| Method | Address |
|---|---|
| POST | /api/v1/accounts/ |
| Parameter | Type | Required | Description |
|---|---|---|---|
| username | string | true | Account username. Consists of [3, 16] alphanumeric characters(English alphabet + digits) + underscore('_') - case insensitive |
| password | string | true | Account password. Consists of [8, 64] characters |
| firstName | string | true | Person's first name. Consists [1, 35] characters from the following set: letters, ' ', '-' |
| lastName | string | true | Person's last name. Consists [1, 35] characters from the following set: letters, ' ', '-' |
| string | true | Person's corporate email. Consists of [7, 255] characters | |
| studyGroup | string | false | Person's study group(if present). [3, 10] characters from the following set: letters, '#', '-' |
Response:
{
"result": {
"id": "575b3581aa87dd1cd0e137ab",
"token": "cQY85mgmSxZl9G3t1B5ZpbsmWWj0bMxb",
"username": "max",
"firstName": null,
"lastName": null,
"role": "ghost"
},
"status": "ok"
}
Check whether the account with the username OR id given exists. username and id parameters are mutually exclusive!
| Method | Address |
|---|---|
| GET | /api/v1/accounts/<token>/exists |
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | true | Authorized user account token |
| id | string | false | id to check for |
| username | string | false | username to check for |
Response:
{
"result": true,
"status": "ok"
}
Set new role of the account with accountId to newRole. Only accessible to users with role moderator.
| Method | Address |
|---|---|
| PUT | /api/v1/accounts/<token>/updateRole |
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | true | Moderator account token |
| accountId | string | true | Id of an account to be updated with new role |
| newRole | string | true | New role to provide the account with. Can only be ghost or student |
Response:
{
"status": "ok"
}
List accounts of ghost and student roles. Only accessible to users with role moderator.
| Method | Address |
|---|---|
| GET | /api/v1/accounts/<token>/listAccounts |
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | true | Authorization token of a moderator account |
Response:
{
"result": [
{
"firstName": null,
"id": "575b53fbaa87dd30d6963e5d",
"lastName": null,
"role": "ghost",
"username": "andr"
},
{
"firstName": null,
"id": "575b3581aa87dd1cd0e137ab",
"lastName": null,
"role": "student",
"username": "max"
}
],
"status": "ok"
}
Get information about user: firstName, lastName, studyGroup, id, username, role. username and id parameters are mutually exclusive! Only accessible to users with role moderator and student.
| Method | Address |
|---|---|
| GET | /api/v1/accounts/<token>/getBio |
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | false | id of an account |
| username | string | false | username of an account |
Response:
{
"result": {
"firstName": "Andrew",
"lastName": "Platz",
"studyGroup": "BS3#4"
"username": "somebody",
"id": "575b3581aa87dd1cd0e137ab",
"role": "student"
},
"status": "ok"
}
Get preferences of a user. Preferences are used to store json-packed custom themes of users.
| Method | Address |
|---|---|
| GET | /api/v1/accounts/<token>/getPreferences |
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | true | User token |
Response:
{
"result": {}, // - if no preferences set;
// otherwise there will be a json-object,
// previously set by updatePreferences method
"status": "ok"
}
Update preferences of a user. Preferences are used to store json-packed custom themes of users.
| Method | Address |
|---|---|
| PUT | /api/v1/accounts/<token>/updatePreferences |
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | true | User token |
| preferences | string | true | String representation of preferences object |
Response:
{
"status": "ok"
}
Authorize the user.
| Method | Address |
|---|---|
| POST | /api/v1/accounts/auth |
| Parameter | Type | Required | Description |
|---|---|---|---|
| username | string | true | Username of an account |
| password | string | true | Password of an account |
Response:
{
"result": {
"id": "575b3581aa87dd1cd0e137ab",
"token": "cQY85mgmSxZl9G3t1B5ZpbsmWWj0bMxb",
"firstName": null,
"lastName": null,
"role": "moderator",
"username": "max"
},
"status": "ok"
}