@paydock/client-sdk
Version:
Paydock client sdk
54 lines • 2.07 kB
TypeScript
import { Env } from '../configs/env';
import { Observable } from 'rxjs';
import { type HttpRequestMethod } from '../shared/http';
import { type ReportErrorFn, type ReportEventFn } from '../shared/services/instrumentation/repositories';
export declare enum API_AUTH_TYPE {
PUBLIC_KEY = 0,
TOKEN = 1
}
export declare class ApiBase {
protected env: Env;
auth: string;
authType: API_AUTH_TYPE;
constructor(auth: string, authType?: API_AUTH_TYPE);
/**
* Current method can change environment. By default environment = sandbox.
* Also we can change domain alias for this environment. By default domain_alias = paydock.com
*
* @example
* widget.setEnv('production');
* @param {string} env - sandbox, production
* @param {string} [alias] - Own domain alias
*/
setEnv(env: string, alias?: string): ApiBase;
requestObservable<Req extends object, Res>(method: 'GET' | 'POST', url: string, requestBody: Req): Observable<Res>;
private makeRequest;
private onRequestLoad;
private onRequestError;
setAuthType(): API_AUTH_TYPE;
getClient(method: Extract<HttpRequestMethod, 'GET' | 'POST'>, link: string): {
config: XMLHttpRequest;
send: (body: any, cb?: (data) => void, errorCb?: (data: any) => any) => void;
};
getClientPromise<Req extends object, Res>(method: Extract<HttpRequestMethod, 'GET' | 'POST'>, link: string): {
config: XMLHttpRequest;
send: (body: Req) => Promise<Res>;
};
parser({ text, status }: {
text: string;
status: number;
}, cb: any, errorCb: any): any;
parserPromise<Res>({ text, status, }: {
text: string;
status: number;
}): Promise<Res>;
reportEvent: ReportEventFn;
reportError: ReportErrorFn;
protected newApiRequest(method: Extract<HttpRequestMethod, 'GET' | 'POST'>, link: string): XMLHttpRequest;
protected get ctx(): {
sdkVersion: string;
className: string;
environment: string;
};
}
//# sourceMappingURL=api-base.d.ts.map