UNPKG

ng-ptplibraries

Version:

56 lines (55 loc) 2.28 kB
import { Observable } from 'rxjs'; import { HttpClient, HttpErrorResponse } from '@angular/common/http'; import { CookieService } from 'ngx-cookie'; import { JwtHelperService } from '@auth0/angular-jwt'; import { Configs } from '../interfaces/IConfig'; import { Router } from '@angular/router'; import { Location } from '@angular/common'; export declare class ServiceBase { private config; http: HttpClient; cookieService?: CookieService; router?: Router; jwtHelperService?: JwtHelperService; location?: Location; protected BASE_API: string; constructor(config: Configs, http: HttpClient, cookieService?: CookieService, router?: Router, jwtHelperService?: JwtHelperService, location?: Location); /** * Generates a GET request and returns it by the generic class injected. */ protected Get<T>(api: string, param?: any, headers?: any): Observable<T>; protected ExternalGet<T>(api: string, param?: any, headers?: any): Observable<T>; /** * Generates a POST request by the generic class injected. */ protected Post<T>(api: string, data: any, param?: any, headers?: any): Observable<T>; /** * Generates a PUT request by the generic class injected. */ protected Put<T>(api: string, data: any, param?: any, headers?: any): Observable<T>; /** * Generates a DELETE request by the generic class injected. */ protected Delete<T>(api: string, param?: any, headers?: any): Observable<T>; /** * Generates a secured GET request by adding the token to the header */ protected SecuredGet<T>(api: string, param?: any, headers?: any): Observable<T>; /** * Generates a secured POST request by adding the token to the header */ protected SecuredPost<T>(api: string, data: any, param?: any, headers?: any): Observable<T>; /** * Generates a secured PUT request by adding the token to the header */ protected SecuredPut<T>(api: string, data: any, param?: any, headers?: any): Observable<T>; protected handleError(error: HttpErrorResponse): Observable<never>; /** * Set content type of header to json */ private GetJSONAsHeader; /** * Adds the token from cookie to header */ private GetTokenAsHeader; }