import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { SystemConnection } from '../models/system'; import * as i0 from "@angular/core"; /** * the main service is the basic http service of all other services "parent" that implements all the required request. * this service will add the headers automatically for each request it self */ export declare class MainService { protected httpClient: HttpClient; private platformId; /** * entity type of the current service, the main service dont have anything but the other services must use it * for example "node, comment, user, system" */ protected readonly entityType: string; /** * the main constractor of this service will inject the required services dynamically. * @param http basic http service * @param cookieService ngx-cookie service provider to save the cookies * @see https://angular.io/guide/dependency-injection * @see https://www.npmjs.com/package/ngx-cookie */ constructor(httpClient: HttpClient, platformId: Object); /** * structure a full entity for drupal request * @param entity the entity to be structured * @param ignoredFields fields to be ignored just like nid or uid or title * @param fieldLabels: the label for each field just like "{field_custom_field: 'value'}" * @param language language of the entity */ structureEntity(entity: any, ignoredFields: string[], fieldLabels?: any[], language?: string): any; /** * structure the field for drupal services request * @param value the field value * @param label field label name * @param language language of the field */ structureField(value: any, label?: string, language?: string): { [x: string]: any[]; }; /** * a getter to return the required headers for drupal * X-CSRF-Token - application token from services/session/connect * Content-Type - the type of the request content. * Accept - forcing drupal to return the response as a json object * @return object of the headers */ get options(): any; /** * getting token from drupal services module * @return http text token response */ protected getToken(): Observable; /** * Saving drupal session and token in cookies using ngx-cookie service * @param connection drupal connection */ protected saveSessionToken(connection: SystemConnection): void; /** * building up the full url path for each resource and / or params * @param resource the entity resource param. ex: system/'connect', user/'login' * @return full request path after adding the entity type and resource param */ protected fullRequestURL(resource?: string | number): string; /** * adding http request configs: request timeout, error handler * @param httpObservableRequest the http Observable to request * @return Observable of the request after adding required configs */ protected httpRequestWithConfig(httpObservableRequest: Observable): Observable; /** * basic http get request with headers. * @param resource the entity resource param. ex: system/'connect', user/'login' * @return http json response */ protected get(resource?: string | number): Observable; /** * basic http post request with headers. * @param resource the entity resource param. ex: system/'connect', user/'login' * @param body the contenct of the request * @return http json response */ protected post(body?: any, resource?: string | number): Observable; /** * basic http put request with headers. * @param resource the entity resource param. ex: system/'connect', user/'login' * @param body the contenct of the request * @return http json response */ protected put(body?: any, resource?: string | number): Observable; /** * basic http delete request with headers. * @param resource the entity resource param. ex: system/'connect', user/'login' * @return http json response */ protected delete(resource?: string | number): Observable; /** * Clearing drupal session after logging out */ protected removeSession(): void; /** * Checking the current connection if the connection is init and valid * @return if connection is valid */ protected isConnected(): boolean; /** * Check if the drupal session is timedout. * @return true if the current date is less than the login date by 24 day "drupal default session timeout is 24 day". */ protected isConnectionExpired(): boolean; /** * Serializin arguments as a string * @param options object of drupal parametars to serialize * @return string of parameters */ protected getArgs(options: any): string; /** * Check if variable is array of objects * @param value array to check */ private isArray; /** * retrive the variable from the connection object or if there is no connection yet it will return them from the cookies * this will will allow you to implement your custom connection storage, just like ionic. * because the cookies is not always available on webview apps, you may need to save the connection in sqllite * and restore them directly. * @param variableName the name of the saved variable */ private getSavedVariable; /** * serializing eatch option * @param key option key * @param value option value * @return single option serilization */ protected optionToString(key: string, value: any): string; /** * serializing the object keys * @param obj object to serialize */ private serializeObject; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }