import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

import { environment } from '../../environments/environment';
import { AbstractService } from './abstract.service';

@Injectable({
    providedIn: 'root',
})
export class TurnoverService {

    constructor(private http: HttpClient, private abstractService: AbstractService) {
    }

    fetch(limit: number, offset: number, sort: string, descending: boolean, filter: any | undefined) {
        return this.abstractService.fetch("/turnovers", limit, offset, sort, descending, filter);
    }

    overview(limit: number, offset: number, sort: string, descending: boolean, filter: any | undefined) {
        return this.abstractService.fetch("/turnovers/overview", limit, offset, sort, descending, filter);
    }

    get(id: number) {
        return this.http.get(environment.apiUrl + "/turnovers/" + id);
    }

    create(turnover: any) {
        return this.http.post(environment.apiUrl + "/turnovers", turnover);
    }

    update(turnover: any) {
        return this.http.patch(environment.apiUrl + "/turnovers", turnover);
    }
}