34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { HttpClient, HttpParams } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { Observable } from 'rxjs/internal/Observable';
|
|
import { catchError } from 'rxjs/operators';
|
|
|
|
import { ErrorLoggerService } from '../core/error-logger.service';
|
|
|
|
import { BillSettlementReport } from './bill-settlement-report';
|
|
|
|
const url = '/api/bill-settlement-report';
|
|
const serviceName = 'BillSettlementReportService';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class BillSettlementReportService {
|
|
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
|
|
|
get(startDate: string | null, finishDate: string | null): Observable<BillSettlementReport> {
|
|
const options = { params: new HttpParams() };
|
|
if (startDate !== null) {
|
|
options.params = options.params.set('s', startDate);
|
|
}
|
|
if (finishDate !== null) {
|
|
options.params = options.params.set('f', finishDate);
|
|
}
|
|
return <Observable<BillSettlementReport>>(
|
|
this.http
|
|
.get<BillSettlementReport>(url, options)
|
|
.pipe(catchError(this.log.handleError(serviceName, 'get')))
|
|
);
|
|
}
|
|
}
|