Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions models/bxml/verbs/Connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Endpoint } from './Endpoint';

export interface ConnectAttributes {
eventCallbackUrl?: string;
eventFallbackUrl?: string;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions models/bxml/verbs/Forward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export interface ForwardAttributes {
diversionTreatment?: string;
diversionReason?: string;
uui?: string;
privacy?: boolean;
callerDisplayName?: string;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions models/bxml/verbs/Gather.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ export interface GatherAttributes {
interDigitTimeout?: number;
firstDigitTimeout?: number;
repeatCount?: number;
input?: string;
hints?: string;
language?: string;
partialResultCallback?: string;
partialResultCallbackMethod?: string;
profanityFilter?: boolean;
speechModel?: string;
speechTimeout?: number;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions models/bxml/verbs/Record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface RecordAttributes {
maxDuration?: number;
silenceTimeout?: number;
fileFormat?: string;
detectLanguage?: boolean;
recordingName?: string;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions models/bxml/verbs/StartRecording.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface StartRecordingAttributes {
tag?: string;
fileFormat?: string;
multiChannel?: boolean;
detectLanguage?: boolean;
recordingName?: string;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions models/bxml/verbs/StartTranscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export interface StartTranscriptionAttributes {
password?: string
destination?: string;
stabilized?: boolean;
detectLanguage?: boolean;
preferredLanguages?: string;
}

/**
Expand Down
1 change: 1 addition & 0 deletions models/bxml/verbs/Transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface TransferAttributes {
tag?: string;
diversionTreatment?: string;
diversionReason?: string;
privacy?: boolean;
}

/**
Expand Down
31 changes: 24 additions & 7 deletions tests/smoke/bxml.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,15 @@ describe('BXML Integration Tests', () => {
maxDigits: 1,
interDigitTimeout: 1.1,
firstDigitTimeout: 1.1,
repeatCount: 1
repeatCount: 1,
input: 'dtmf_speech',
hints: 'yes, no',
language: 'en-US',
partialResultCallback: 'https://initial.com',
partialResultCallbackMethod: 'POST',
profanityFilter: true,
speechModel: 'default',
speechTimeout: 2
};

const speakSentenceAttributes: SpeakSentenceAttributes = {
Expand All @@ -99,7 +107,9 @@ describe('BXML Integration Tests', () => {
terminatingDigits: '#',
maxDuration: 2,
silenceTimeout: 2,
fileFormat: 'wav'
fileFormat: 'wav',
detectLanguage: true,
recordingName: 'initialRecordingName'
};

const sendDtmfAttributes: SendDtmfAttributes = {
Expand Down Expand Up @@ -130,7 +140,7 @@ describe('BXML Integration Tests', () => {

const transferAttributes: TransferAttributes = {
transferCallerId: '+19195551234',
transferCallerDisplayName: 'initialDisplayName',
transferCallerDisplayName: 'Anonymous',
callTimeout: 5,
transferCompleteUrl: 'https://initial.com',
transferCompleteMethod: 'POST',
Expand All @@ -142,7 +152,8 @@ describe('BXML Integration Tests', () => {
fallbackPassword: 'initialFallbackPassword',
tag: 'initialTag',
diversionTreatment: 'propagate',
diversionReason: 'user-busy'
diversionReason: 'user-busy',
privacy: true
};

const phoneNumber = new Bxml.PhoneNumber('+19195551234');
Expand Down Expand Up @@ -197,7 +208,9 @@ describe('BXML Integration Tests', () => {
password: 'initialPassword',
tag: 'initialTag',
fileFormat: 'wav',
multiChannel: true
multiChannel: true,
detectLanguage: true,
recordingName: 'initialRecordingName'
};

const startStreamAttributes: StartStreamAttributes = {
Expand All @@ -218,7 +231,9 @@ describe('BXML Integration Tests', () => {
username: 'initialUsername',
password: 'initialPassword',
destination: 'wss://initial.com',
stabilized: true
stabilized: true,
detectLanguage: false,
preferredLanguages: 'en-US,fr-FR'
};

const stopStreamAttributes: StopStreamAttributes = {
Expand Down Expand Up @@ -267,7 +282,9 @@ describe('BXML Integration Tests', () => {
callTimeout: 5,
diversionTreatment: 'propagate',
diversionReason: 'user-busy',
uui: '93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt'
uui: '93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt',
privacy: true,
callerDisplayName: 'Anonymous'
};

const forward = new Bxml.Forward(forwardAttributes);
Expand Down
11 changes: 6 additions & 5 deletions tests/unit/models/bxml/verbs/Connect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { Endpoint } from '../../../../../models/bxml/verbs/Endpoint';

describe('Connect', () => {
const attributes: ConnectAttributes = {
eventCallbackUrl: 'https://example.com/events'
eventCallbackUrl: 'https://example.com/events',
eventFallbackUrl: 'https://example.com/fallback'
};

const endpoint = new Endpoint('ep-123456');

test('should create a Connect Verb', () => {
const connect = new Connect(attributes);
const expected = '<Connect eventCallbackUrl="https://example.com/events"/>';
const expected = '<Connect eventCallbackUrl="https://example.com/events" eventFallbackUrl="https://example.com/fallback"/>';

expect(connect).toBeInstanceOf(Connect);
expect(connect).toBeInstanceOf(Verb);
Expand All @@ -20,7 +21,7 @@ describe('Connect', () => {

test('should create a Connect Verb with nested Endpoint', () => {
const connect = new Connect(attributes, endpoint);
const expected = '<Connect eventCallbackUrl="https://example.com/events"><Endpoint>ep-123456</Endpoint></Connect>';
const expected = '<Connect eventCallbackUrl="https://example.com/events" eventFallbackUrl="https://example.com/fallback"><Endpoint>ep-123456</Endpoint></Connect>';

expect(connect).toBeInstanceOf(Connect);
expect(connect).toBeInstanceOf(Verb);
Expand All @@ -30,7 +31,7 @@ describe('Connect', () => {
test('should create a Connect Verb with multiple nested Endpoints', () => {
const endpoint2 = new Endpoint('ep-789012');
const connect = new Connect(attributes, [endpoint, endpoint2]);
const expected = '<Connect eventCallbackUrl="https://example.com/events"><Endpoint>ep-123456</Endpoint><Endpoint>ep-789012</Endpoint></Connect>';
const expected = '<Connect eventCallbackUrl="https://example.com/events" eventFallbackUrl="https://example.com/fallback"><Endpoint>ep-123456</Endpoint><Endpoint>ep-789012</Endpoint></Connect>';

expect(connect).toBeInstanceOf(Connect);
expect(connect).toBeInstanceOf(Verb);
Expand All @@ -39,7 +40,7 @@ describe('Connect', () => {

test('should test the addEndpoints method when no verbs are initially nested', () => {
const connect = new Connect(attributes);
const expected = '<Connect eventCallbackUrl="https://example.com/events"><Endpoint>ep-123456</Endpoint></Connect>';
const expected = '<Connect eventCallbackUrl="https://example.com/events" eventFallbackUrl="https://example.com/fallback"><Endpoint>ep-123456</Endpoint></Connect>';

connect.addEndpoints(endpoint);
expect(connect.toBxml()).toBe(expected);
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/models/bxml/verbs/Forward.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ describe('Forward', () => {
callTimeout: 5,
diversionTreatment: 'propagate',
diversionReason: 'user-busy',
uui: '93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt'
uui: '93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt',
privacy: true,
callerDisplayName: 'Anonymous'
};

const expected = '<Forward to="+19195551234" from="+19195554321" callTimeout="5" diversionTreatment="propagate" diversionReason="user-busy" uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt"/>';
const expected = '<Forward to="+19195551234" from="+19195554321" callTimeout="5" diversionTreatment="propagate" diversionReason="user-busy" uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt" privacy="true" callerDisplayName="Anonymous"/>';

test('should create a Forward Verb', () => {
const forward = new Forward(attributes);
Expand Down
20 changes: 14 additions & 6 deletions tests/unit/models/bxml/verbs/Gather.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@ describe('Gather', () => {
maxDigits: 5,
interDigitTimeout: 5,
firstDigitTimeout: 5,
repeatCount: 5
repeatCount: 5,
input: 'dtmf_speech',
hints: 'yes,no',
language: 'en-US',
partialResultCallback: 'https://initial.com',
partialResultCallbackMethod: 'POST',
profanityFilter: true,
speechModel: 'default',
speechTimeout: 5
};

const playAudio = new PlayAudio('https://audio.url/audio1.wav');
const speakSentence = new SpeakSentence('<lang xml:lang="es-MX">Hola</lang>nodejs speak sentence <emphasis>SSML test</emphasis>');

test('should create a Gather Verb', () => {
const gather = new Gather(attributes);
const expected = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5"/>';
const expected = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5" input="dtmf_speech" hints="yes,no" language="en-US" partialResultCallback="https://initial.com" partialResultCallbackMethod="POST" profanityFilter="true" speechModel="default" speechTimeout="5"/>';

expect(gather).toBeInstanceOf(Gather);
expect(gather).toBeInstanceOf(Verb);
Expand All @@ -35,9 +43,9 @@ describe('Gather', () => {

test('should create a Gather Verb with nested PlayAudio and SpeakSentence', () => {
let gather = new Gather(attributes, playAudio);
const expected = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5"><PlayAudio>https://audio.url/audio1.wav</PlayAudio></Gather>';
const expectedSingle = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5"><PlayAudio>https://audio.url/audio1.wav</PlayAudio><SpeakSentence><lang xml:lang="es-MX">Hola</lang>nodejs speak sentence <emphasis>SSML test</emphasis></SpeakSentence></Gather>';
const expectedMultiple = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5"><PlayAudio>https://audio.url/audio1.wav</PlayAudio><SpeakSentence><lang xml:lang="es-MX">Hola</lang>nodejs speak sentence <emphasis>SSML test</emphasis></SpeakSentence><SpeakSentence><lang xml:lang="es-MX">Hola</lang>nodejs speak sentence <emphasis>SSML test</emphasis></SpeakSentence><PlayAudio>https://audio.url/audio1.wav</PlayAudio></Gather>';
const expected = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5" input="dtmf_speech" hints="yes,no" language="en-US" partialResultCallback="https://initial.com" partialResultCallbackMethod="POST" profanityFilter="true" speechModel="default" speechTimeout="5"><PlayAudio>https://audio.url/audio1.wav</PlayAudio></Gather>';
const expectedSingle = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5" input="dtmf_speech" hints="yes,no" language="en-US" partialResultCallback="https://initial.com" partialResultCallbackMethod="POST" profanityFilter="true" speechModel="default" speechTimeout="5"><PlayAudio>https://audio.url/audio1.wav</PlayAudio><SpeakSentence><lang xml:lang="es-MX">Hola</lang>nodejs speak sentence <emphasis>SSML test</emphasis></SpeakSentence></Gather>';
const expectedMultiple = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5" input="dtmf_speech" hints="yes,no" language="en-US" partialResultCallback="https://initial.com" partialResultCallbackMethod="POST" profanityFilter="true" speechModel="default" speechTimeout="5"><PlayAudio>https://audio.url/audio1.wav</PlayAudio><SpeakSentence><lang xml:lang="es-MX">Hola</lang>nodejs speak sentence <emphasis>SSML test</emphasis></SpeakSentence><SpeakSentence><lang xml:lang="es-MX">Hola</lang>nodejs speak sentence <emphasis>SSML test</emphasis></SpeakSentence><PlayAudio>https://audio.url/audio1.wav</PlayAudio></Gather>';

expect(gather).toBeInstanceOf(Gather);
expect(gather).toBeInstanceOf(Verb);
Expand All @@ -52,7 +60,7 @@ describe('Gather', () => {

test('should test the addAudioVerbs method when no verbs are initially nested', () => {
const gather = new Gather(attributes);
const expected = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5"><PlayAudio>https://audio.url/audio1.wav</PlayAudio></Gather>';
const expected = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5" input="dtmf_speech" hints="yes,no" language="en-US" partialResultCallback="https://initial.com" partialResultCallbackMethod="POST" profanityFilter="true" speechModel="default" speechTimeout="5"><PlayAudio>https://audio.url/audio1.wav</PlayAudio></Gather>';

gather.addAudioVerbs(playAudio);
expect(gather.toBxml()).toBe(expected);
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/models/bxml/verbs/Record.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ describe('Record', () => {
terminatingDigits: '5',
maxDuration: 5,
silenceTimeout: 5,
fileFormat: 'wav'
fileFormat: 'wav',
detectLanguage: true,
recordingName: 'initialRecordingName'
};

const expected = '<Record recordCompleteUrl="https://initial.com" recordCompleteMethod="POST" recordCompleteFallbackUrl="https://initial.com" recordCompleteFallbackMethod="POST" recordingAvailableUrl="https://initial.com" recordingAvailableMethod="POST" transcribe="true" transcriptionAvailableUrl="https://initial.com" transcriptionAvailableMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDuration="5" silenceTimeout="5" fileFormat="wav"/>';
const expected = '<Record recordCompleteUrl="https://initial.com" recordCompleteMethod="POST" recordCompleteFallbackUrl="https://initial.com" recordCompleteFallbackMethod="POST" recordingAvailableUrl="https://initial.com" recordingAvailableMethod="POST" transcribe="true" transcriptionAvailableUrl="https://initial.com" transcriptionAvailableMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDuration="5" silenceTimeout="5" fileFormat="wav" detectLanguage="true" recordingName="initialRecordingName"/>';

test('should create a Record Verb', () => {
const record = new Record(attributes);
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/models/bxml/verbs/StartRecording.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ describe('StartRecording', () => {
password: 'initialPassword',
tag: 'initialTag',
fileFormat: 'wav',
multiChannel: true
multiChannel: true,
detectLanguage: true,
recordingName: 'initialRecordingName'
};

const expected = '<StartRecording recordingAvailableUrl="https://initial.com" recordingAvailableMethod="POST" transcribe="true" transcriptionAvailableUrl="https://initial.com" transcriptionAvailableMethod="POST" username="initialUsername" password="initialPassword" tag="initialTag" fileFormat="wav" multiChannel="true"/>';
const expected = '<StartRecording recordingAvailableUrl="https://initial.com" recordingAvailableMethod="POST" transcribe="true" transcriptionAvailableUrl="https://initial.com" transcriptionAvailableMethod="POST" username="initialUsername" password="initialPassword" tag="initialTag" fileFormat="wav" multiChannel="true" detectLanguage="true" recordingName="initialRecordingName"/>';

test('should create a StartRecording Verb', () => {
const startRecording = new StartRecording(attributes);
Expand Down
Loading