import { AuthStore } from '../stores';
import { HttpService } from './httpService';
export class AccountService {
  constructor() { }
  static getInstance() {
    if (!AccountService.instance) {
      AccountService.instance = new AccountService();
    }
    return AccountService.instance;
  }
  async register(registerInput) {
    const headers = {
      'Content-Type': 'application/json',
    };
    AuthStore.state.loading = true;
    let result;
    try {
      result = await HttpService.http.post('api/Account/Register', registerInput, {
        headers: headers
      });
      if (result.Succeeded) {
        AuthStore.state.loading = false;
      }
    }
    catch (e) {
      AuthStore.state.loading = false;
      return e;
    }
    return result;
  }
  async forgotPassword(forgotPasswordInput) {
    AuthStore.state.loading = true;
    let result;
    try {
      result = await HttpService.http.post('api/Account/Forgot-Password', forgotPasswordInput);
      if (result.Succeeded) {
        AuthStore.state.loading = false;
      }
    }
    catch (e) {
      AuthStore.state.loading = false;
      return e;
    }
    return result;
  }
  async resetPassword(resetPasswordInput) {
    AuthStore.state.loading = true;
    let result;
    try {
      result = await HttpService.http.post('api/Account/reset-password', resetPasswordInput);
      if (result.Succeeded) {
        AuthStore.state.loading = false;
      }
    }
    catch (e) {
      AuthStore.state.loading = false;
      return e;
    }
    return result;
  }
}
