import { IListingResponse } from '@/core/models/service.model';
import ISummary from '@/core/models/summary';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { CATALOG_API_ROUTES } from './apiRoutes';

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

  private apiRoutes = CATALOG_API_ROUTES;

  getGuilds(): Observable<IListingResponse<ISummary>> {
    return this.http.get<IListingResponse<ISummary>>(this.apiRoutes.guilds());
  }

  getGuildGoodCategories(guildId: string): Observable<IListingResponse<ISummary>> {
    return this.http.get<IListingResponse<ISummary>>(this.apiRoutes.guildGoodCategories(guildId));
  }

  getSKU(search?: string): Observable<IListingResponse<ISummary>> {
    return this.http.get<IListingResponse<ISummary>>(this.apiRoutes.sku(), {
      params: {
        search: search || '',
      },
    });
  }

  getMeasureUnits(): Observable<IListingResponse<ISummary>> {
    return this.http.get<IListingResponse<ISummary>>(this.apiRoutes.measureUnits());
  }

  getProviders(): Observable<IListingResponse<ISummary>> {
    return this.http.get<IListingResponse<ISummary>>(this.apiRoutes.providers());
  }

  getDevices(): Observable<IListingResponse<ISummary>> {
    return this.http.get<IListingResponse<ISummary>>(this.apiRoutes.devices());
  }

  getDeviceBrands(): Observable<IListingResponse<ISummary>> {
    return this.http.get<IListingResponse<ISummary>>(this.apiRoutes.deviceBrands());
  }
}
