moh-common-lib
Version:
A library of Angular components, services, and styles for B.C. Government Ministry of Health (MoH).
37 lines (36 loc) • 1.81 kB
TypeScript
import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { CommonImage } from '../models/images.model';
/**
* Abstract class for HTTP Service
*/
export declare abstract class AbstractHttpService {
protected http: HttpClient;
protected logHTTPRequestsToConsole: boolean;
constructor(http: HttpClient);
/** The headers to send along with every GET and POST. */
protected abstract _headers: HttpHeaders;
/**
* Makes a GET request to the specified URL, using headers and HTTP options specified in their respective methods.
* @param url Target URL to make the GET request
*/
protected get<T>(url: any, queryParams?: HttpParams): Observable<T>;
protected post<T>(url: any, body: any): Observable<T>;
protected setupRequest<T>(observable: Observable<any>): Observable<T>;
/** The HttpOptions object that Angular takes for GET and POST requests. Used in every HTTP request from this service. */
protected readonly httpOptions: {
headers: HttpHeaders;
params?: HttpParams;
};
/** Handles all failed requests that throw either a server error (400/500) or a client error (e.g. lost internet). */
protected abstract handleError(error: HttpErrorResponse): any;
protected generateUUID(): string;
/**
* Uploads an individual attachment. All you need to do is set the url.
* Note: urls often include UUIDs, so this must be an application decision.
*
* @param relativeUrl URL to hit, must include UUIDs of application and CommonImage
* @param attachment CommonImage to upload
*/
protected uploadAttachment(relativeUrl: string, attachment: CommonImage): Observable<string>;
}