import {APIService} from './api-service';

export type AuthorizationStatus = 'not-initialized' | 'not-logged' | 'logged';

export class AuthorizationService {
  constructor(private apiService: APIService) {}

  async checkStatus(): Promise<AuthorizationStatus> {
    return this.apiService.post('/api/authorization/check-status');
  }

  async initialize(password: string): Promise<void> {
    await this.apiService.post('/api/authorization/initialize', {
      password,
    });
  }

  async login(password: string): Promise<void> {
    await this.apiService.post('/api/authorization/login', {
      password,
    });
  }

  async logout(): Promise<void> {
    await this.apiService.post('/api/authorization/logout');
  }
}
