@ringcentral/sdk
Version:
- [Installation](#installation) - [Getting Started](#getting-started) - [API Calls](#api-calls) - [Advanced SDK Configuration & Polyfills](#advanced-sdk-configuration--polyfills) - [Making telephony calls](#making-telephony-calls) - [Call management using
161 lines (160 loc) • 5.75 kB
TypeScript
/// <reference types="node" />
import EventEmitter from 'events';
import * as qs from 'querystring';
import Auth, { AuthOptions } from './Auth';
import Cache from '../core/Cache';
import Client, { ApiError } from '../http/Client';
import Externals from '../core/Externals';
export declare enum events {
beforeLogin = "beforeLogin",
loginSuccess = "loginSuccess",
loginError = "loginError",
beforeRefresh = "beforeRefresh",
refreshSuccess = "refreshSuccess",
refreshError = "refreshError",
beforeLogout = "beforeLogout",
logoutSuccess = "logoutSuccess",
logoutError = "logoutError",
rateLimitError = "rateLimitError"
}
export default class Platform extends EventEmitter {
static _cacheId: string;
events: typeof events;
private _server;
private _clientId;
private _clientSecret;
private _redirectUri;
private _refreshDelayMs;
private _clearCacheOnRefreshError;
private _userAgent;
private _externals;
private _cache;
private _client;
private _refreshPromise;
private _auth;
private _tokenEndpoint;
private _revokeEndpoint;
private _authorizeEndpoint;
private _authProxy;
private _urlPrefix;
constructor({ server, clientId, clientSecret, redirectUri, refreshDelayMs, clearCacheOnRefreshError, appName, appVersion, externals, cache, client, refreshHandicapMs, tokenEndpoint, revokeEndpoint, authorizeEndpoint, authProxy, urlPrefix, }: PlatformOptionsConstructor);
on(event: events.beforeLogin, listener: () => void): any;
on(event: events.loginSuccess, listener: (response: Response) => void): any;
on(event: events.loginError, listener: (error: ApiError | Error) => void): any;
on(event: events.beforeRefresh, listener: () => void): any;
on(event: events.refreshSuccess, listener: (response: Response) => void): any;
on(event: events.refreshError, listener: (error: ApiError | Error) => void): any;
on(event: events.beforeLogout, listener: () => void): any;
on(event: events.logoutSuccess, listener: (response: Response) => void): any;
on(event: events.logoutError, listener: (error: ApiError | Error) => void): any;
on(event: events.rateLimitError, listener: (error: ApiError | Error) => void): any;
auth(): Auth;
createUrl(path?: string, options?: CreateUrlOptions): string;
signUrl(path: string): Promise<string>;
loginUrl({ implicit, state, brandId, display, prompt, uiOptions, uiLocales, localeId }?: LoginUrlOptions): string;
/**
* @param {string} url
* @return {Object}
*/
parseLoginRedirect(url: string): qs.ParsedUrlQuery;
/**
* Convenience method to handle 3-legged OAuth
*
* Attention! This is an experimental method and it's signature and behavior may change without notice.
*/
loginWindow({ url, width, height, origin, property, target, }: LoginWindowOptions): Promise<LoginOptions>;
/**
* @return {Promise<boolean>}
*/
loggedIn(): Promise<boolean>;
login({ username, password, extension, code, access_token_ttl, refresh_token_ttl, access_token, endpoint_id, ...options }?: LoginOptions): Promise<Response>;
private _refresh;
refresh(): Promise<Response>;
logout(): Promise<Response>;
inflateRequest(request: Request, options?: SendOptions): Promise<Request>;
sendRequest(request: Request, options?: SendOptions): Promise<Response>;
send(options?: SendOptions): Promise<Response>;
get(url: any, query?: any, options?: SendOptions): Promise<Response>;
post(url: any, body?: any, query?: any, options?: SendOptions): Promise<Response>;
put(url: any, body?: any, query?: any, options?: SendOptions): Promise<Response>;
delete(url: any, query?: any, options?: SendOptions): Promise<Response>;
ensureLoggedIn(): Promise<Response | null>;
protected _tokenRequest(url: any, body: any): Promise<Response>;
basicAuthHeader(): string;
authHeader(): Promise<string>;
}
export interface PlatformOptions extends AuthOptions {
server?: string;
clientId?: string;
clientSecret?: string;
redirectUri?: string;
refreshDelayMs?: number;
refreshHandicapMs?: number;
clearCacheOnRefreshError?: boolean;
appName?: string;
appVersion?: string;
tokenEndpoint?: string;
revokeEndpoint?: string;
authorizeEndpoint?: string;
authProxy?: boolean;
urlPrefix?: string;
}
export interface PlatformOptionsConstructor extends PlatformOptions {
externals: Externals;
cache: Cache;
client: Client;
}
export interface SendOptions {
url?: any;
body?: any;
method?: string;
query?: any;
headers?: any;
skipAuthCheck?: boolean;
handleRateLimit?: boolean | number;
retry?: boolean;
}
export interface LoginOptions {
username?: string;
password?: string;
extension?: string;
code?: string;
access_token?: string;
access_token_ttl?: number;
refresh_token_ttl?: number;
endpoint_id?: string;
}
export interface LoginUrlOptions {
state?: string;
brandId?: string;
display?: LoginUrlDisplay | string;
prompt?: LoginUrlPrompt | string;
implicit?: boolean;
uiOptions?: string;
uiLocales?: string;
localeId?: string;
}
export declare enum LoginUrlPrompt {
login = "login",
sso = "sso",
consent = "consent",
none = "none"
}
export declare enum LoginUrlDisplay {
page = "page",
popup = "popup",
touch = "touch",
mobile = "mobile"
}
export interface CreateUrlOptions {
addServer?: boolean;
addMethod?: string;
}
export interface LoginWindowOptions {
url: string;
width?: number;
height?: number;
origin?: string;
property?: string;
target?: string;
}