UNPKG

@vonage/voice

Version:

The Voice API lets you create outbound calls, control in-progress calls and get information about historical calls.

153 lines (151 loc) 4.76 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // lib/classes/NCCO/Conversation.ts var Conversation_exports = {}; __export(Conversation_exports, { Conversation: () => Conversation }); module.exports = __toCommonJS(Conversation_exports); var Conversation = class { /** * The action type, which is always 'conversation'. */ action = "conversation" /* CONVERSATION */; /** * The name of the conversation. * * @param {string} name - The name of the conversation. */ name; /** * An array of URLs for music to be played while participants are on hold. * * @param {string[]} musicOnHoldUrl - An array of music on hold URLs. */ musicOnHoldUrl; /** * Set to true to start the conversation when a participant enters. * * @param {boolean} startOnEnter - Set to true to start the conversation on participant enter. */ startOnEnter; /** * Set to true to end the conversation when the last participant exits. * * @param {boolean} endOnExit - Set to true to end the conversation on last participant exit. */ endOnExit; /** * Set to true to record the conversation. * * @param {boolean} record - Set to true to record the conversation. */ record; /** * An array of participant IDs (e.g., phone numbers) who can speak in the conversation. * * @param {string[]} canSpeak - An array of participant IDs who can speak in the conversation. */ canSpeak; /** * An array of participant IDs (e.g., phone numbers) who can hear in the conversation. * * @param {string[]} canHear - An array of participant IDs who can hear in the conversation. */ canHear; /** * Set to true to mute all participants in the conversation. * * @param {boolean} mute - Set to true to mute all participants in the conversation. */ mute; /** * Create a new Conversation instance. * * @param {string} name - The name of the conversation. * @param {string} musicOnHoldUrl - An array of music on hold URLs. * @param {boolean} startOnEnter - Set to true to start the conversation on participant enter. * @param {boolean} endOnExit - Set to true to end the conversation on last participant exit. * @param {boolean} record - Set to true to record the conversation. * @param {string[]} canSpeak - An array of participant IDs who can speak in the conversation. * @param {string[]} canHear - An array of participant IDs who can hear in the conversation. * @param {boolean} mute - Set to true to mute all participants in the conversation. */ constructor(name, musicOnHoldUrl, startOnEnter, endOnExit, record, canSpeak, canHear, mute) { this.name = name; if (musicOnHoldUrl) { this.musicOnHoldUrl = [musicOnHoldUrl]; } if (startOnEnter) { this.startOnEnter = startOnEnter; } if (endOnExit) { this.endOnExit = endOnExit; } if (record) { this.record = record; } if (canSpeak) { this.canSpeak = canSpeak; } if (canHear) { this.canHear = canHear; } if (mute) { this.mute = mute; } } /** * Serialize the Conversation action to a Nexmo Call Control Object (NCCO) format. * * @return {ConversationAction} - The serialized Conversation action. */ serializeToNCCO() { const data = { action: "conversation" /* CONVERSATION */, name: this.name }; if (this.musicOnHoldUrl) { data.musicOnHoldUrl = this.musicOnHoldUrl; } if (this.startOnEnter) { data.startOnEnter = this.startOnEnter; } if (this.endOnExit) { data.endOnExit = this.endOnExit; } if (this.record) { data.record = this.record; } if (this.canSpeak) { data.canSpeak = this.canSpeak; } if (this.canHear) { data.canHear = this.canHear; } if (this.mute) { data.mute = this.mute; } return data; } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Conversation });