Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.
Olexander edited this page Aug 30, 2023 · 16 revisions

Navigation

Endpoints


Patch /v2/users/:userId/verifyStudent

Authorization

Bearer <Bot Token>

Request options

{
  params: {
    userId: string,
  },
  body: {
    state: 'APPROVED' | 'PENDING' | 'DECLINED', 
    isCaptain: boolean,
  },
}

Response body

{
  firstName: string,
  middleName: string,
  lastName: string,
  user: {
    id: string,
    username: string,
    email: string,
    telegramId: number,
    avatar: string,
    state: 'APPROVED' | 'PENDING' | 'DECLINED',
  },
  group: string,
  roles: {
    role: 'CAPTAIN' | 'MODERATOR' | 'STUDENT',
  },
  state: 'APPROVED' | 'PENDING' | 'DECLINED',
}

Expected exceptions

400 InvalidEntityIdException: 'user with such id is not found'

400 InvalidBodyException: 'State is not an enum'
400 InvalidBodyException: 'isCaptain must be a boolean'

Patch /v2/users/:userId/verifySuperhero

Authorization

Bearer <Bot Token>

Request options

{
  params: {
    userId: string,
  },
  body: {
    state: 'APPROVED' | 'PENDING' | 'DECLINED',
  },
}

Response body

{
  userId: string, 
  dorm: boolean
}

Expected exceptions

400 InvalidEntityIdException: 'user with such id is not found'

400 InvalidBodyException: 'State is not an enum'

POST /v2/users/:userId/superhero

Authorization

Bearer <JWT AccessToken>

Request options

{
  params: {
    userId: string,
  },
  body: {
    dorm: boolean,
  },
}

Response body

Expected exceptions

403 NoPermissionException 'You do not have permission to perform this action'

400 InvalidEntityIdException: 'user with such id is not found'

400 InvalidBodyException: 'Dorm is not a number'

Post /v2/users/:userId/roles

Authorization

Request options

{
  params: {
    userId: string,
  },
  body: {
    roleId: string,
  },
}

Response body

Expected exceptions

400 InvalidEntityIdException: 'user with such id is not found'

400 InvalidBodyException: 'Role id can not be empty'

DELETE /v2/users/:userId/roles/:roleId

Authorization

Request options

{
  params: {
    userId: string,
    roleId: string,
  },
}

Response body

Expected exceptions

400 InvalidEntityIdException: 'user with such id is not found'

DELETE /v2/users/:userId

Authorization

Bearer <JWT AccessToken>

Request options

{
  params: {
    userId: string,
  },
}

Response body

Expected exceptions

403 NoPermissionException 'You do not have permission to perform this action'

400 InvalidEntityIdException: 'user with such id is not found'

PATCH /v2/users/:userId

Authorization

Bearer <JWT AccessToken>

Request options

{
  params: {
    userId: string,
  },
  body: {
    username?: string;
    state?: State;
    avatar?: string;
    email?: string;
  },
}

Response body

Expected exceptions

403 NoPermissionException 'You do not have permission to perform this action'

400 InvalidEntityIdException: 'user with such id is not found'

400 InvalidBodyException: 'Username is too short (min: 2)'
400 InvalidBodyException: 'Username is too long (max: 40)'
400 InvalidBodyException: 'Username is not correct (a-zA-Z0-9_)'
400 InvalidBodyException: 'State is not an enum'
400 InvalidBodyException: 'Avatar link is too long (max: 400)'
400 InvalidBodyException: 'Email is not an email'

GET /v2/users/:userId/contacts

Authorization

Bearer <JWT AccessToken>

Request options

{
  params: {
    userId: string,
  },
}

Response body

{
  contacts: {
    id: string,
    link: string,  
    name: string, 
    displayName: string
  }[],
} 

Expected exceptions

403 NoPermissionException 'You do not have permission to perform this action'

400 InvalidEntityIdException: 'user with such id is not found'

POST /v2/users/:userId/contacts

Authorization

Bearer <JWT AccessToken>

Request options

{
  params: {
    userId: string,
  },
  body: {
    name: string,
    value: string,
  },
}

Response body

{
  id: string,     
  name: string,
  value: string,
} 

Expected exceptions

403 NoPermissionException 'You do not have permission to perform this action'

400 InvalidEntityIdException: 'user with such id is not found'

400 InvalidBodyException: 'Name is too long (max: 100)'
400 InvalidBodyException: 'Name can not be empty'
400 InvalidBodyException: 'Name is not correct (a-zA-Z0-9A-Я(укр.)\\-\' )'
400 InvalidBodyException: 'Display name is too long (max: 100)'
400 InvalidBodyException: 'Display name can not be empty'
400 InvalidBodyException: 'Display name contains wrong symbols (ASCII only)'
400 InvalidBodyException: 'Link is too long (max: 200)'
400 InvalidBodyException: 'Link can not be empty'
400 InvalidBodyException: 'Link contains wrong symbols (ASCII only)'

PATCH /v2/users/:userId/contacts/:name

Authorization

Bearer <JWT AccessToken>

Request options

{
  params: {
    userId: string,
    name: string,
  },
  body: {
    name?: string;
    value?: string;
  },
}

Response body

{
  id: string, 
  link: string, 
  name: string, 
  displayName: string,
}

Expected exceptions

403 NoPermissionException 'You do not have permission to perform this action'

400 InvalidEntityIdException: 'user with such id is not found'

400 InvalidContactNameException: 'Contact with such name is not found'

400 InvalidBodyException: 'Display name is too long (max: 100)'
400 InvalidBodyException: 'Display name contains wrong symbols (ASCII only)'
400 InvalidBodyException: 'Link is too long (max: 200)'
400 InvalidBodyException: 'Link contains wrong symbols (ASCII only)'

DELETE /v2/users/:userId/contacts/:name

Authorization

Bearer <JWT AccessToken>

Request options

{
  params: {
    userId: string,
    name: string,
  },
}

Response body

Expected exceptions

403 NoPermissionException 'You do not have permission to perform this action'

400 InvalidEntityIdException: 'user with such id is not found'

400 InvalidContactNameException: 'Contact with such name is not found'

DELETE /v2/users/:userId/student

Authorization

Bearer <JWT AccessToken>

Request options

{
  params: {
    userId: string,
  },
}

Response body

Expected exceptions

403 NoPermissionException 'You do not have permission to perform this action'

400 InvalidEntityIdException: 'user with such id is not found'

PATCH /v2/users/:userId/student

Authorization

Bearer <JWT AccessToken>

Request options

{
  params: {
    userId: string,
  },
  body: {
    firstName?: string,
    lastName?: string,
    middleName?: string,
    groupId?: string,
    state?: 'APPROVED' | 'PENDING' | 'DECLINED',
  },
}

Response body

{
  firstName: string,
  middleName: string,
  lastName: string,
  user: {
    id: string,
    username: string,
    email: string,
    telegramId: number,
    avatar: string,
    state: 'APPROVED' | 'PENDING' | 'DECLINED',
  },
  group: string,
  roles: {
    role: 'CAPTAIN' | 'MODERATOR' | 'STUDENT',
  },
  state: 'APPROVED' | 'PENDING' | 'DECLINED',
}

Expected exceptions

403 NoPermissionException 'You do not have permission to perform this action'

400 InvalidEntityIdException: 'user with such id is not found'

400 InvalidBodyException: 'First name is not correct (A-Я(укр.)\\-\' )'
400 InvalidBodyException: 'First name is too short (min 2)'
400 InvalidBodyException: 'First name is too long (max 40)'

400 InvalidBodyException: 'Last name is not correct (A-Я(укр.)\\-\' )'
400 InvalidBodyException: 'Last name is too short (min 2)'
400 InvalidBodyException: 'Last name is too long (max 40)'

400 InvalidBodyException: 'Middle name is not correct (A-Я(укр.)\\-\' )'
400 InvalidBodyException: 'Middle name is too short (min 2)'
400 InvalidBodyException: 'Middle name is too long (max 40)'

400 InvalidBodyException: 'State is not an enum'

GET /v2/users/:userId/telegram

Authorization

Bearer <Bot Token>

Request options

{
  params: {
    userId: string,
  },
}

Response body

{
  id: string, 
  telegramId: number,         
  username: string, 
  email: string, 
  firstName: string, 
  lastName: string, 
  middleName: string, 
  avatar: string,  
  group: {
    id: string, 
    code: string
  },
}

Expected exceptions

400 InvalidEntityIdException: 'user with such id is not found'

POST /v2/users/:userId/telegram

Authorization

Bearer <JWT AccessToken>

Request options

{
  params: {
    userId: string,
  },
  body: {
    auth_date: number,
    first_name: string,
    hash: string,
    id: number,
    last_name: string,
    photo_url: string,
    username: string,
  },
}

Response body

Expected exceptions

403 NoPermissionException 'You do not have permission to perform this action'

400 InvalidEntityIdException: 'user with such id is not found'

400 InvalidBodyException: 'first_name can not be empty'
400 InvalidBodyException: 'hash can not be empty'
400 InvalidBodyException: 'photo_url can not be empty'
400 InvalidBodyException: 'username can not be empty'

GET /v2/users/:userId

Authorization

Bearer <JWT AccessToken>

Request options

{
  params: {
    userId: string,
  },
}

Response body

{     
  id: string, 
  telegramId: number,         
  username: string, 
  email: string, 
  firstName: string, 
  lastName: string, 
  middleName: string, 
  avatar: string,  
  group: {
    id: string, 
    code: string
  },                   
}

Expected exceptions

403 NoPermissionException 'You do not have permission to perform this action'

400 InvalidEntityIdException: 'user with such id is not found'