import type { IRecoveryPasswordForm, IProfileData, IChangePasswordForm, ILoginForm, IPasswordForm, IRegistrateForm, IChangeEmail } from '../../types'; import { ApiHelper } from '../../runtime'; /** Сервис для работы с API авторизации */ export class AuthorizationApiService { static async recoveryPassword(data: IRecoveryPasswordForm): Promise { return await ApiHelper.fetch('/authorization/recovery-password', { method: 'POST', headers: { 'X-Cache-Time': 259200, 'Content-Type': 'application/json', }, body: data, }, useRuntimeConfig(), ); } static async changePassword(data: IChangePasswordForm): Promise { return await ApiHelper.fetch('/authorization/change-password', { method: 'POST', headers: { 'X-Cache-Time': 259200, 'Content-Type': 'application/json', }, body: data, }, useRuntimeConfig(), ); } static async changeEmail(data: IChangeEmail): Promise { return await ApiHelper.fetch('/authorization/change-email', { method: 'POST', headers: { 'X-Cache-Time': 259200, 'Content-Type': 'application/json', }, body: data, }, useRuntimeConfig(), ); } static async postProfile(data: FormData): Promise { return await ApiHelper.fetch('/authorization/post-profile', { method: 'POST', headers: { 'X-Cache-Time': 259200, }, body: data, }, useRuntimeConfig(), ); } static async getProfile(): Promise { return await ApiHelper.fetch( '/authorization/get-profile', { method: 'GET', headers: { 'X-Cache-Time': 259200, 'Content-Type': 'application/json', }, }, useRuntimeConfig(), ); } static async password( data: IPasswordForm, ): Promise { return await ApiHelper.fetch( '/authorization/password', { method: 'POST', headers: { 'X-Cache-Time': 259200, 'Content-Type': 'application/json', }, body: data, }, useRuntimeConfig(), ); } static async deleteProfile(): Promise { return await ApiHelper.fetch( '/authorization/delete-profile', { method: 'DELETE', headers: { 'X-Cache-Time': 259200, 'Content-Type': 'application/json', }, }, useRuntimeConfig(), ); } static async deleteAvatar(): Promise { return await ApiHelper.fetch( '/authorization/profile-avatar', { method: 'DELETE', headers: { 'X-Cache-Time': 259200, 'Content-Type': 'application/json', }, }, useRuntimeConfig(), ); } static async login( data: ILoginForm, ): Promise { return await ApiHelper.fetch( '/authorization/login', { method: 'POST', headers: { 'X-Cache-Time': 259200, 'Content-Type': 'application/json', }, body: data, }, useRuntimeConfig(), ); } static async register( data: IRegistrateForm, ): Promise { return await ApiHelper.fetch( '/authorization/register', { method: 'POST', headers: { 'X-Cache-Time': 259200, 'Content-Type': 'application/json', }, body: data }, useRuntimeConfig(), ); } static async confirmRegistration(token: string): Promise { return await ApiHelper.fetch( '/authorization/confirm', { method: 'GET', headers: { 'X-Cache-Time': 259200, 'X-Domain': useRuntimeConfig()?.public?.xDomain, 'Content-Type': 'application/json', }, params: { token, } }, useRuntimeConfig(), ); } }