import { IPaginatedResponse } from '@/core/models/service.model';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { CONSUMER_POSES_API_ROUTES } from '../constants';
import { IPosRawResponse, IPosRequest, IPosResponse } from '../models';

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

  private apiRoutes = CONSUMER_POSES_API_ROUTES;

  getAll(): Observable<IPaginatedResponse<IPosResponse>> {
    return this.http.get<IPaginatedResponse<IPosRawResponse>>(this.apiRoutes.list());
  }
  getSingle(posId: string): Observable<IPosResponse> {
    return this.http.get<IPosRawResponse>(this.apiRoutes.single(posId));
  }

  update(posId: string, data: IPosRequest): Observable<IPosResponse> {
    return this.http.patch<IPosRawResponse>(this.apiRoutes.single(posId), data);
  }
}
