UNPKG

ngx-drupal8-rest

Version:

> A wrapper library to connect to a Drupal8+ based backend

55 lines (54 loc) 2.1 kB
import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { HttpOptions, LoginResponse } from '../models'; import * as i0 from "@angular/core"; export declare class BaseService { private httpClient; private platform; private static currentTokenRequest; constructor(httpClient: HttpClient, platform: string); getToken(): Observable<string>; /** * Check for current user if logged in or not. * Based on current connection and expiration date */ get isLoggedIn(): boolean; /** * Get current user login connection */ get connection(): LoginResponse; /** * Check if the current connection is expired */ protected get connectionExpired(): boolean; /** * save the user login connection in localstorage and constants singleton * @param data connection to be saved */ protected saveConnection(data: LoginResponse, token: string): void; /** * remove the current session details */ protected deleteConnection(): void; /** * Main method for implementing all the HttpClient requests and return the results * @param options Custom HttpOptions to be overrided * @param resource The resource url, Token frags will be replaced from options.frags, EX: {'/user/{uid}'} * @param body the content to be sent with the request, Only for patch and post methods */ protected request(options: HttpOptions, resource: string, body?: any): Observable<any>; /** * Get default HttpOptions or replace the custom ones. * Supports url params, responseType, headers, observer * @param options Custom httpOptions to override the defaults */ private httpOptions; /** * get full resource structure after adding the frags * @param resource drupal base resource url * @param frags frags to change it with the value that inside brackets */ private structureResource; static ɵfac: i0.ɵɵFactoryDeclaration<BaseService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<BaseService>; }