/
Muip
/
ProBody
Обзор
Документация
Войти
/
Muip
/
ProBody
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
api/user/User.ts
35 строк
1 KB
chmerev
new
14 авг 2024, 12:02
14 авг 2024, 12:02
595f266
Код
Авторство
О чём код?
/* eslint-disable no-unused-vars */ import ApiClient from '../ApiClient'; import { NiceResponse } from '../dto/NiceResponse'; import UserAuthRequest from './dto/UserAuthRequest.dto'; import { UserAuthResponse } from './dto/UserAuthResponse.dto'; import { UserForgotRequest } from './dto/UserForgotRequest.dto'; import { UserMeResponse } from './dto/UserMeResponse.dto'; import UserRegistrRequest from './dto/UserRegistrRequest.dto'; import { UserRegistrResponse } from './dto/UserRegistrResponse.dto'; export class UserApi { constructor(private api: ApiClient) { } path = '/authorization'; async login(req: UserAuthRequest) { const login = await this.api.client.post<NiceResponse<UserAuthResponse>>(this.path + '/login', { ...req }); return login.data; } async forgotPassword(req: UserForgotRequest) { const restore = await this.api.client.put<NiceResponse<null>>(this.path + '/forgot-password', { ...req }); return restore.data; } async registration(req: UserRegistrRequest) { const restore = await this.api.client.post<NiceResponse<UserRegistrResponse>>(this.path + '/register', { ...req }); return restore.data; } async me() { const reg = await this.api.client.get<NiceResponse<UserMeResponse>>(this.path + '/me?fields={id,email,firstName,lastName}'); return reg.data; } }