Skip to content

Commit 9f2cfc8

Browse files
authored
fix(voice): ncco encoding (#906)
1 parent aec47d6 commit 9f2cfc8

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

packages/voice/__tests__/__dataSets__/create.ts

+20
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ export default [
3636
{
3737
action: NCCOActions.TALK,
3838
text: "I'll always dial the K for you",
39+
bargeIn: false,
40+
},
41+
{
42+
payload: {
43+
room_name: 'my-room',
44+
id: 'CON-00000000-0000-0000-0000-000000000000',
45+
},
46+
eventUrl: ['https://example.com/event'],
47+
eventMethod: 'POST',
48+
action: 'notify',
3949
},
4050
],
4151
random_from_number: false,
@@ -80,6 +90,16 @@ export default [
8090
{
8191
action: NCCOActions.TALK,
8292
text: "I'll always dial the K for you",
93+
bargeIn: false,
94+
},
95+
{
96+
payload: {
97+
room_name: 'my-room',
98+
id: 'CON-00000000-0000-0000-0000-000000000000',
99+
},
100+
eventUrl: ['https://example.com/event'],
101+
eventMethod: 'POST',
102+
action: 'notify',
83103
},
84104
],
85105
randomFromNumber: false,

packages/voice/lib/voice.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { AuthenticationType, Client, FileClient } from '@vonage/server-client';
2-
import { NCCOActions } from './enums';
32
import {
43
GetCallDetailsParameters,
54
CallPageResponse,
@@ -12,6 +11,7 @@ import {
1211
Action,
1312
TalkAction,
1413
OutboundCall,
14+
CallWithNCCO,
1515
} from './types';
1616

1717
import { ResponseTypes } from '@vonage/vetch';
@@ -237,9 +237,14 @@ export class Voice extends Client {
237237
* ```
238238
*/
239239
async createOutboundCall(call: OutboundCall): Promise<CallResult> {
240+
const callRequest = Client.transformers.snakeCaseObjectKeys(call, true);
241+
if ((call as CallWithNCCO).ncco) {
242+
callRequest.ncco = (call as CallWithNCCO).ncco;
243+
}
244+
240245
const resp = await this.sendPostRequest<CreateCallResponse>(
241246
`${this.config.apiHost}/v1/calls`,
242-
Client.transformers.snakeCaseObjectKeys(call, true),
247+
callRequest,
243248
);
244249
const result = Client.transformers.camelCaseObjectKeys(
245250
resp.data,

0 commit comments

Comments
 (0)