import { HttpClient, HttpErrorResponse, HttpEvent, HttpHeaders } from '@angular/common/http'; import { BehaviorSubject, Observable } from 'rxjs'; export declare class GenericService { endpoint?: string; /** * Http client */ http: HttpClient; /** * List of entities */ list: BehaviorSubject; /** * Constructor * * @param http */ constructor(endpoint?: string); /** * Gets a single entity * * @param id The id of the entity or relative path * @param params Adds query params to the request * @param headers Adds headers to the request */ get(id: string | number, params?: Object, headers?: Object, handleError?: boolean): Observable; /** * Counts entities * * @param params Adds query params to the request * @param path A relative path to the action * @param headers Adds headers to the request * @param handleError Handle errors */ count(params?: Object, path?: string, headers?: Object, handleError?: boolean): Observable; /** * Gets a list of entities * * @param params Adds query params to the request * @param headers Adds headers to the request * @param path A relative path to the action */ getList(params?: Object, path?: string, headers?: Object): Observable; /** * Loads data * @param params Adds query params to the request * @param path A relative path to the action * @param headers Adds headers to the request */ loadList(params?: Object, path?: string, headers?: Object): void; /** * Gets result list as Observable */ getListAsObservable(): Observable; /** * Creates an entity * * @param entity The entity to create * @param path A relative path to the action * @param httpOptions Additional http options, like headers and so on * @param handleError Handle errors */ create(entity: any, path?: string, httpOptions?: Object, handleError?: boolean): Observable; /** * Updates an entity * * @param entity The entity to update * @param path A relative path to the action * @param httpOptions Additional http options, like headers and so on * @param handleError Handle errors */ update(id: string | number, entity: any, path?: string, httpOptions?: Object, handleError?: boolean): Observable; /** * Patches an entity * * @param id id The id of the item to patch * @param body The body * @param path A relative path to the action * @param httpOptions Additional http options, like headers and so on * @param handleError Handle errors */ patch(id: string | number, body: any, path?: string, httpOptions?: Object, handleError?: boolean): Observable; /** * Patches multiple entities * * @param ids The ids of the items to patch * @param body The body * @param path A relative path to the action * @param httpOptions Additional http options, like headers and so on * @param handleError Handle errors */ patchList(ids: string[] | number[], body: any, path?: string, httpOptions?: Object, handleError?: boolean): Observable; /** * Deletes an entity. * * @param id The id of the item to delete * @param path A relative path to the action * @param httpOptions Additional http options, like headers and so on * @param handleError Handle errors */ delete(id: string | number, path?: string, httpOptions?: Object, handleError?: boolean): Observable; /** * Deletes multiple entities. * * @param ids The ids of the items to delete * @param path A relative path to the action * @param httpOptions Additional http options, like headers and so on * @param handleError Handle errors */ deleteList(ids: string[] | number[], path?: string, httpOptions?: Object, handleError?: boolean): Observable; /** * Downloads a file * * @param path A relative path to the action * @param params Some query params */ download(path: string, params?: Object, handleError?: boolean): Observable; /** * Duplicates a record * @param id */ duplicate(id: number): Observable; /** * Uploads a file * * @param file The file to upload * @param path A relative path to the action */ upload(file: File, path?: string, extraData?: object): Observable; /** * Convert Object to FromData * * @param body */ protected toFormData(body: Object): FormData; /** * Convert Object to HttpHeaders * * @param body */ protected toHttpHeaders(body: Object): HttpHeaders; /** * Gets file name from Httpheaders: Content-Disposition * @param disposition */ protected getFileNameFromHeaders(headers: HttpHeaders): string; /** * Returns a function that handles Http operation failures. * This error handler lets the app continue to run as if no error occurred. * @param operation - name of the operation that failed */ protected handleError(operation?: string): (error: HttpErrorResponse) => Observable; /** * Return distinct message for sent, upload progress, & response events * * @param event The response event * @param file The file beeing uploaded */ protected getEventMessage(event: HttpEvent, file: File): string; /** * Shows upload progress. * * @param message */ protected showProgress(message: string): void; }