import { AngularFireAuth } from 'angularfire2/auth'; import { HttpClient } from '@angular/common/http'; import * as firebase from 'firebase'; import 'rxjs/add/operator/toPromise'; import 'rxjs/add/operator/map'; import { ROUTER_RESPONSE } from './defines'; /** * Interface for Configuration */ export interface FIREBASE_CMS_SERVICE_CONFIG { firebase: any; apiUrl: string; disableAlertOnNotInstall?: boolean; logRequestUrl?: boolean; } export declare class FirebaseCmsService { http: HttpClient; static config: any; firebaseApp: firebase.app.App; apiUrl: string; afAuth: AngularFireAuth; idToken: string; isLogin: boolean; constructor(http: HttpClient); readonly config: FIREBASE_CMS_SERVICE_CONFIG; /** * It initialize the CMS with the configuration. * @param config Backend configuration * config['firebase'] is the firebase configuration. * config['api'] is the function api url. */ initialize(config: FIREBASE_CMS_SERVICE_CONFIG): void; initializeFirebase(): void; initializeFirebaseAuthentication(): void; updateIdToken(idToken: string): void; readonly userDisplayName: string; version(debug?: boolean): Promise; userSet(data: any): void; /** * Returns the same return value of `auth.signInWithEmailAndPassword()` * @desc It does not return `backend server response`. * @param email user email * @param password user passowrd * * @return `Firebase` Promise. */ login(email: any, password: any): Promise; logout(): Promise; /** * Returns a Promise of `ROUTER_REPONSE` or Firebase Error Object. * @param data User data to resiter with Email/Password on Authentication. */ registerWithAuthentication(data: any): Promise; /** * Returns server response after register. * @param data User data to create `Firebase Authentication` and set Document on `user collection` * * @desc It does not log after registration since it may get a complicated code. Simple is the best! */ register(data: any): Promise; profileUpdate(data: any): Promise; getUserData(): Promise; logUrl(data: any): void; /** * Request to `Firebase Functions` and returns the response. * * @desc All request must be done through this method. * * @desc If there is error, the `BACKEND_ERROR_RESPONSE` object will be returned instead of `Error` object. * This is important when you handle error. * @param data request data */ route(data: any): Promise; /** * Returns http query string. * @param params Object to build as http query string * @return * - http query string * - Or null if the input is emtpy or not object. */ httpBuildQuery(params: any): string | null; /** * Returns server response. * * @return * - `data` is set to true if the backend is installed. * - Otherwise, `data` will be false. */ checkInstall(): Promise; install(data: any): Promise; categoryCreate(data: any): Promise; categoryGet(id: any): Promise; categoryUpdate(data: any): Promise; }