/** * Smartface Service-Call-Offline module. * This module provides classes to be instead of ServiceCall class for some offline capability. * * @module service-call-offline * @type {object} * @deprecated USE AXIOS OR XMLHTTPREQUEST INSTEAD! * @copyright Smartface 2019 */ import ServiceCall from "../service-call"; interface OfflineRequestOptions { offlineRequestHandler?(e: T): Promise; } export declare const closeOfflineDatabase: (e: any) => any; export declare class OfflineRequestServiceCall extends ServiceCall { offlineRequestHandler: OfflineRequestOptions["offlineRequestHandler"]; /** * Creates an OfflineRequestServiceCall helper class * If there's no network connection, saves the request to perform later when * network connection is available * @augments ServiceCall * @param {function} offlineRequestHandler - Gets request options to be modified * when network connection is available and returns a promise * @example * ``` * import { OfflineRequestServiceCall } from '@smartface/extension-utils/lib/service-call-offline'; * sc = new OfflineRequestServiceCall({ * baseUrl: "http://smartface.io", * logEnabled: true, * offlineRequestHandler: requestOptions => { * return new Promise((resolve, reject) => { * amce.createRequestOptions(amceOptions) * .then(({ headers }) => { * resolve(Object.assign({}, requestOptions, headers)); * }); * }); * } * }); * ``` */ constructor(options: OfflineRequestOptions & ConstructorParameters["0"]); request(endpointPath: string, options: Parameters[1]): Promise; /** * Perform all pending requests in DB * @static * @method * @returns {Promise} */ sendAll(): Promise; private clearJobs; } export declare class OfflineResponseServiceCall extends ServiceCall { private _requestCleaner; /** * Creates an OfflineResponseServiceCall helper class * Response is served from DB then request is made to update the DB * * @augments ServiceCall * @param {function} requestCleaner - Returns modified request options * @example * ``` * import { OfflineResponseServiceCall } from '@smartface/extension-utils/lib/service-call-offline'; * sc = sc || new OfflineResponseServiceCall({ * baseUrl: "http://smartface.io", * logEnabled: true, * requestCleaner: requestOptions => { * delete requestOptions.headers; * return requestOptions; * } * }); * ``` */ constructor(options: { baseUrl: string; logEnabled?: boolean; requestCleaner: OfflineRequestOptions["offlineRequestHandler"]; encryptionFunction: (e: any) => any; decryptionFunction: (e: any) => any; }); request(endpointPath: string, options?: Parameters[1]): Promise; } export declare function clearOfflineDatabase(): Promise; export {};