import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { FleioApiService } from '../fleio-api.service';
import { ConfigService } from '../../config/config.service';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class YearlyRevenueReportService extends FleioApiService<any> {
  constructor(protected httpClient: HttpClient, protected config: ConfigService) {
    super();
    this.setEndpoint(config.getPanelApiUrl('reports/yearly-revenue'));
  }

  getYearlyRevenueReport(forYear?: string): Observable<any> {
    if (!forYear) {
      return this.getAction('get_yearly_revenue');
    }
    return this.getAction('get_yearly_revenue', {
      for_year: forYear,
    });
  }
}
