import { IPaginatedResponse } from '@/core/models/service.model';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { CONSUMER_BUSINESS_ACTIVITIES_API_ROUTES } from '../constants';
import {
  IBusinessActivityRawResponse,
  IBusinessActivityRequest,
  IBusinessActivityResponse,
} from '../models';

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

  private apiRoutes = CONSUMER_BUSINESS_ACTIVITIES_API_ROUTES;

  getAll(): Observable<IPaginatedResponse<IBusinessActivityResponse>> {
    return this.http.get<IPaginatedResponse<IBusinessActivityRawResponse>>(this.apiRoutes.list());
  }
  getSingle(businessId: string): Observable<IBusinessActivityResponse> {
    return this.http.get<IBusinessActivityRawResponse>(this.apiRoutes.single(businessId));
  }

  update(
    businessId: string,
    userData: IBusinessActivityRequest,
  ): Observable<IBusinessActivityResponse> {
    return this.http.patch<IBusinessActivityResponse>(this.apiRoutes.single(businessId), userData);
  }
}
