UNPKG

@netgrif/components-core

Version:

Netgrif Application engine frontend core Angular library

57 lines (56 loc) 3.09 kB
import { HttpClient, HttpEvent, HttpHeaders, HttpParams, HttpProgressEvent, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import { MessageResource } from './interface/message-resource'; import * as i0 from "@angular/core"; export type Headers = HttpHeaders | { [header: string]: string | Array<string>; }; export type Params = HttpParams | ObjectParams; export type ResponseType = 'json' | 'hal'; export interface ObjectParams { [param: string]: string | Array<string>; } export declare enum ProgressType { UPLOAD = "upload", DOWNLOAD = "download" } export interface ProviderProgress { type: ProgressType; loaded: number; total?: number; progress?: number; } export declare abstract class AbstractResourceProvider { protected httpClient: HttpClient; protected constructor(httpClient: HttpClient); private static addLastSlash; private static removeFirstSlash; static sanitizeUrl(endpoint?: string, url?: string): string; /** * Combines two instances of {@link Params} type into one. * If a parameter is declared in both instances uses the value of the `highPriorityParams` in the result. * @param highPriorityParams parameters with the higher priority * @param lowPriorityParams parameters with the lower priority * @returns combination of botch parameters. Uses the value of the higher priority parameters if the keys are in conflict. */ static combineParams(highPriorityParams: Params, lowPriorityParams: Params): HttpParams; /** * Converts {@link HttpParams} instance into a simple object. * @param params instance to convert * @returns simple object with keys and values from the input argument */ static convertHttpParamsToObjectParams(params: HttpParams): ObjectParams; static getProgress(event: HttpProgressEvent): ProviderProgress; static processMessageResource(response: MessageResource | HttpResponse<MessageResource>): MessageResource; get$<T>(endpoint?: string, url?: string, params?: Params, headers?: Headers, responseType?: ResponseType): Observable<T>; getBlob$(endpoint?: string, url?: string, params?: Params, headers?: Headers): Observable<HttpEvent<Blob>>; post$<T>(endpoint?: string, url?: string, body?: object, params?: Params, headers?: Headers, responseType?: ResponseType): Observable<T>; postWithEvent$<T>(endpoint?: string, url?: string, body?: object, params?: Params, headers?: Headers, responseType?: ResponseType): Observable<HttpEvent<T>>; put$<T>(endpoint?: string, url?: string, body?: object, params?: Params, headers?: Headers, responseType?: ResponseType): Observable<T>; delete$<T>(endpoint?: string, url?: string, params?: Params, headers?: Headers, responseType?: ResponseType, body?: object): Observable<T>; } export declare class ResourceProvider extends AbstractResourceProvider { constructor(httpClient: HttpClient); static ɵfac: i0.ɵɵFactoryDeclaration<ResourceProvider, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ResourceProvider>; }