import { IPaginatedResponse } from '@/core/models/service.model';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { DEVICE_BRANDS_API_ROUTES } from '../constants';
import { IDeviceBrandRawResponse, IDeviceBrandRequest, IDeviceBrandResponse } from '../models';

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

  private apiRoutes = DEVICE_BRANDS_API_ROUTES;

  getAll(): Observable<IPaginatedResponse<IDeviceBrandResponse>> {
    return this.http.get<IPaginatedResponse<IDeviceBrandRawResponse>>(this.apiRoutes.list());
  }
  // getSingle(userId: string): Observable<IDeviceBrandResponse> {
  //   return this.http.get<IDeviceBrandRawResponse>(this.apiRoutes.single(userId));
  // }

  create(userData: IDeviceBrandRequest): Observable<IDeviceBrandResponse> {
    return this.http.post<IDeviceBrandResponse>(this.apiRoutes.list(), userData);
  }

  update(userId: string, userData: IDeviceBrandRequest): Observable<IDeviceBrandResponse> {
    return this.http.patch<IDeviceBrandResponse>(this.apiRoutes.single(userId), userData);
  }
}
