voximplant-websdk
Version:
VoxImplant Web SDK for embedding voice and video communication into web applications.
964 lines (959 loc) • 319 kB
TypeScript
// Generated by dts-bundle v0.7.3
declare module 'voximplant-websdk' {
import { Client } from 'voximplant-websdk/Client';
import Messaging from 'voximplant-websdk/Messaging';
export { Messaging } from 'voximplant-websdk/Messaging';
export { Events } from 'voximplant-websdk/Events';
export { CallEvents } from 'voximplant-websdk/Call/CallEvents';
export { Endpoint } from 'voximplant-websdk/Call/EndPoints/Endpoint';
export { EndpointEvents } from 'voximplant-websdk/Call/EndPoints/EndpointEvents';
export { OperatorACDStatuses, LoginTokens, VideoFlags, LogRecord, QueueTypes, ConnectionNode, AuthResultCode, MediaRendererKind, } from 'voximplant-websdk/Structures';
export { LogCategory, LogLevel, ClientState } from 'voximplant-websdk/Logger';
export * from 'voximplant-websdk/Hardware/index';
export { MediaRenderDisablingReason } from 'voximplant-websdk/Media/MediaRenderDisablingReason';
export { CallState } from 'voximplant-websdk/Call/AbstractCall';
/**
* Get a [Client] instance to use platform functions
* @returns {Client}
*/
export function getInstance(): Client;
/**
* Voximplant Web SDK lib version
*/
export const version: string;
/**
* Get a [Messenger] instance to use Messaging functions
* @returns {Messenger}
*
*/
export function getMessenger(): Messaging.Messenger;
}
declare module 'voximplant-websdk/Client' {
import { Call } from 'voximplant-websdk/Call/Call';
import { SharingCall } from 'voximplant-websdk/Call/SharingCall';
import { ViewerCall } from 'voximplant-websdk/Call/ViewerCall';
import { EventHandlers } from 'voximplant-websdk/EventHandlers';
import { Events } from 'voximplant-websdk/Events';
import { EventListenerOption, EventTarget } from 'voximplant-websdk/EventTarget';
import { ClientState, LogCategory, LogLevel } from 'voximplant-websdk/Logger';
import { LoginState } from 'voximplant-websdk/LoginStateEnum';
import { MediaRenderer } from 'voximplant-websdk/Media/MediaRenderer';
import { CodecDescription } from 'voximplant-websdk/PeerConnection/SDP/Interfaces';
import { VoxSignalingHandler } from 'voximplant-websdk/Signaling/VoxSignalingHandler';
import { AudioOutputInfo, AudioSourceInfo, CallSettings, Config, LoginOptions, LogRecord, OperatorACDStatuses, SetOperatorACDStatusOptions, VideoFlags, VideoSettings, VideoSourceInfo } from 'voximplant-websdk/Structures';
/**
* The Client class is used to control platform functions. Cannot be instantiated directly (singleton), so use the [getInstance] method to get the class instance.
*/
export class Client extends EventTarget<Events> implements VoxSignalingHandler {
/**
* @hidden
*/
videoSupport: boolean;
/**
* @hidden
*/
localVideoContainerId: string;
/**
* @hidden
*/
remoteVideoContainerId: string;
/**
* @hidden
*/
_defaultSinkId: string;
/**
* Enforce use turn serves for conference calls
* If value is false turn servers possible, but not guarantee
* @type {boolean}
* @hidden
*/
allowTurnForConferenceCalls: boolean;
/**
* @hidden
*/
loginState: LoginState;
/**
* @type {Array}
* @hidden
*/
limitVCodecs: CodecDescription[];
/**
* @type {Array}
* @hidden
*/
limitACodecs: CodecDescription[];
/**
* @hidden
*/
features: string[];
/**
* @hidden
*/
constructor();
/**
* Returns the Voximplant Web SDK version.
* @function
* @hidden
*/
get version(): string;
/**
* @hidden
*/
static getInstance(): Client;
/**
* Plays a progress tone according to specified country in config.progressToneCountry.
* @hidden
*/
playProgressTone(check?: boolean): void;
/**
* Stops the progress tone.
* @hidden
*/
stopProgressTone(): void;
/**
* @hidden
*/
onIncomingCall(id: any, callerid: any, displayName: any, headers: any, hasVideo: any): void;
get alreadyInitialized(): boolean;
/**
* Initializes the SDK. The [Events.SDKReady] event is dispatched after successful SDK initialization. SDK cannot be used until it is initialized.
* @param {VoxImplant.Config} [config] Client configuration options
*/
init(config?: Config): Promise<EventHandlers.SDKReady | string>;
/**
* Creates a call.
*
* This method can throw the 1003 error if the client is not connected to the Voximplant Cloud or the 1004 error if the client is not authorized.
* @name VoxImplant.Client.call
* @param {(String|CallSettings)} num The number to call or [CallSettings](/docs/references/websdk/voximplant/callsettings). For SIP compatibility reasons it should be a non-empty string even if the number itself is not used by a Voximplant cloud scenario
* @param {VideoFlags} useVideo Deprecated: Please, use [CallSettings](/docs/references/websdk/voximplant/callsettings) instead
* @param {String} customData Deprecated: Please, use [CallSettings](/docs/references/websdk/voximplant/callsettings) instead
* @param {Object} extraHeaders Deprecated: Please, use [CallSettings](/docs/references/websdk/voximplant/callsettings) instead
* @returns {VoxImplant.Call}
*/
call(num: string | CallSettings, useVideo?: boolean | VideoFlags, customData?: string, extraHeaders?: {
[id: string]: string;
}): Call;
/**
* Creates a call to a dedicated conference without a proxy session. For details see the [video conferencing guide](/docs/guides/conferences/scenarios).
*
* This method can throw the 1003 error if the client is not connected to the Voximplant Cloud or the 1004 error if the client is not authorized.
* @param {(String|CallSettings)} num The number to call or [CallSettings](/docs/references/websdk/voximplant/callsettings). For SIP compatibility reasons it should be a non-empty string even if the number itself is not used by a Voximplant cloud scenario
* @param {Boolean} useVideo Deprecated: Please, use [CallSettings](/docs/references/websdk/voximplant/callsettings) instead
* @param {String} customData Deprecated: Please, use [CallSettings](/docs/references/websdk/voximplant/callsettings) instead
* @param {Object} extraHeaders Deprecated: Please, use [CallSettings](/docs/references/websdk/voximplant/callsettings) instead
* @returns {Call}
*/
callConference(num: string | CallSettings, useVideo?: boolean | VideoFlags, customData?: string, extraHeaders?: {
[id: string]: string;
}): Call;
/**
* Calls the specified conference as a separate screen sharing participant.
*
* This method can throw the 1003 error if the client is not connected to the Voximplant Cloud or the 1004 error if the client is not authorized.
* @param num The conference room ID. Use different room IDs for different conference rooms. You can launch different scenarios depending on this parameter by specifying this value as a [routing rule](/docs/getting-started/basic-concepts/routing) pattern.
* @param sendAudio Whether to send audio stream (works only for Chrome, Edge)
* @param extraHeaders
*/
joinAsSharing(num: string | number, sendAudio?: boolean, extraHeaders?: {
[id: string]: string;
}): SharingCall;
/**
* Calls the specified conference as viewer participant only for receiving audio/video.
*
* This method can throw the 1003 error if the client is not connected to the Voximplant Cloud or the 1004 error if the client is not authorized.
* @param num The conference room number or ID
* @param extraHeaders
*/
joinAsViewer(num: string | number, extraHeaders?: {
[id: string]: string;
}): ViewerCall;
/**
* Gets the current config.
*/
config(): Config;
/**
* Connects to the Voximplant Cloud.
*/
connect(): Promise<boolean>;
/**
* Disconnects from the Voximplant Cloud.
*/
disconnect(): Promise<void>;
/**
* Sets the agent's status for SmartQueue and ACD v1 contact center.
* @param {OperatorACDStatuses} Automatic call distributor status
* @param {SetOperatorACDStatusOptions} Options for setting an agent's status
*/
setOperatorACDStatus(status: OperatorACDStatuses, options?: SetOperatorACDStatusOptions): Promise<OperatorACDStatuses>;
/**
* Sets the SmartQueue messaging status.
* @param {OperatorACDStatuses} SmartQueue messaging status
* @param {SetOperatorACDStatusOptions} Options for setting the SmartQueue instant messaging status.
*/
setOperatorSQMessagingStatus(status: OperatorACDStatuses, options?: SetOperatorACDStatusOptions): Promise<OperatorACDStatuses>;
/**
* Returns the current agent's status for SmartQueue and ACD v1 contact center.
* @returns {Promise<OperatorACDStatuses>}
*/
getOperatorACDStatus(): Promise<OperatorACDStatuses>;
/**
* Returns the current agent's status for SmartQueue messaging.
* @returns {Promise<OperatorACDStatuses>}
*/
getOperatorSQMessagingStatus(): Promise<OperatorACDStatuses>;
/**
* Logs in to an application. The method triggers the [Events.AuthResult] event.
* @param {String} username Fully-qualified username that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com"
* @param {String} password The user's password
* @param {VoxImplant.LoginOptions} [options]
*/
login(username: string, password: string, options?: LoginOptions): Promise<EventHandlers.AuthResult>;
/**
* Logs in to an application via the 'code' auth method. The method triggers the [Events.AuthResult] event.
*
* Please, refer to the [documentation](/docs/guides/sdk/authorization-onetimekey).
* @param {String} username Fully-qualified username that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com"
* @param {String} code
* @param {VoxImplant.LoginOptions} [options]
* @hidden
*/
loginWithCode(username: string, code: string, options?: LoginOptions): Promise<EventHandlers.AuthResult>;
/**
* Logs in to an application via an accessToken. The method triggers the [Events.AuthResult] event.
* @param {String} username Fully-qualified username that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com"
* @param {String} token
* @param {VoxImplant.LoginOptions} [options]
*/
loginWithToken(username: string, token: string, options?: LoginOptions): Promise<EventHandlers.AuthResult>;
/**
* Refreshes the expired access token.
* @param {String} username Fully-qualified username that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com".
* @param {String} refreshToken
* @param {String} deviceToken A unique token for the current device
*/
tokenRefresh(username: string, refreshToken: string, deviceToken?: string): Promise<EventHandlers.AuthTokenResult>;
/**
* Requests a key for the 'onetimekey' auth method.
* Server sends the key in the [Events.AuthResult] event with the code 302.
*
* Please read the article about the [authorization with one-time key](/docs/guides/sdk/onetimekey).
* @param {String} username
*/
requestOneTimeLoginKey(username: string): Promise<EventHandlers.AuthResult>;
/**
* Logs in to an application via the 'onetimekey' auth method.
* Hash should be calculated with the key from the triggered [Events.AuthResult] event.
*
* Please read the article about the [authorization with one-time key](/docs/guides/sdk/onetimekey).
* @param {String} username
* @param {String} hash
* @param {VoxImplant.LoginOptions} [options]
*/
loginWithOneTimeKey(username: string, hash: string, options?: LoginOptions): Promise<EventHandlers.AuthResult>;
/**
* Checks if the client is connected to Voximplant Cloud.
* @deprecated
* See [[Client.getClientState]]
*/
connected(): boolean;
/**
* Shows/hides the local video. *IMPORTANT*: Safari browser for iOS requires a user interface for playing video during a call. It should be interactive element like an HTML "button" with "onclick" handler that calls "play" method on the "video" HTML element.
* @param {Boolean} [flag=true] Show/hide - true/false
* @param {Boolean} mirror Deprecated
* @param {Boolean} detachCamera Deprecated
*/
showLocalVideo(flag?: boolean, mirror?: boolean, detachCamera?: boolean): Promise<MediaRenderer | void>;
/**
* Sets the local video position.
* @param {Number} x Horizontal position (px)
* @param {Number} y Vertical position (px)
* @function
* @hidden
* @deprecated
* @name VoxImplant.Client.setLocalVideoPosition
*/
setLocalVideoPosition(x: number, y: number): void;
/**
* Sets the local video size.
* @param {Number} width Width in pixels
* @param {Number} height Height in pixels
* @function
* @hidden
* @deprecated
* @name VoxImplant.Client.setLocalVideoSize
*/
setLocalVideoSize(width: number, height: number): void;
/**
* Sets the video settings globally. This settings is to be used for the next call.
* @param {VoxImplant.VideoSettings|VoxImplant.FlashVideoSettings} settings Video settings
* @param {Function} [successCallback] Success callback function has MediaStream object as its argument
* @param {Function} [failedCallback] Failed callback function
* @deprecated
* @hidden
*/
setVideoSettings(settings: VideoSettings, successCallback?: Function, failedCallback?: Function): void;
/**
* Sets the bandwidth limit for video calls. Currently supported by Chrome/Chromium. (WebRTC mode only). The limit is to be applied for the next call.
* @param {Number} bandwidth Bandwidth limit in kilobits per second (kbps)
*/
setVideoBandwidth(bandwidth: number): void;
/**
* Plays a ToneScript via WebAudio API.
* @param {String} script Tonescript string
* @param {Boolean} [loop=false] Loop playback if true
*/
playToneScript(script: string, loop?: boolean): void;
/**
* Stops playing ToneScript via WebAudio API.
*/
stopPlayback(): void;
/**
* Changes the current global sound volume.
* @deprecated
* @param {Number} level New sound volume value between 0 and 100
* @function
* @hidden
*/
volume(level: number): number;
/**
* Gets a list of all currently available audio sources/microphones.
* @deprecated
* @hidden
*/
audioSources(): AudioSourceInfo[];
/**
* Gets the list of all currently available video sources/cameras.
* @deprecated
* @hidden
*/
videoSources(): VideoSourceInfo[];
/**
* Gets the list of all currently available audio playback devices
* @deprecated
* @hidden
*/
audioOutputs(): AudioOutputInfo[];
/**
* Selects the specified audio source, use [audioSources] to get the list of available audio sources.
* If SDK is init with micRequired: false, force attach microphone.
* @param {String} id Id of the audio source
* @param {Function} [successCallback] Called in WebRTC mode if audio source changed successfully
* @param {Function} [failedCallback] Called in WebRTC mode if audio source could not changed successfully
* @deprecated
* @hidden
*/
useAudioSource(id: string, successCallback?: Function, failedCallback?: Function): Promise<MediaStream>;
/**
* Selects the specified video source, use [videoSources] to get the list of available video sources.
* @param {String} id Id of the video source
* @param {Function} [successCallback] Called if video source changed successfully, has MediaStream object as its argument
* @param {Function} [failedCallback] Called if the video source has not been changed successfully, or has a MediaStreamError object as its argument
* @deprecated
* @hidden
*/
useVideoSource(id: string, successCallback?: Function, failedCallback?: Function): Promise<MediaStream>;
/**
* Selects the specified audio output for new calls, use [audioOutputs] to get the list of available audio output.
* @param {String} id Id of the audio source
* @deprecated
* @hidden
*/
useAudioOutput(id: string): Promise<void>;
/**
* Enables microphone/camera if micRequired in [Config] is set to false.
* @param {Function} successCallback Called if selected recording devices are attached successfully, has MediaStream object as its argument
* @param {Function} failedCallback Called if selected recording devices cannot be attached, has MediaStreamError object as its argument
* @deprecated
* @hidden
*/
attachRecordingDevice(successCallback?: Function, failedCallback?: Function): Promise<MediaStreamTrack>;
/**
* Disables microphone/camera if micRequired in [Config] is set to false.
* @deprecated
* @hidden
*/
detachRecordingDevice(): void;
/**
* Sets the call active.
* @param {VoxImplant.Call} call Voximplant call instance
* @param {Boolean} [active=true] If true make call active, otherwise make call inactive
* @deprecated
* @hidden
*/
setCallActive(call: Call, active?: boolean): Promise<EventHandlers.Updated>;
/**
* Starts/stops sending local video to remote party/parties. *IMPORTANT*: Safari browser for iOS requires a user interface for playing video during a call. It should be interactive element like an HTML "button" with "onclick" handler that calls "play" method on the "video" HTML element.
* @param {Boolean} [flag=true] Start/stop - true/false
* @deprecated
* @hidden
*/
sendVideo(flag?: boolean): void;
/**
* Checks if WebRTC support is available.
* @returns {Boolean}
*/
isRTCsupported(): boolean;
/**
* Transfers a call. Depending on the result, [CallEvents.TransferComplete] or [CallEvents.TransferFailed] event is dispatched.
*
* This method can throw the 1003 error if the client is not connected to the Voximplant Cloud or the 1004 error if the client is not authorized.
* @param {VoxImplant.Call} call1 The call to transfer
* @param {VoxImplant.Call} call2 The destination call where the call1 needs to be transferred
*/
transferCall(call1: Call, call2: Call): void;
/**
* Sets the logger levels for specified logger categories.
* @param {LogCategory} category Log category
* @param {LogLevel} level Log level
* @hidden
*/
setLogLevel(category: LogCategory, level: LogLevel): void;
/**
* @hidden
*/
onSignalingConnected(): void;
/**
* @hidden
*/
onSignalingClosed(): Promise<void>;
/**
* @hidden
*/
onSignalingConnectionFailed(reason: any): void;
/**
* @hidden
*/
onMediaConnectionFailed(): void;
/**
* Not documented function for backward compatibility
* @hidden
* @param string call_id Call ID
* @returns {Call}
*/
getCall(call_id: string): Call;
/**
* Not documented function for backward compatibility
* Remove call from calls array
* @param string call_id Call id
* @hidden
*/
removeCall(call_id: string): void;
/**
* Returns promise that is resolved with a boolean flag. The boolean flag.
* is set to 'true' if screen sharing is supported.
* Promise is rejected in case of an internal error.
*/
screenSharingSupported(): Promise<boolean>;
/**
* Registers a handler for specified event.
* @param event Event name (i.e. [Events.SDKReady]). See [Events]
* @param handler Handler function. A single parameter is passed - object with event information
* @deprecated
* @hidden
*/
addEventListener(event: Events, handler: (ev: any) => void): void;
/**
* Removes the handler for specified event
* @param {Function} event Event name (i.e. [Events.SDKReady]). See [Events]
* @param {Function} [handler] Handler function, if not specified all event handlers for the specified event are removed
* @function
* @deprecated
* @hidden
*/
removeEventListener(event: Events, handler?: (ev: any) => void): void;
/**
* Registers a handler for the specified event. The method is a shorter equivalent for *addEventListener*. One event can have more than one handler; handlers are executed in order of registration.
* Use the [Client.off] method to delete a handler.
* @param {string} event Event name (i.e. [Events.SDKReady]). See [Events]
* @param {Function} handler Handler function. A single parameter is passed - object with event information
* @function
*/
on(event: Events, handler: (ev: any) => void, options?: EventListenerOption): void;
/**
* Removes a handler for the specified event. The method is a shorter equivalent for *removeEventListener*. If a number of events has the same function as a handler, the method can be called multiple times with the same handler argument.
* @param {string} event Event name (i.e. [Events.SDKReady]). See [Events]
* @param {Function} [handler] Handler function, if not specified all event handlers for the specified event are removed
* @function
*/
off(event: Events, handler?: (ev: any) => void): void;
/**
* Registers for push notifications. Application receive push notifications from Voximplant Server after first login.
* @hidden
* @param token FCM registration token that can be retrieved by calling firebase.messaging().getToken() inside a service worker
* @returns {Promise<void>}
*/
registerForPushNotificatuons(token: string): Promise<void>;
/**
* Registers for push notifications. Application receive push notifications from Voximplant Server after first login.
* @param token FCM registration token that can be retrieved by calling firebase.messaging().getToken() inside a service worker
* @returns {Promise<void>}
*/
registerForPushNotifications(token: string): Promise<void>;
/**
* Unregisters from push notifications. Application no longer receives push notifications from the Voximplant server.
* @param token FCM registration token that has been used to register for push notifications
* @hidden
* @returns {Promise<void>}
*/
unregisterForPushNotificatuons(token: string): Promise<void>;
/**
* Unregisters from push notifications. Application no longer receives push notifications from the Voximplant server.
* @hidden
* @param token FCM registration token that has been used to register for push notifications
* @returns {Promise<void>}
*/
unregisterForPushNotifications(token: string): Promise<void>;
/**
* Handles push notification
* @param message Push notification that comes from the firebase.messaging().setBackgroundMessageHandler callback inside a service worker
* @returns {Promise<void>}
*/
handlePushNotification(message: any): Promise<void>;
/**
* Generates a new GUID identifier. Unique each time.
* @hidden
*/
getGUID(): string;
/**
* Sets the state of the silent logging inside SDK (it is disabled by default). When it is enabled, the WebSDK saves all logger messages into the logger until you disable it.
*
* Note that enabling of the silent logging automatically clears all existed logger records before the start.
*
* You can get current logger by the [getSilentLog] function and clean it by the [clearSilentLog] function.
* @param {boolean} flag
*/
enableSilentLogging(flag: boolean): void;
/**
* Clears the logger journal and free some memory.
*/
clearSilentLog(): void;
/**
* Gets records from the logger journal.
* @returns {Array<string>}
*/
getSilentLog(): Array<string>;
/**
* Sets outer logging callback.
*
* The method allows integrating logging pipeline of the WebSDK into the own logger i.e. the method call sends all events to the function.
* *IMPORTANT:* the callback strictly ignores Loglevel settings of the WebSDK.
*
* @param {{(record: LogRecord): void}} callback
*/
setLoggerCallback(callback: {
(record: LogRecord): void;
}): void;
/**
* Gets current client state
* @return {ClientState}
*/
getClientState(): ClientState;
/**
* @hidden
* @deprecated
* @returns {any}
*/
setSwfColor(): any;
/**
* @hidden
* @return {string}
* @private
*/
_traceName(): string;
/**
* @hidden
*/
setConnectionData(gateway: any, connectionId: any): void;
/**
* Specifies the audio codecs that can be used for calls.
*/
limitAudioCodecs(codecs: CodecDescription[]): Promise<boolean>;
/**
* Specifies the video codecs that can be used for calls.
*/
limitVideoCodecs(codecs: CodecDescription[]): Promise<boolean>;
get audioMediaTrackTransform(): (originalTrack: MediaStreamTrack) => MediaStreamTrack;
set audioMediaTrackTransform(transform: (originalTrack: MediaStreamTrack) => MediaStreamTrack);
get videoMediaTrackTransform(): (originalTrack: MediaStreamTrack) => Promise<MediaStreamTrack>;
set videoMediaTrackTransform(transform: (originalTrack: MediaStreamTrack) => Promise<MediaStreamTrack>);
}
}
declare module 'voximplant-websdk/Messaging' {
import { Messenger as ImplementMessenger } from 'voximplant-websdk/Messaging/src/Messenger';
import { Conversation as ImplementConversation } from 'voximplant-websdk/Messaging/src/Conversation';
import { Message as ImplementMessage } from 'voximplant-websdk/Messaging/src/Message';
import * as Implement from 'voximplant-websdk/Messaging/src/Structures';
/**
* Messaging module allows to exchange instant messages between two or more participants.
* Messaging supports text and metadata. The conversation does not bind or depend on audio/video calls though there is a possibility to integrate messaging in audio/video calls.
*
* FEATURES:
* 1. Messaging is the separate part of WEB SDK but it uses the [Client.login], [Client.loginWithOneTimeKey] and [Client.loginWithToken] methods. In brief, if a user has already been logged in, he can use Messaging functionality.
* 2. Messaging does not use backend JS scenarios at all.
*
*/
export module Messaging {
/**
* Get a [Messenger] instance to use Messaging functions.
*/
function getInstance(): Messenger;
/**
* Messenger class is used to control messaging functions. Cannot be instantiated directly (singleton), please use [getMessenger] or [Messaging.get] to get the class instance.
*/
class Messenger extends ImplementMessenger {
}
/**
* Class that represents a conversation. A Conversation instance is returned by the [Messenger.createConversation] and [Messenger.createConversationFromCache] methods.
* Provides methods to send messages, manage participants, receive conversation events history etc.
*/
class Conversation extends ImplementConversation {
}
/**
* Describes single message. Received via the [MessengerEvents.SendMessage] or [MessengerEvents.EditMessage] events and used to serialize or edit the message.
*/
class Message extends ImplementMessage {
}
/**
* Serialized [Message] that can be stored (e.g. in IndexedDB) and restored later via the [Messenger.createMessageFromCache] method.
*/
interface SerializedMessage extends Implement.SerializedMessage {
}
/**
* Serialized [Conversation] that can be stored (e.g. in IndexedDB) and restored later via the [Messenger.createConversationFromCache] method.
*/
interface SerializedConversation extends Implement.SerializedConversation {
}
/**
* Interface that represents a participant of the conversation (see [Conversation.participants].
* The default permissions for all participants are: write / edit / remove their own messages.
*/
interface ConversationParticipant extends Implement.ConversationParticipant {
}
/**
* Interface that represents a Voximplant user with Messaging user id.
* Voximplant users are created in [Voximplant control panel](https://manage.voximplant.com) or via [HTTP API](/docs/references/httpapi).
* To get user(s) information use the [Messenger.getUser], [Messenger.getUsers], [Messenger.getUserById] and [Messenger.getUsersById] methods.
*/
interface User extends Implement.User {
}
/**
* Interface that represents user subscription information. Available in the [MessengerEvents.GetSubscriptionList] event.
*/
interface UserSubscriptions extends Implement.MsgOutput.UserSubscriptions {
}
/**
* Interface that represents user status information. Available in the [MessengerEvents.SetStatus] event.
*/
interface UserStatus extends Implement.MsgInOutput.PresenceMessage {
}
/**
* Enum that represents actions that trigger messenger events.
* Each action is the reason for every triggered event and is specified in the [EventHandlers.MessengerEvent.messengerAction] property.
*/
enum MessengerAction {
/**
* @hidden
*/
UNKNOWN = "UNKNOWN",
createConversation = "createConversation",
editConversation = "editConversation",
/**
* @hidden
*/
removeConversation = "removeConversation",
joinConversation = "joinConversation",
leaveConversation = "leaveConversation",
getConversation = "getConversation",
getConversations = "getConversations",
getPublicConversations = "getPublicConversations",
/**
* @hidden
*/
searchConversations = "searchConversations",
/**
* @hidden
*/
removeEmptyConversation = "removeEmptyConversation",
addParticipants = "addParticipants",
editParticipants = "editParticipants",
removeParticipants = "removeParticipants",
getUser = "getUser",
getUsers = "getUsers",
editUser = "editUser",
setStatus = "setStatus",
sendMessage = "sendMessage",
editMessage = "editMessage",
removeMessage = "removeMessage",
typingMessage = "typingMessage",
isRead = "isRead",
subscribe = "subscribe",
unsubscribe = "unsubscribe",
manageNotification = "manageNotification",
getSubscriptionList = "getSubscriptionList",
/**
* @hidden
*/
createBot = "createBot",
/**
* @hidden
*/
removeBot = "removeBot",
retransmitEvents = "retransmitEvents"
}
/**
* Enum that represents types of messenger events.
* @event
*/
enum MessengerEvents {
/**
* Triggered when any user has created a new conversation with the current user in the participant array.
*/
CreateConversation = "CreateConversation",
/**
* Triggered when conversation the current user belongs to wat modified.
*/
EditConversation = "EditConversation",
/**
* @hidden
* @deprecated
* The conversation is removed.
*/
RemoveConversation = "RemoveConversation",
/**
* Triggered when the [Messenger.getConversation] or [Messenger.getConversations] has been called by the current user.
*/
GetConversation = "GetConversation",
/**
* Triggered when the [Conversation.GetPublicConversations] method has been called by the current user.
*/
GetPublicConversations = "GetPublicConversations",
/**
* Triggered when a new message has been sent to a conversation via the [Conversation.sendMessage] method by any conversation participant.
*/
SendMessage = "SendMessage",
/**
* Triggered when a message has been edited via the [Message.update] method by any conversation participant.
*/
EditMessage = "EditMessage",
/**
* Triggered when a message has been removed via the [Message.remove] method by any conversation participant.
*/
RemoveMessage = "RemoveMessage",
/**
* Triggered when any participant of a conversation the current user belongs to has called the [Conversation.typing] method.
*/
Typing = "Typing",
/**
* Triggered when the information about the user which the current user is subscribed to or the information about the current user has been changed via the [Messenger.editUser] method.
*/
EditUser = "EditUser",
/**
* Triggered when the [Messenger.getUser], [Messenger.getUsers], [Messenger.getUserById] or [Messenger.getUsersById] method has been called by the current user.
*/
GetUser = "GetUser",
/**
* Triggered when error occurs. Refer to the error codes in the [MessengerError] enum.
*/
Error = "Error",
/**
* Triggered when the [Conversation.retransmitEvents] method has been called by the current user.
*/
RetransmitEvents = "RetransmitEvents",
/**
* Triggered when any participant of a conversation the current user belongs to called the [Conversation.markAsRead] method.
*/
Read = "Read",
/**
* Triggered when the [Messenger.subscribe] method has been called by the current user.
*/
Subscribe = "Subscribe",
/**
* Triggered when the [Messenger.unsubscribe] method has been called by the current user.
*/
Unsubscribe = "Unsubscribe",
/**
* Triggered when any user the current user is subscribed to or the current user called the [Messenger.setStatus] method.
*/
SetStatus = "SetStatus",
/**
* Triggered when the [Messenger.getSubscriptionList] method has been called by the current user.
*/
GetSubscriptionList = "GetSubscriptionList",
/**
* @hidden
*/
CreateBot = "CreateBot",
/**
* @hidden
*/
RemoveBot = "RemoveBot"
}
enum MessengerError {
/**
* Something went wrong. Please check the input or required parameters.
*/
Error_0 = 0,
/**
* Transport message structure is wrong. From GW.
*/
Error_1 = 1,
/**
* Event name is unknown.
*/
Error_2 = 2,
/**
* User is not authorized. From GW.
*/
Error_3 = 3,
/**
* Conversation does not exist.
*/
Error_8 = 8,
/**
* Message with this UUID does not exist in the conversation.
*/
Error_10 = 10,
/**
* Message with this UUID is deleted from the conversation.
*/
Error_11 = 11,
/**
* ACL error.
*/
Error_12 = 12,
/**
* User is already in the participants list.
*/
Error_13 = 13,
/**
* Public join is not available for this conversation.
*/
Error_15 = 15,
/**
* Conversation with this UUID is deleted.
*/
Error_16 = 16,
/**
* User validation error.
*/
Error_18 = 18,
/**
* User is not in the participants list.
*/
Error_19 = 19,
/**
* Number of requested objects is 0 or larger than allowed by the service.
*/
Error_21 = 21,
/**
* Number of requested objects is larger than allowed by the service.
*/
Error_22 = 22,
/**
* Message size exceeds the limit of 5000 symbols.
*/
Error_23 = 23,
/**
* The 'seq' parameter value is greater than currently possible.
*/
Error_24 = 24,
/**
* User is not found.
*/
Error_25 = 25,
/**
* The notification event is incorrect.
*/
Error_26 = 26,
/**
* The 'from' field value is greater than the 'to' field value.
*/
Error_28 = 28,
/**
* Messaging service is not available. Try again later. From GW.
*/
Error_30 = 30,
/**
* N messages per second limit reached. Please try again later. From GW.
*/
Error_32 = 32,
/**
* N messages per minute limit reached. Please try again later. From GW.
*/
Error_33 = 33,
/**
* Direct conversation cannot be public or uber.
*/
Error_34 = 34,
/**
* Direct conversation is allowed between two users only.
*/
Error_35 = 35,
/**
* Passing the 'eventsFrom', 'eventsTo' and 'count' parameters simultaneously is not allowed. You should use only two of them.
*/
Error_36 = 36,
/**
* Adding participant to a direct conversation is not allowed.
*/
Error_37 = 37,
/**
* Removing participant from a direct conversation is not allowed.
*/
Error_38 = 38,
/**
* Joining a direct conversation is not allowed.
*/
Error_39 = 39,
/**
* Leaving a direct conversation is not allowed.
*/
Error_40 = 40,
/**
* Specify at least two parameters: eventsFrom, eventsTo or count.
*/
Error_41 = 41,
/**
* Current messaging tier has been exceeded.
*/
Error_42 = 42,
/**
* Messaging tier is being upgraded. Please try again later.
*/
Error_43 = 43,
/**
* The legacy format is not supported
*/
Error_44 = 44,
/**
* Internal error.
*/
Error_500 = 500,
/**
* Invalid argument(s).
*/
Error_10001 = 10001,
/**
* Response timeout.
*/
Error_10002 = 10002
}
module EventHandlers {
/**
* Interface that represents all messenger events which are passed
* - as a resolve value by all [Messenger], [Conversation] and [Message] methods that return a Promise
* - as an argument to a callback function registered via the [Messenger.on] method
*/
interface MessengerEvent {
/**
* Messaging user id of the user that initiated the event.
*/
initiator: number;
/**
* [MessengerAction] which is the reason the event has been triggered.
*/
messengerAction: MessengerAction;
/**
* Optional. Messenger request UUID.
* There's no requestUuid only in [EventHandlers.RetransmittedEvent] and in [EventHandlers.ErrorEvent] when the actual request has not been made due to an invalid payload.