Skip to content

Commit

Permalink
fix: create conversation was sending the request incorrectly (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck authored Nov 12, 2024
1 parent 5ab39f8 commit 4b81d74
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
41 changes: 40 additions & 1 deletion packages/conversations/__tests__/__dataSets__/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export default [
callback: {
url: conversationToCreate?.callback?.url,
event_mask: conversationToCreate?.callback?.eventMask,
params: conversationToCreate?.callback?.params,
params:{
applicationId: conversationToCreate?.callback?.params?.applicationId,
ncco_url: conversationToCreate?.callback?.params?.nccoUrl,
},
method: conversationToCreate?.callback?.method,
},
} as CreateConversationRequest,
Expand Down Expand Up @@ -109,4 +112,40 @@ export default [
error: false,
expected: event,
},
{
label: 'create conversation with callback',
requests: [
[
'/v1/conversations',
'POST',
{
name: conversationToCreate.name,
display_name: conversationToCreate.displayName,
image_url: conversationToCreate.imageUrl,
properties: {
ttl: conversationToCreate?.properties?.ttl,
type: conversationToCreate?.properties?.type,
custom_sort_key: conversationToCreate?.properties?.customSortKey,
custom_data: conversationToCreate?.properties?.customData,
},
numbers: conversationToCreate?.numbers,
callback: {
url: conversationToCreate?.callback?.url,
event_mask: conversationToCreate?.callback?.eventMask,
params: {
applicationId: conversationToCreate?.callback?.params?.applicationId,
ncco_url: conversationToCreate?.callback?.params?.nccoUrl,
},
method: conversationToCreate?.callback?.method,
},
} as CreateConversationRequest,
],
],
responses: [[200, conversationResponse]],
clientMethod: 'createConversation',
parameters: [conversationToCreate],
generator: false,
error: false,
expected: conversation,
},
];
5 changes: 4 additions & 1 deletion packages/conversations/__tests__/__dataSets__/put.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export default [
callback: {
url: conversationToCreate?.callback?.url,
event_mask: conversationToCreate?.callback?.eventMask,
params: conversationToCreate?.callback?.params,
params: {
applicationId: conversationToCreate?.callback?.params?.applicationId,
ncco_url: conversationToCreate?.callback?.params?.nccoUrl,
},
method: conversationToCreate?.callback?.method,
},
} as CreateConversationRequest,
Expand Down
5 changes: 4 additions & 1 deletion packages/conversations/__tests__/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export const conversationToCreate = Object.freeze({
callback: {
url: 'https://example.com/callback',
eventMask: EventType.AUDIO_PLAY,
params: {},
params: {
applicationId: 'APP-00000000-0000-0000-0000-000000000001',
nccoUrl: 'https://example.com/ncco',
},
method: 'POST',
}
}) as Conversation;
Expand Down
7 changes: 7 additions & 0 deletions packages/conversations/lib/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ const conversationToApi = (
apiConversation.properties.custom_data = customData;
}

if (conversation?.callback?.params?.applicationId && apiConversation?.callback?.params) {
apiConversation.callback.params = {
applicationId: conversation.callback.params.applicationId,
ncco_url: conversation.callback.params.nccoUrl,
};
}

return apiConversation;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export type ConversationCallbackRequest = {
/**
* The application ID for the callback.
*/
application_id: string;
applicationId?: string;

/**
* The NCCO URL for the callback.
*/
ncco_url: string;
ncco_url?: string;
};

/**
Expand Down

0 comments on commit 4b81d74

Please sign in to comment.