UNPKG

bria

Version:

CounterPath Bria Desktop API for Node.js

141 lines 5.11 kB
import EventEmitter from 'eventemitter3'; import sxml from 'sxml'; import BriaRequest from '../requests/BriaRequest'; import { BriaClientStatus } from './Status'; import { BriaClientAudio } from './Audio'; import { BriaClientCall } from './Call'; import { BriaClientAccount } from './Account'; import { BriaClientVoicemail } from './Voicemail'; import { BriaClientHistory } from './History'; import { BriaClientPresence } from './Presence'; import { BriaClientCollaboration } from './Collaboration'; import { BriaClientAuth } from './Auth'; import { BriaClientPhone } from './Phone'; declare type BriaClientOptions = { userAgent?: string; /** * Bria WebSocket URL * Default is 'wss://cpclientapi.softphone.com:9002/counterpath/socketapi/v1' */ apiUrl?: string; autoReconnect?: boolean; /** * Delay before reopening the WebSocket (in milliseconds) */ autoReconnectDelay?: number; autoReconnectAttempts?: number; /** * Ignore invalid certificates * Default FALSE (insecure!!) because the Desktop API does not include * valid intermediate certificates in the chain. */ rejectUnauthorized?: boolean; /** * Automatically populate the version information on connection * Default TRUE, this will request API access as soon as connected * If false, you won't be able to use old Bria versions with the wrapper. */ populateVersion?: boolean; /** * Automatically populate the client's children's properties * Default TRUE, this will request API access as soon as connected * If false, it will only populate data on-demand (on event/method calls) */ populateChildren?: boolean; }; declare type BriaClientVersion = { systemCompanyName: string; systemProductName: string; systemProductVersion: string; systemProductBuild: number; }; /** * @param xml XML response from simplexml (sxml), if any * @param rawData Raw response string from Bria */ declare type BriaClientStatusChangeEvent = (xml: sxml.XML, rawData: string) => Promise<void> | void; declare type BriaClientEvents = { error: (error: Error) => void; warn: (warning: Error) => void; reconnect: () => Promise<void> | void; /** * WebSocket is open */ open: () => Promise<void> | void; /** * Client is ready for requests */ ready: () => Promise<void> | void; close: (code: number, reason: string) => Promise<void> | void; 'statusChange.authentication': BriaClientStatusChangeEvent; 'statusChange.phone': BriaClientStatusChangeEvent; 'statusChange.call': BriaClientStatusChangeEvent; 'statusChange.callOptions': BriaClientStatusChangeEvent; 'statusChange.voicemail': BriaClientStatusChangeEvent; 'statusChange.callHistory': BriaClientStatusChangeEvent; [x: string]: any; }; /** * Bria Client */ export declare class BriaClient extends EventEmitter<BriaClientEvents> { private userAgent; private apiUrl; private autoReconnect; private autoReconnectDelay; private autoReconnectAttempts; private ws?; private reconnectAttempts; private rejectUnauthorized; private populateVersion; private populateChildren; clientVersion?: BriaClientVersion; auth: BriaClientAuth; phone: BriaClientPhone; status: BriaClientStatus; audio: BriaClientAudio; call: BriaClientCall; account: BriaClientAccount; voicemail: BriaClientVoicemail; history: BriaClientHistory; presence: BriaClientPresence; collaboration: BriaClientCollaboration; constructor(options?: BriaClientOptions); private websocketReconnect; private websocketOpen; private websocketClosed; private websocketMessage; connect(): void; /** * Check the Bria version against the args (clientVersion < major.minor.patch) * If populateVersion is false, this function always returns FALSE. * @param version */ versionLt(version: string): boolean; /** * Check the Bria version against the args (clientVersion > major.minor.patch) * If populateVersion is false, this function always returns TRUE. * @param version */ versionGt(version: string): boolean; /** * Send a request to the Bria client * @param request BriaRequest * @returns request's transaction ID (UUID) */ send(request: BriaRequest): string; /** * Send a request to the Bria client and wait for a response by transaction ID * @param request BriaRequest * @returns response */ sendWait(request: BriaRequest): Promise<sxml.XML>; /** * Brings Bria window to front and takes focus * @param window Window to bring focus to * @see https://docs.counterpath.com/guides/desk/desk_api/clients/deskAPI/deskApiGettingReady.htm#getBringToFront */ bringToFront(window?: 'main' | 'collab'): Promise<sxml.XML>; } export {}; //# sourceMappingURL=index.d.ts.map