import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { CONSUMER_PROFILE_API_ROUTES } from '../constants';
import { IProfileRequestPayload, IProfileResponse, IResetPasswordRequest } from '../models';

@Injectable({ providedIn: 'root' })
export class ProfileService {
  constructor(private readonly http: HttpClient) {}

  getInfo(): Observable<IProfileResponse> {
    return this.http.get<IProfileResponse>(CONSUMER_PROFILE_API_ROUTES.info());
  }

  updateProfile(payload: IProfileRequestPayload): Observable<IProfileResponse> {
    return this.http.patch<IProfileResponse>(CONSUMER_PROFILE_API_ROUTES.updateInfo(), payload);
  }

  resetPassword(payload: IResetPasswordRequest): Observable<unknown> {
    return this.http.put(CONSUMER_PROFILE_API_ROUTES.resetPassword(), payload);
  }
}
