import { IPaginatedResponse } from '@/core/models/service.model';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { DEVICES_API_ROUTES } from '../constants';
import { IDeviceRawResponse, IDeviceRequest, IDeviceResponse } from '../models';

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

  private apiRoutes = DEVICES_API_ROUTES;

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

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

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