@vonage/voice
Version:
The Voice API lets you create outbound calls, control in-progress calls and get information about historical calls.
121 lines (119 loc) • 3.35 kB
JavaScript
;
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/Input.ts
var Input_exports = {};
__export(Input_exports, {
Input: () => Input
});
module.exports = __toCommonJS(Input_exports);
var Input = class {
/**
* The action type, which is always 'input'.
*/
action = "input" /* INPUT */;
/**
* An array of input types ('dtmf' and/or 'speech').
*/
type = [];
/**
* DTMF input settings.
*/
dtmf;
/**
* Speech input settings.
*/
speech;
/**
* An array of URLs to send events to asynchronously.
*/
eventUrl = [];
/**
* The HTTP method used to send events (e.g., 'POST' or 'GET').
*/
eventMethod;
/**
* Input processing mode, currently only applicable to DTMF. Valid values are
* synchronous (the default) and asynchronous. If set to asynchronous, all
* DTMF settings must be left blank. In asynchronous mode, digits are sent one
* at a time to the event webhook in real time. In the default synchronous
* mode, this is controlled by the DTMF settings instead and the inputs are
* sent in batch.
*/
mode;
/**
* Create a new Input instance.
*
* @param {DTMFSettings} dtmf - DTMF input settings.
* @param {SpeechSettings} speech - Speech input settings.
* @param {string} eventUrl - URL to send events to asynchronously.
* @param {string} eventMethod - The HTTP method used to send events.
*/
constructor(dtmf, speech, eventUrl, eventMethod, mode) {
if (dtmf) {
this.type.push("dtmf");
this.dtmf = dtmf;
}
if (speech) {
this.type.push("speech");
this.speech = speech;
}
if (eventUrl) {
this.eventUrl = [eventUrl];
}
if (eventMethod) {
this.eventMethod = eventMethod;
}
if (mode) {
this.mode = mode;
}
if (this.type.length === 0) {
throw new TypeError(
"Input action must have at least either DTMF or Speech settings"
);
}
}
/**
* Serialize the Input action to a Nexmo Call Control Object (NCCO) format.
*
* @return {InputAction} - The serialized Input action.
*/
serializeToNCCO() {
const data = {
action: "input" /* INPUT */,
type: this.type
};
if (this.dtmf) {
data.dtmf = this.dtmf;
}
if (this.speech) {
data.speech = this.speech;
}
if (this.eventUrl) {
data.eventUrl = this.eventUrl;
}
if (this.eventMethod) {
data.eventMethod = this.eventMethod;
}
return data;
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Input
});