import { Injectable } from '@angular/core';
import { ApiService } from '../api.service';
import { Observable } from 'rxjs';
import {
  CHANGE_PASSWORD,
  CHANGE_PASSWORD_RESPONSE,
  FORGET_PASSWORD,
  FORGET_PASSWORD_RESPONSE,
  LOGIN,
  LOGIN_RESPONSE,
  OTP,
  OTP_RESPONSE,
} from '@core/models/authenticcation.model';

@Injectable({
  providedIn: 'root',
})
export class AuthService {
  constructor(private readonly apiService: ApiService) {}

  Login(data: LOGIN): Observable<LOGIN_RESPONSE> {
    return this.apiService.post<LOGIN, LOGIN_RESPONSE>('/login', data);
  }

  ForgetPassword(data: FORGET_PASSWORD): Observable<FORGET_PASSWORD_RESPONSE> {
    return this.apiService.post<FORGET_PASSWORD, FORGET_PASSWORD_RESPONSE>(
      '',
      data
    );
  }

  SendCode(data: OTP): Observable<OTP_RESPONSE> {
    return this.apiService.post<OTP, OTP_RESPONSE>('', data);
  }

  ChnagePassword(data: CHANGE_PASSWORD): Observable<CHANGE_PASSWORD_RESPONSE> {
    return this.apiService.post<CHANGE_PASSWORD, CHANGE_PASSWORD_RESPONSE>(
      '',
      data
    );
  }
}
