import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { POS_STATISTICS_API_ROUTES } from '../constants';
import { IPosStatisticsRawResponse, IPosStatisticsResponse } from '../models';

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

  private apiRoutes = POS_STATISTICS_API_ROUTES;

  getAll(fromDate?: Date): Observable<IPosStatisticsResponse> {
    return this.http.get<IPosStatisticsRawResponse>(this.apiRoutes.getAll(), {
      params: { from_date: fromDate?.toISOString() || '' },
    });
  }
}
