import { IPosInfoRawResponse, IPosInfoResponse } from '@/domains/pos/models/pos.io';
import { IPosProfileRawResponse, IPosProfileResponse } from '@/domains/pos/models/profile.io';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { POS_GOOD_FAVORITE_API_ROUTES } from '../constants';

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

  private apiRoutes = POS_GOOD_FAVORITE_API_ROUTES;

  attach(good_id: string): Observable<IPosProfileResponse> {
    return this.http.post<IPosProfileRawResponse>(this.apiRoutes.favorite(good_id), {});
  }

  detach(good_id: string): Observable<IPosInfoResponse> {
    return this.http.delete<IPosInfoRawResponse>(this.apiRoutes.favorite(good_id));
  }
}
