@cognigy/rest-api-client
Version:
Cognigy REST-Client
63 lines • 2.03 kB
JavaScript
/* Custom modules */
import { BaseMapper } from "./base.mapper";
export class MuteSpeechInputMapper extends BaseMapper {
handleInput(input, api, isGenericNode = false) {
try {
switch (this.endpointType) {
case "bandwidth": {
const output = this.handleBandwidthInput(input, api);
return this.buildPayload(output);
}
case "audioCodes": {
const output = this.handleAudioCodesInput(input, api);
return this.buildPayload(output);
}
case "voiceGateway2":
default: {
const output = this.handleVGInput(input, api);
return this.buildPayload(output);
}
}
}
catch (err) {
const errorMessage = `Error in MuteSpeechInputMapper handleInput: ${err.message}`;
if (typeof api.log === "function") {
api.log("error", errorMessage);
}
throw Error(errorMessage);
}
}
handleVGInput(input, api) {
const { muteSpeechInput = false, muteDtmfInput = false } = input;
const output = {
channelConfig: {
mute: {
muteSpeechInput,
muteDtmfInput
}
}
};
return output;
}
handleAudioCodesInput(input, api) {
const { muteSpeechInput = false } = input;
return {
type: "event",
name: "config",
sessionParams: {
enableSpeechInput: !muteSpeechInput
}
};
}
handleBandwidthInput(input, api) {
const { muteSpeechInput = false } = input;
return {
type: "event",
name: "config",
sessionParams: {
enableSpeechInput: !muteSpeechInput
}
};
}
}
//# sourceMappingURL=muteSpeechInput.mapper.js.map