import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {environment} from "../../../../../environments/environment";
import {Observable} from "rxjs";


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


    constructor(private http: HttpClient) {
    }

    url = `${environment.HOST}/`;
    endpoint: string = 'Caja';


    saveObject(obj): Observable<any> {
        return this.http.post(this.url + this.endpoint + '/guardarCaja', obj);
    }

    getAll(): Observable<any> {
        return this.http.get(this.url + this.endpoint + '/listarCaja');
    }

    getById(key): Observable<any> {
        return this.http.get(this.url + this.endpoint + '/buscarPorIdCaja/' + key);
    }




    deleteObject(key): Observable<any> {
        return this.http.delete(this.url + this.endpoint + '/eliminarCaja/' + key);
    }


    getByIdUser(key): Observable<any> {
        return this.http.get(this.url + this.endpoint + '/buscarCajaPorIdUser/' + key);
    }
}
