/// import { EventEmitter } from 'events'; import 'isomorphic-fetch'; import Token, { TokenStore } from './Token'; import RCAccount from './RCAccount'; export declare const SERVER_PRODUCTION = "https://platform.ringcentral.com"; export declare const SERVER_SANDBOX = "https://platform.devtest.ringcentral.com"; export declare const API_VERSION = "v1.0"; export declare const BASE_URL = "/restapi/"; export declare const EventLoginStart = "LoginStart"; export declare const EventLoginSuccess = "LoginSuccess"; export declare const EventLoginError = "LoginError"; export declare const EventRefreshStart = "RefreshStart"; export declare const EventRefreshSuccess = "RefreshSuccess"; export declare const EventRefreshError = "RefreshError"; export declare const EventLogoutStart = "LogoutStart"; export declare const EventLogoutSuccess = "LogoutSuccess"; export declare const EventLogoutError = "LogoutError"; /** * A wrapper for sending http requests to RingCentralService. */ export default class RestClient extends EventEmitter { server: string; appKey: string; appSecret: string; handleRateLimit: boolean; private recoverTime; tokenStore: TokenStore; private gettingToken; agents: string[]; constructor(opts: ClientOptions); private basicAuth(); /** * Throw exception if no valid token. */ getToken(ownerInfo?: RCAccount): Promise; /** * Send http GET method */ get(url: string, query?: {}): Promise; delete(url: string, query?: {}): Promise; /** Body can be Blob, FormData, URLSearchParams, String, Buffer or stream.Readable, any other type, plain object or instance of class will stringified as json. */ post(url: string, body: any, query?: {}): Promise; /** Type of body is the same as post. */ put(url: string, body: any, query?: {}): Promise; call(endpoint: string, query?: {}, opts?: RequestInit): Promise; /** * Perform an authenticated API call. */ private sendApiCall(endpoint, query?, opts?); auth(opts: { username: string; password: string; extension?: string; accessTokenTtl?: number; refreshTokenTtl?: number; scope?: string[]; }): Promise; /** * Login by oauth. http://ringcentral-api-docs.readthedocs.io/en/latest/oauth/ * @param callbackUrl The full oauth callback url with parameters returned from RingCentral. */ oauthByUrl(callbackUrl: string, opts?: { accessTokenTtl: string; refreshTokenTtl: string; }): Promise; oauth(code: string, redirectUri: string, opts?: { accessTokenTtl: string; refreshTokenTtl: string; }): Promise; /** * Parse parameters from oauth. * @param paramsStr The query part of the RingCentral oauth call back url. */ parseOauthCallback(paramsStr: string): OauthCallbackParams; oauthUrl(redirect_uri: string, opts?: { state?: string; force?: boolean; }): string; private authRequest(body, user?); logout(): Promise; /** Only one request will be sent at the same time. */ private refreshToken(token); } export interface OauthCallbackParams { code: string; expires_in: number; state?: string; } export interface ClientOptions { server?: string; appKey: string; appSecret: string; /** Default TokenStore is MemoryTokenStore */ tokenStore?: TokenStore; handleRateLimit?: boolean; }