coersystem
Version:
Library for Angular projects
47 lines (46 loc) • 2.01 kB
TypeScript
import { HttpClient } from "@angular/common/http";
import { CoerAlert } from "./coer-alert/coer-alert.component";
import { IHttpRequest, IHttpResponse } from "coersystem/interfaces";
import { Subscription } from "rxjs";
/** Provides several methods for handling http requests */
export declare abstract class Service {
protected readonly alert: CoerAlert;
protected readonly http: HttpClient;
protected readonly HTTP_CODE: {
Ok: number;
Created: number;
NoContent: number;
BadRequest: number;
Unauthorize: number;
Forbidden: number;
NotFound: number;
NotAllowed: number;
NotAcceptable: number;
Conflict: number;
PayloadTooLarge: number;
InnerError: number;
};
private _GET$;
private _POST$;
private _PUT$;
private _PATCH$;
private _DELETE$;
/** Clear and release a subscription */
protected ReleaseSubscription(subscription: Subscription): void;
/** Generates a GET http request */
protected HTTP_GET<T>(request: IHttpRequest<T>, cancelPrevious?: boolean): Promise<IHttpResponse<T>>;
/** Generates a POST http request */
protected HTTP_POST<T>(request: IHttpRequest<T>, cancelPrevious?: boolean): Promise<IHttpResponse<T>>;
/** Generates a PUT http request */
protected HTTP_PUT<T>(request: IHttpRequest<T>, cancelPrevious?: boolean): Promise<IHttpResponse<void>>;
/** Generates a PATCH http request */
protected HTTP_PATCH<T>(request: IHttpRequest<T>, cancelPrevious?: boolean): Promise<IHttpResponse<void>>;
/** Generates a DELETE http request */
protected HTTP_DELETE<T>(request: IHttpRequest<T>, cancelPrevious?: boolean): Promise<IHttpResponse<void>>;
/** Download a csv file from browser */
protected DOWNLOAD_CSV(buffer: ArrayBuffer, fileName?: string): Blob;
/** Download a txt file from browser */
protected DOWNLOAD_TXT(buffer: ArrayBuffer, fileName?: string): Blob;
/** */
private AlertError;
}