import { Injectable } from "@angular/core"; import { LegalService } from "../services/legalService"; import { Utility } from "./utility"; import { Legal } from "../../public-api"; /** * Exposes the User endpoint * */ @Injectable({ providedIn: 'root' }) export class LegalState { constructor(private legal: LegalService, private utility:Utility) { } // get(id:string, done:any, error:any) { // const self = this; // this.legal.getByID().subscribe({ // next(rslt) { // if (rslt) { // if(rslt.results.length === 1){ // done(rslt.results[0]); // } else { // done(); // } // } // }, error(e) { // error(e) // }, complete() { // } // }) // } getBySite(id: string, done:any, error:any) { const self = this; this.legal.getBySite(id).subscribe({ next(rslt) { if (rslt) { // self.utility.updateRslt(self.legals, rslt) done(rslt) } }, error(e) { error(e) }, complete() { } }) } post(legal: Legal,done:any, error:any) { const self = this; this.legal.post(legal).subscribe({ next(rslt) { if (rslt) { done(rslt) } }, error(e) { error(e) }, complete() { } }) } put(legal: Legal, done:any) { const self = this; this.legal.put(legal).subscribe({ next(rslt) { if (rslt) { done(rslt) } }, error(e) { }, complete() { } }) } delete(legal: Legal, done:any, error:any) { const self = this; this.legal.delete(legal).subscribe({ next(rslt) { if (rslt) { done(rslt) } }, error(e) { error(e) }, complete() { } }) } }