Skip to content

Commit

Permalink
fix(voice): ncco encoding (#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck authored Jan 23, 2024
1 parent aec47d6 commit 9f2cfc8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
20 changes: 20 additions & 0 deletions packages/voice/__tests__/__dataSets__/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ export default [
{
action: NCCOActions.TALK,
text: "I'll always dial the K for you",
bargeIn: false,
},
{
payload: {
room_name: 'my-room',
id: 'CON-00000000-0000-0000-0000-000000000000',
},
eventUrl: ['https://example.com/event'],
eventMethod: 'POST',
action: 'notify',
},
],
random_from_number: false,
Expand Down Expand Up @@ -80,6 +90,16 @@ export default [
{
action: NCCOActions.TALK,
text: "I'll always dial the K for you",
bargeIn: false,
},
{
payload: {
room_name: 'my-room',
id: 'CON-00000000-0000-0000-0000-000000000000',
},
eventUrl: ['https://example.com/event'],
eventMethod: 'POST',
action: 'notify',
},
],
randomFromNumber: false,
Expand Down
9 changes: 7 additions & 2 deletions packages/voice/lib/voice.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AuthenticationType, Client, FileClient } from '@vonage/server-client';
import { NCCOActions } from './enums';
import {
GetCallDetailsParameters,
CallPageResponse,
Expand All @@ -12,6 +11,7 @@ import {
Action,
TalkAction,
OutboundCall,
CallWithNCCO,
} from './types';

import { ResponseTypes } from '@vonage/vetch';
Expand Down Expand Up @@ -237,9 +237,14 @@ export class Voice extends Client {
* ```
*/
async createOutboundCall(call: OutboundCall): Promise<CallResult> {
const callRequest = Client.transformers.snakeCaseObjectKeys(call, true);
if ((call as CallWithNCCO).ncco) {
callRequest.ncco = (call as CallWithNCCO).ncco;
}

const resp = await this.sendPostRequest<CreateCallResponse>(
`${this.config.apiHost}/v1/calls`,
Client.transformers.snakeCaseObjectKeys(call, true),
callRequest,
);
const result = Client.transformers.camelCaseObjectKeys(
resp.data,
Expand Down

0 comments on commit 9f2cfc8

Please sign in to comment.