diff --git a/examples/integrated-flows-examples/src/numbers/app.ts b/examples/integrated-flows-examples/src/numbers/app.ts index 065019f3..501f9321 100644 --- a/examples/integrated-flows-examples/src/numbers/app.ts +++ b/examples/integrated-flows-examples/src/numbers/app.ts @@ -1,12 +1,6 @@ import { SinchClient, - ActiveNumber, - GetActiveNumberRequestData, ListActiveNumbersRequestData, - ListAvailableNumbersRequestData, - ListAvailableRegionsRequestData, - NumberTypeEnum, - RegionNumberTypeEnum, ReleaseNumberRequestData, RentAnyNumberRequestData, - RentNumberRequestData, UpdateActiveNumberRequestData, + Numbers, } from '@sinch/sdk-core'; import dotenv from 'dotenv'; dotenv.config(); @@ -24,15 +18,15 @@ dotenv.config(); const keySecret = process.env.SINCH_KEY_SECRET || ''; const sinchClient = new SinchClient({ projectId, keyId, keySecret }); - const regionType: RegionNumberTypeEnum = 'LOCAL'; - const type: NumberTypeEnum = 'LOCAL'; + const regionType: Numbers.RegionNumberTypeEnum = 'LOCAL'; + const type: Numbers.NumberTypeEnum = 'LOCAL'; console.log('+------------------------------------------------------------------------------+'); console.log('| Step 1: List the available regions and store the first one from the response |'); console.log('+------------------------------------------------------------------------------+'); // Build the request data - const availableRegionsRequestData: ListAvailableRegionsRequestData = { + const availableRegionsRequestData: Numbers.ListAvailableRegionsRequestData = { types: [regionType], }; @@ -64,7 +58,7 @@ dotenv.config(); console.log('+-----------------------------------------------+'); // Build the request data - const listAvailableNumbersRequestData: ListAvailableNumbersRequestData = { + const listAvailableNumbersRequestData: Numbers.ListAvailableNumbersRequestData = { regionCode, type, }; @@ -97,7 +91,7 @@ dotenv.config(); console.log('+-------------------------------+'); // Build the request data - const rentNumberRequestData: RentNumberRequestData = { + const rentNumberRequestData: Numbers.RentNumberRequestData = { phoneNumber: phoneNumber1, rentNumberRequestBody: {}, }; @@ -119,7 +113,7 @@ dotenv.config(); console.log('+------------------------------------------------------------+'); // Build the request data - const rentAnyNumberRequestData: RentAnyNumberRequestData = { + const rentAnyNumberRequestData: Numbers.RentAnyNumberRequestData = { rentAnyNumberRequestBody: { regionCode, type, @@ -150,7 +144,7 @@ dotenv.config(); console.log('+-----------------------------------------------------------------------------------------------+'); // Build the request data - const getActiveNumberRequestData: GetActiveNumberRequestData = { + const getActiveNumberRequestData: Numbers.GetActiveNumberRequestData = { phoneNumber: phoneNumber1, }; @@ -171,13 +165,13 @@ dotenv.config(); console.log('+----------------------------------------------------------------------------------------------+'); // Build the request data - const listActiveNumbersRequestData: ListActiveNumbersRequestData = { + const listActiveNumbersRequestData: Numbers.ListActiveNumbersRequestData = { regionCode, type, }; // The ActiveNumbersResponse is paginated. Let's fetch all the pages using the iterator functionality - const activeNumbersList: ActiveNumber[] = []; + const activeNumbersList: Numbers.ActiveNumber[] = []; for await (const activeNumber of sinchClient.numbers.activeNumber.list(listActiveNumbersRequestData)) { activeNumbersList.push(activeNumber); } @@ -195,9 +189,9 @@ dotenv.config(); console.log('+---------------------------------+'); // Build the request data - const updateActiveNumberRequestData: UpdateActiveNumberRequestData = { + const updateActiveNumberRequestData: Numbers.UpdateActiveNumberRequestData = { phoneNumber: phoneNumber1, - activeNumberRequestBody: { + updateActiveNumberRequestBody: { displayName: 'Sample number 1', }, }; @@ -221,7 +215,7 @@ dotenv.config(); console.log('+---------------------------------------+'); // Build the request data - let releaseActiveNumberRequestData: ReleaseNumberRequestData = { + let releaseActiveNumberRequestData: Numbers.ReleaseNumberRequestData = { phoneNumber: phoneNumber1, }; diff --git a/examples/integrated-flows-examples/src/verification/app.ts b/examples/integrated-flows-examples/src/verification/app.ts index e1a1b4fa..5c3cf202 100644 --- a/examples/integrated-flows-examples/src/verification/app.ts +++ b/examples/integrated-flows-examples/src/verification/app.ts @@ -1,5 +1,5 @@ import inquirer from 'inquirer'; -import { SinchClient, verificationsHelper, VerificationStatusByIdRequestData } from '@sinch/sdk-core'; +import { SinchClient, Verification } from '@sinch/sdk-core'; import dotenv from 'dotenv'; dotenv.config(); @@ -54,7 +54,7 @@ dotenv.config(); }); const startSmsVerificationFlow = async (phoneNumber: string) => { - const requestData = verificationsHelper.buildStartSmsVerificationRequest(phoneNumber); + const requestData = Verification.startVerificationHelper.buildSmsRequest(phoneNumber); const response = await sinch.verification.verifications.startSms(requestData); console.log('Verification request sent! Please check the SMS on your you phone to get the OTP.'); const answers = await inquirer.prompt([ @@ -64,7 +64,7 @@ dotenv.config(); message: 'Enter the verification code:', }, ]); - const reportRequestData = verificationsHelper.buildReportSmsVerificationByIdRequest( + const reportRequestData = Verification.reportVerificationByIdHelper.buildSmsRequest( response.id!, answers.code); const reportResponse = await sinch.verification.verifications.reportSmsById(reportRequestData); console.log(`Verification status: ${reportResponse.status}${reportResponse.status === 'SUCCESSFUL' ? '' : ' - Reason: ' + reportResponse.reason}`); @@ -73,7 +73,7 @@ dotenv.config(); }; const startCalloutVerificationFlow = async (phoneNumber: string) => { - const requestData = verificationsHelper.buildStartCalloutVerificationRequest(phoneNumber); + const requestData = Verification.startVerificationHelper.buildCalloutRequest(phoneNumber); const response = await sinch.verification.verifications.startCallout(requestData); console.log('Verification request sent! Please answer to the phone call ans listen to the OTP.'); const answers = await inquirer.prompt([ @@ -83,14 +83,14 @@ dotenv.config(); message: 'Enter the verification code:', }, ]); - const reportRequestData = verificationsHelper.buildReportCalloutVerificationByIdRequest( + const reportRequestData = Verification.reportVerificationByIdHelper.buildCalloutRequest( response.id!, answers.code); const reportResponse = await sinch.verification.verifications.reportCalloutById(reportRequestData); console.log(`Verification status: ${reportResponse.status}${reportResponse.status === 'SUCCESSFUL'?'':' - Reason: ' + reportResponse.reason}`); }; const startFlashCallVerificationFlow = async (phoneNumber: string) => { - const requestData = verificationsHelper.buildStartFlashCallVerificationRequest(phoneNumber); + const requestData = Verification.startVerificationHelper.buildFlashCallRequest(phoneNumber); const response = await sinch.verification.verifications.startFlashCall(requestData); console.log('Verification request sent! Please check the phone number calling you.'); const answers = await inquirer.prompt([ @@ -100,7 +100,7 @@ dotenv.config(); message: 'Enter the caller ID:', }, ]); - const reportRequestData = verificationsHelper.buildReportFlashCallVerificationByIdRequest( + const reportRequestData = Verification.reportVerificationByIdHelper.buildFlashCallRequest( response.id!, answers.cli, ); @@ -109,7 +109,7 @@ dotenv.config(); }; const startSeamlessVerificationFlow = async (phoneNumber: string) => { - const requestData = verificationsHelper.buildStartSeamlessVerificationRequest(phoneNumber); + const requestData = Verification.startVerificationHelper.buildSeamlessRequest(phoneNumber); let response; try { response = await sinch.verification.verifications.startSeamless(requestData); @@ -117,7 +117,7 @@ dotenv.config(); console.log(`Impossible to process the seamless verification: ${error.data})`); return; } - const verificationStatusRequestData: VerificationStatusByIdRequestData = { + const verificationStatusRequestData: Verification.VerificationStatusByIdRequestData = { id: response.id!, }; const statusResponse = await sinch.verification.verificationStatus.getById(verificationStatusRequestData); diff --git a/examples/simple-examples/src/conversation/app/create.ts b/examples/simple-examples/src/conversation/app/create.ts index d0240dbe..b439d863 100644 --- a/examples/simple-examples/src/conversation/app/create.ts +++ b/examples/simple-examples/src/conversation/app/create.ts @@ -1,4 +1,4 @@ -import { CreateAppRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getMessengerTokenFormConfig, getPrintFormat, @@ -13,7 +13,7 @@ import { const messengerToken = getMessengerTokenFormConfig(); - const requestData: CreateAppRequestData = { + const requestData: Conversation.CreateAppRequestData = { appCreateRequestBody: { display_name: 'New app created with the Node.js SDK', channel_credentials: [ diff --git a/examples/simple-examples/src/conversation/app/delete.ts b/examples/simple-examples/src/conversation/app/delete.ts index 4569f055..00d62c46 100644 --- a/examples/simple-examples/src/conversation/app/delete.ts +++ b/examples/simple-examples/src/conversation/app/delete.ts @@ -1,4 +1,4 @@ -import { DeleteAppRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getAppIdFromConfig, initConversationService, printFullResponse } from ' const appId = getAppIdFromConfig(); - const requestData: DeleteAppRequestData = { + const requestData: Conversation.DeleteAppRequestData = { app_id: appId, }; diff --git a/examples/simple-examples/src/conversation/app/get.ts b/examples/simple-examples/src/conversation/app/get.ts index 1aa02c31..eacccc2e 100644 --- a/examples/simple-examples/src/conversation/app/get.ts +++ b/examples/simple-examples/src/conversation/app/get.ts @@ -1,4 +1,4 @@ -import { GetAppRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getPrintFormat, @@ -13,7 +13,7 @@ import { const appId = getAppIdFromConfig(); - const requestData: GetAppRequestData = { + const requestData: Conversation.GetAppRequestData = { app_id: appId, }; diff --git a/examples/simple-examples/src/conversation/app/list.ts b/examples/simple-examples/src/conversation/app/list.ts index 6c1edcbb..9510e70c 100644 --- a/examples/simple-examples/src/conversation/app/list.ts +++ b/examples/simple-examples/src/conversation/app/list.ts @@ -1,4 +1,4 @@ -import { ListAppsRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getPrintFormat, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -6,7 +6,7 @@ import { getPrintFormat, initConversationService, printFullResponse } from '../. console.log('* App_ListApps *'); console.log('****************'); - const requestData: ListAppsRequestData= {}; + const requestData: Conversation.ListAppsRequestData= {}; const conversationService = initConversationService(); const response = await conversationService.app.list(requestData); diff --git a/examples/simple-examples/src/conversation/app/update.ts b/examples/simple-examples/src/conversation/app/update.ts index 200d751f..da0615cf 100644 --- a/examples/simple-examples/src/conversation/app/update.ts +++ b/examples/simple-examples/src/conversation/app/update.ts @@ -1,4 +1,4 @@ -import { UpdateAppRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getMessengerTokenFormConfig, @@ -14,7 +14,7 @@ import { const appId = getAppIdFromConfig(); - const requestData: UpdateAppRequestData = { + const requestData: Conversation.UpdateAppRequestData = { app_id: appId, update_mask: ['display_name', 'conversation_metadata_report_view'], appUpdateRequestBody: { diff --git a/examples/simple-examples/src/conversation/capability/lookup.ts b/examples/simple-examples/src/conversation/capability/lookup.ts index 1cd6dfd7..44c05f66 100644 --- a/examples/simple-examples/src/conversation/capability/lookup.ts +++ b/examples/simple-examples/src/conversation/capability/lookup.ts @@ -1,4 +1,4 @@ -import { ContactId, LookupCapabilityRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, @@ -14,7 +14,7 @@ import { const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: LookupCapabilityRequestData = { + const requestData: Conversation.LookupCapabilityRequestData = { lookupCapabilityRequestBody: { app_id: appId, recipient: { diff --git a/examples/simple-examples/src/conversation/contact/create.ts b/examples/simple-examples/src/conversation/contact/create.ts index 0b84fa2f..d40c12f0 100644 --- a/examples/simple-examples/src/conversation/contact/create.ts +++ b/examples/simple-examples/src/conversation/contact/create.ts @@ -1,4 +1,4 @@ -import { CreateContactRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getMessengerUserIdFromConfig, @@ -17,7 +17,7 @@ import { const messengerUserId = getMessengerUserIdFromConfig(); const appId = getAppIdFromConfig(); - const requestData: CreateContactRequestData = { + const requestData: Conversation.CreateContactRequestData = { contactCreateRequestBody: { display_name: 'New contact created with the Node.js SDK', channel_identities: [ diff --git a/examples/simple-examples/src/conversation/contact/delete.ts b/examples/simple-examples/src/conversation/contact/delete.ts index e4674884..4cf45e0f 100644 --- a/examples/simple-examples/src/conversation/contact/delete.ts +++ b/examples/simple-examples/src/conversation/contact/delete.ts @@ -1,4 +1,4 @@ -import { DeleteContactRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getContactIdFromConfig, initConversationService, printFullResponse } fr const contactId = getContactIdFromConfig(); - const requestData: DeleteContactRequestData = { + const requestData: Conversation.DeleteContactRequestData = { contact_id: contactId, }; diff --git a/examples/simple-examples/src/conversation/contact/get.ts b/examples/simple-examples/src/conversation/contact/get.ts index 9fa13090..e23c947e 100644 --- a/examples/simple-examples/src/conversation/contact/get.ts +++ b/examples/simple-examples/src/conversation/contact/get.ts @@ -1,4 +1,4 @@ -import { GetContactRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getContactIdFromConfig, getPrintFormat, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getContactIdFromConfig, getPrintFormat, initConversationService, printF const contactId = getContactIdFromConfig(); - const requestData: GetContactRequestData = { + const requestData: Conversation.GetContactRequestData = { contact_id: contactId, }; diff --git a/examples/simple-examples/src/conversation/contact/getChannelProfile.ts b/examples/simple-examples/src/conversation/contact/getChannelProfile.ts index e58a6c12..6519f125 100644 --- a/examples/simple-examples/src/conversation/contact/getChannelProfile.ts +++ b/examples/simple-examples/src/conversation/contact/getChannelProfile.ts @@ -1,4 +1,4 @@ -import { GetChannelProfileRequestData, IdentifiedBy } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getMessengerUserIdFromConfig, @@ -14,7 +14,7 @@ import { const appId = getAppIdFromConfig(); const messengerUserId = getMessengerUserIdFromConfig(); - const requestData: GetChannelProfileRequestData = { + const requestData: Conversation.GetChannelProfileRequestData = { getChannelProfileRequestBody: { app_id: appId, channel: 'MESSENGER', diff --git a/examples/simple-examples/src/conversation/contact/list.ts b/examples/simple-examples/src/conversation/contact/list.ts index 788ad5d7..a75a4446 100644 --- a/examples/simple-examples/src/conversation/contact/list.ts +++ b/examples/simple-examples/src/conversation/contact/list.ts @@ -1,12 +1,12 @@ -import { Contact, ListContactsRequestData, PageResult } from '@sinch/sdk-core'; +import { Conversation, PageResult } from '@sinch/sdk-core'; import { getPrintFormat, initConversationService, printFullResponse } from '../../config'; const populateContactsList = ( - contactPage: PageResult, - contactList: Contact[], + contactPage: PageResult, + contactList: Conversation.Contact[], contactDetailsList: string[], ) => { - contactPage.data?.map((contact: Contact) => { + contactPage.data?.map((contact: Conversation.Contact) => { contactList.push(contact); contactDetailsList.push(`${contact.id} - ${contact.display_name}`); }); @@ -17,7 +17,7 @@ const populateContactsList = ( console.log('* Contact_ListContacts *'); console.log('************************'); - const requestData: ListContactsRequestData = { + const requestData: Conversation.ListContactsRequestData = { page_size: 2, }; @@ -28,7 +28,7 @@ const populateContactsList = ( // ---------------------------------------------- let response = await conversationService.contact.list(requestData); - const contactList: Contact[] = []; + const contactList: Conversation.Contact[] = []; const contactDetailsList: string[] = []; // Loop on all the pages to get all the active numbers diff --git a/examples/simple-examples/src/conversation/contact/merge.ts b/examples/simple-examples/src/conversation/contact/merge.ts index 82186980..c58cf350 100644 --- a/examples/simple-examples/src/conversation/contact/merge.ts +++ b/examples/simple-examples/src/conversation/contact/merge.ts @@ -1,4 +1,4 @@ -import { CreateContactRequestData, MergeContactRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getPhoneNumberFromConfig, getPrintFormat, @@ -14,7 +14,7 @@ import { const phoneNumber = getPhoneNumberFromConfig(); - const sourceContactRequestData: CreateContactRequestData = { + const sourceContactRequestData: Conversation.CreateContactRequestData = { contactCreateRequestBody: { channel_identities: [ { @@ -29,7 +29,7 @@ import { }, }; - const destinationContactRequestData: CreateContactRequestData = { + const destinationContactRequestData: Conversation.CreateContactRequestData = { contactCreateRequestBody: { channel_identities: [ { @@ -48,7 +48,7 @@ import { const destinationContact = await conversationService.contact.create(destinationContactRequestData); if (sourceContact.id && destinationContact.id) { - const requestData: MergeContactRequestData = { + const requestData: Conversation.MergeContactRequestData = { destination_id: destinationContact.id, mergeContactRequestBody: { source_id: sourceContact.id, diff --git a/examples/simple-examples/src/conversation/contact/update.ts b/examples/simple-examples/src/conversation/contact/update.ts index 7c69a4d0..e040f2f3 100644 --- a/examples/simple-examples/src/conversation/contact/update.ts +++ b/examples/simple-examples/src/conversation/contact/update.ts @@ -4,7 +4,7 @@ import { initConversationService, printFullResponse, } from '../../config'; -import { UpdateContactRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; (async () => { console.log('*************************'); @@ -13,7 +13,7 @@ import { UpdateContactRequestData } from '@sinch/sdk-core'; const contactId = getContactIdFromConfig(); - const requestData: UpdateContactRequestData = { + const requestData: Conversation.UpdateContactRequestData = { contact_id: contactId, update_mask:['channel_priority'], updateContactRequestBody: { diff --git a/examples/simple-examples/src/conversation/conversation/create.ts b/examples/simple-examples/src/conversation/conversation/create.ts index d555aada..3d48585f 100644 --- a/examples/simple-examples/src/conversation/conversation/create.ts +++ b/examples/simple-examples/src/conversation/conversation/create.ts @@ -1,4 +1,4 @@ -import { CreateConversationRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, @@ -15,7 +15,7 @@ import { const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: CreateConversationRequestData = { + const requestData: Conversation.CreateConversationRequestData = { createConversationRequestBody: { app_id: appId, contact_id: contactId, diff --git a/examples/simple-examples/src/conversation/conversation/delete.ts b/examples/simple-examples/src/conversation/conversation/delete.ts index 1f63c669..c0746bd8 100644 --- a/examples/simple-examples/src/conversation/conversation/delete.ts +++ b/examples/simple-examples/src/conversation/conversation/delete.ts @@ -1,4 +1,4 @@ -import { DeleteConversationRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getConversationIdFromConfig, initConversationService, printFullResponse } from '../../config'; @@ -9,7 +9,7 @@ import { getConversationIdFromConfig, initConversationService, printFullResponse const conversationId = getConversationIdFromConfig(); - const requestData: DeleteConversationRequestData = { + const requestData: Conversation.DeleteConversationRequestData = { conversation_id: conversationId, }; diff --git a/examples/simple-examples/src/conversation/conversation/get.ts b/examples/simple-examples/src/conversation/conversation/get.ts index e24fea29..30811293 100644 --- a/examples/simple-examples/src/conversation/conversation/get.ts +++ b/examples/simple-examples/src/conversation/conversation/get.ts @@ -1,4 +1,4 @@ -import { GetConversationRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getConversationIdFromConfig, getPrintFormat, @@ -13,7 +13,7 @@ import { const conversationId = getConversationIdFromConfig(); - const requestData: GetConversationRequestData = { + const requestData: Conversation.GetConversationRequestData = { conversation_id: conversationId, }; diff --git a/examples/simple-examples/src/conversation/conversation/injectEvent.ts b/examples/simple-examples/src/conversation/conversation/injectEvent.ts index 9cbf4f02..987f1dae 100644 --- a/examples/simple-examples/src/conversation/conversation/injectEvent.ts +++ b/examples/simple-examples/src/conversation/conversation/injectEvent.ts @@ -1,4 +1,4 @@ -import { InjectEventRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getContactIdFromConfig, getConversationIdFromConfig, @@ -15,7 +15,7 @@ import { const conversationId = getConversationIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: InjectEventRequestData= { + const requestData: Conversation.InjectEventRequestData= { conversation_id: conversationId, injectConversationEventRequestBody: { app_event: { diff --git a/examples/simple-examples/src/conversation/conversation/injectMessage.ts b/examples/simple-examples/src/conversation/conversation/injectMessage.ts index 97435c7e..58a7425b 100644 --- a/examples/simple-examples/src/conversation/conversation/injectMessage.ts +++ b/examples/simple-examples/src/conversation/conversation/injectMessage.ts @@ -1,4 +1,4 @@ -import { InjectMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, getConversationIdFromConfig, @@ -18,7 +18,7 @@ import { const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: InjectMessageRequestData= { + const requestData: Conversation.InjectMessageRequestData= { conversation_id: conversationId, injectMessageRequestBody: { app_message: { diff --git a/examples/simple-examples/src/conversation/conversation/list.ts b/examples/simple-examples/src/conversation/conversation/list.ts index 7abf34c7..1740da4a 100644 --- a/examples/simple-examples/src/conversation/conversation/list.ts +++ b/examples/simple-examples/src/conversation/conversation/list.ts @@ -1,12 +1,12 @@ -import { Conversation, ListConversationsRequestData, PageResult } from '@sinch/sdk-core'; +import { Conversation, PageResult } from '@sinch/sdk-core'; import { getAppIdFromConfig, getPrintFormat, initConversationService, printFullResponse } from '../../config'; const populateConversationsList = ( - conversationPage: PageResult, - conversationList: Conversation[], + conversationPage: PageResult, + conversationList: Conversation.Conversation[], conversationDetailsList: string[], ) => { - conversationPage.data.map((conversation: Conversation) => { + conversationPage.data.map((conversation: Conversation.Conversation) => { conversationList.push(conversation); conversationDetailsList.push(`${conversation.id} - ${conversation.active_channel}`); }); @@ -19,7 +19,7 @@ const populateConversationsList = ( const appId = getAppIdFromConfig(); - const requestData: ListConversationsRequestData = { + const requestData: Conversation.ListConversationsRequestData = { only_active: false, app_id: appId, }; @@ -31,7 +31,7 @@ const populateConversationsList = ( // ---------------------------------------------- let response = await conversationService.conversation.list(requestData); - const conversationList: Conversation[] = []; + const conversationList: Conversation.Conversation[] = []; const conversationDetailsList: string[] = []; // Loop on all the pages to get all the active numbers diff --git a/examples/simple-examples/src/conversation/conversation/listRecent.ts b/examples/simple-examples/src/conversation/conversation/listRecent.ts index 445edc07..b6e9ce2e 100644 --- a/examples/simple-examples/src/conversation/conversation/listRecent.ts +++ b/examples/simple-examples/src/conversation/conversation/listRecent.ts @@ -1,16 +1,12 @@ -import { - ConversationRecentMessage, - ListRecentConversationsRequestData, - PageResult, -} from '@sinch/sdk-core'; +import { Conversation, PageResult } from '@sinch/sdk-core'; import { getAppIdFromConfig, getPrintFormat, initConversationService, printFullResponse } from '../../config'; const populateConversationsList = ( - conversationPage: PageResult, - conversationList: ConversationRecentMessage[], + conversationPage: PageResult, + conversationList: Conversation.ConversationRecentMessage[], conversationDetailsList: string[], ) => { - conversationPage.data.map((recentConversation: ConversationRecentMessage) => { + conversationPage.data.map((recentConversation: Conversation.ConversationRecentMessage) => { conversationList.push(recentConversation); conversationDetailsList.push(`${recentConversation.conversation?.id} - ${recentConversation.conversation?.active_channel}\n - Latest message: ${recentConversation.last_message?.accept_time}`); }); @@ -23,7 +19,7 @@ const populateConversationsList = ( const appId = getAppIdFromConfig(); - const requestData: ListRecentConversationsRequestData = { + const requestData: Conversation.ListRecentConversationsRequestData = { only_active: true, app_id: appId, order: 'ASC', @@ -36,7 +32,7 @@ const populateConversationsList = ( // ---------------------------------------------- let response = await conversationService.conversation.listRecent(requestData); - const conversationList: ConversationRecentMessage[] = []; + const conversationList: Conversation.ConversationRecentMessage[] = []; const conversationDetailsList: string[] = []; // Loop on all the pages to get all the active numbers diff --git a/examples/simple-examples/src/conversation/conversation/stop.ts b/examples/simple-examples/src/conversation/conversation/stop.ts index 420dff5d..5c06149c 100644 --- a/examples/simple-examples/src/conversation/conversation/stop.ts +++ b/examples/simple-examples/src/conversation/conversation/stop.ts @@ -1,4 +1,4 @@ -import { StopActiveConversationRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getConversationIdFromConfig, initConversationService, printFullResponse } from '../../config'; @@ -9,7 +9,7 @@ import { getConversationIdFromConfig, initConversationService, printFullResponse const conversationId = getConversationIdFromConfig(); - const requestData: StopActiveConversationRequestData = { + const requestData: Conversation.StopActiveConversationRequestData = { conversation_id: conversationId, }; diff --git a/examples/simple-examples/src/conversation/conversation/update.ts b/examples/simple-examples/src/conversation/conversation/update.ts index 04a64f78..359462d3 100644 --- a/examples/simple-examples/src/conversation/conversation/update.ts +++ b/examples/simple-examples/src/conversation/conversation/update.ts @@ -4,7 +4,7 @@ import { initConversationService, printFullResponse, } from '../../config'; -import { UpdateConversationRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; (async () => { console.log('***********************************'); @@ -13,7 +13,7 @@ import { UpdateConversationRequestData } from '@sinch/sdk-core'; const conversationId = getConversationIdFromConfig(); - const requestData: UpdateConversationRequestData = { + const requestData: Conversation.UpdateConversationRequestData = { conversation_id: conversationId, update_mask: ['metadata'], updateConversationRequestBody: { diff --git a/examples/simple-examples/src/conversation/events/delete.ts b/examples/simple-examples/src/conversation/events/delete.ts index ae2d3e62..1e818c10 100644 --- a/examples/simple-examples/src/conversation/events/delete.ts +++ b/examples/simple-examples/src/conversation/events/delete.ts @@ -1,4 +1,4 @@ -import { DeleteEventRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getEventIdFromConfig, initConversationService, printFullResponse } from '../../config'; @@ -9,7 +9,7 @@ import { getEventIdFromConfig, initConversationService, printFullResponse } from const eventId = getEventIdFromConfig(); - const requestData: DeleteEventRequestData = { + const requestData: Conversation.DeleteEventRequestData = { event_id: eventId, }; diff --git a/examples/simple-examples/src/conversation/events/get.ts b/examples/simple-examples/src/conversation/events/get.ts index 3af8bc9c..74e7a45c 100644 --- a/examples/simple-examples/src/conversation/events/get.ts +++ b/examples/simple-examples/src/conversation/events/get.ts @@ -1,4 +1,4 @@ -import { GetEventRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getEventIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getEventIdFromConfig, initConversationService, printFullResponse } from const eventId = getEventIdFromConfig(); - const requestData: GetEventRequestData = { + const requestData: Conversation.GetEventRequestData = { event_id: eventId, }; diff --git a/examples/simple-examples/src/conversation/events/list.ts b/examples/simple-examples/src/conversation/events/list.ts index 215f7d6b..06674001 100644 --- a/examples/simple-examples/src/conversation/events/list.ts +++ b/examples/simple-examples/src/conversation/events/list.ts @@ -1,4 +1,4 @@ -import { ConversationEvent, ListEventsRequestData, PageResult } from '@sinch/sdk-core'; +import { Conversation, PageResult } from '@sinch/sdk-core'; import { getContactIdFromConfig, getConversationIdFromConfig, @@ -8,11 +8,11 @@ import { } from '../../config'; const populateEventsList = ( - eventPage: PageResult, - eventList: ConversationEvent[], + eventPage: PageResult, + eventList: Conversation.ConversationEvent[], eventDetailsList: string[], ) => { - eventPage.data.map((event: ConversationEvent) => { + eventPage.data.map((event: Conversation.ConversationEvent) => { eventList.push(event); eventDetailsList.push(`${event.id} - ${event.accept_time}`); }); @@ -26,7 +26,7 @@ const populateEventsList = ( const contactId = getContactIdFromConfig(); const conversationId = getConversationIdFromConfig(); - const requestData: ListEventsRequestData = { + const requestData: Conversation.ListEventsRequestData = { contact_id: contactId, conversation_id: conversationId, }; @@ -38,7 +38,7 @@ const populateEventsList = ( // ---------------------------------------------- let response = await conversationService.events.list(requestData); - const eventsList: ConversationEvent[] = []; + const eventsList: Conversation.ConversationEvent[] = []; const eventsDetailsList: string[] = []; // Loop on all the pages to get all the active numbers diff --git a/examples/simple-examples/src/conversation/events/send.ts b/examples/simple-examples/src/conversation/events/send.ts index cb7b91b1..ddb73f6d 100644 --- a/examples/simple-examples/src/conversation/events/send.ts +++ b/examples/simple-examples/src/conversation/events/send.ts @@ -1,4 +1,4 @@ -import { ContactId, SendEventRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendEventRequestData = { + const requestData: Conversation.SendEventRequestData = { sendEventRequestBody: { app_id: appId, recipient: { diff --git a/examples/simple-examples/src/conversation/events/sendAgentJoinedEvent.ts b/examples/simple-examples/src/conversation/events/sendAgentJoinedEvent.ts index ed2fd594..a30157c4 100644 --- a/examples/simple-examples/src/conversation/events/sendAgentJoinedEvent.ts +++ b/examples/simple-examples/src/conversation/events/sendAgentJoinedEvent.ts @@ -1,4 +1,4 @@ -import { ContactId, SendAgentJoinedEventRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendAgentJoinedEventRequestData = { + const requestData: Conversation.SendAgentJoinedEventRequestData = { sendEventRequestBody: { app_id: appId, recipient: { diff --git a/examples/simple-examples/src/conversation/events/sendAgentLeftEvent.ts b/examples/simple-examples/src/conversation/events/sendAgentLeftEvent.ts index a7877f5a..6db4d449 100644 --- a/examples/simple-examples/src/conversation/events/sendAgentLeftEvent.ts +++ b/examples/simple-examples/src/conversation/events/sendAgentLeftEvent.ts @@ -1,4 +1,4 @@ -import { ContactId, SendAgentLeftEventRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendAgentLeftEventRequestData = { + const requestData: Conversation.SendAgentLeftEventRequestData = { sendEventRequestBody: { app_id: appId, recipient: { diff --git a/examples/simple-examples/src/conversation/events/sendCommentReplyEvent.ts b/examples/simple-examples/src/conversation/events/sendCommentReplyEvent.ts index c49822a3..eb3989c3 100644 --- a/examples/simple-examples/src/conversation/events/sendCommentReplyEvent.ts +++ b/examples/simple-examples/src/conversation/events/sendCommentReplyEvent.ts @@ -1,4 +1,4 @@ -import { ContactId, SendCommentReplyEventRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendCommentReplyEventRequestData = { + const requestData: Conversation.SendCommentReplyEventRequestData = { sendEventRequestBody: { app_id: appId, recipient: { diff --git a/examples/simple-examples/src/conversation/events/sendComposingEndEvent.ts b/examples/simple-examples/src/conversation/events/sendComposingEndEvent.ts index 6055c3d9..b792cb77 100644 --- a/examples/simple-examples/src/conversation/events/sendComposingEndEvent.ts +++ b/examples/simple-examples/src/conversation/events/sendComposingEndEvent.ts @@ -1,4 +1,4 @@ -import { ContactId, SendComposingEndEventRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendComposingEndEventRequestData = { + const requestData: Conversation.SendComposingEndEventRequestData = { sendEventRequestBody: { app_id: appId, recipient: { diff --git a/examples/simple-examples/src/conversation/events/sendComposingEvent.ts b/examples/simple-examples/src/conversation/events/sendComposingEvent.ts index 3f8bf4ff..754ada46 100644 --- a/examples/simple-examples/src/conversation/events/sendComposingEvent.ts +++ b/examples/simple-examples/src/conversation/events/sendComposingEvent.ts @@ -1,4 +1,4 @@ -import { ContactId, SendComposingEventRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendComposingEventRequestData = { + const requestData: Conversation.SendComposingEventRequestData = { sendEventRequestBody: { app_id: appId, recipient: { diff --git a/examples/simple-examples/src/conversation/events/sendGenericEvent.ts b/examples/simple-examples/src/conversation/events/sendGenericEvent.ts index 033ec212..0850407d 100644 --- a/examples/simple-examples/src/conversation/events/sendGenericEvent.ts +++ b/examples/simple-examples/src/conversation/events/sendGenericEvent.ts @@ -1,4 +1,4 @@ -import { ContactId, SendGenericEventRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendGenericEventRequestData = { + const requestData: Conversation.SendGenericEventRequestData = { sendEventRequestBody: { app_id: appId, recipient: { diff --git a/examples/simple-examples/src/conversation/messages/delete.ts b/examples/simple-examples/src/conversation/messages/delete.ts index 562bbc36..22553333 100644 --- a/examples/simple-examples/src/conversation/messages/delete.ts +++ b/examples/simple-examples/src/conversation/messages/delete.ts @@ -1,4 +1,4 @@ -import { DeleteMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getMessageIdFromConfig, initConversationService, printFullResponse } from '../../config'; @@ -9,7 +9,7 @@ import { getMessageIdFromConfig, initConversationService, printFullResponse } fr const messageId = getMessageIdFromConfig(); - const requestData: DeleteMessageRequestData = { + const requestData: Conversation.DeleteMessageRequestData = { message_id: messageId, }; diff --git a/examples/simple-examples/src/conversation/messages/get.ts b/examples/simple-examples/src/conversation/messages/get.ts index e5008c69..9820289f 100644 --- a/examples/simple-examples/src/conversation/messages/get.ts +++ b/examples/simple-examples/src/conversation/messages/get.ts @@ -1,4 +1,4 @@ -import { GetMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getMessageIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getMessageIdFromConfig, initConversationService, printFullResponse } fr const messageId = getMessageIdFromConfig(); - const requestData: GetMessageRequestData = { + const requestData: Conversation.GetMessageRequestData = { message_id: messageId, }; diff --git a/examples/simple-examples/src/conversation/messages/list.ts b/examples/simple-examples/src/conversation/messages/list.ts index 2e5ff970..a16fdfe3 100644 --- a/examples/simple-examples/src/conversation/messages/list.ts +++ b/examples/simple-examples/src/conversation/messages/list.ts @@ -1,4 +1,4 @@ -import { ConversationMessage, ListMessagesRequestData, PageResult } from '@sinch/sdk-core'; +import { Conversation, PageResult } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, getConversationIdFromConfig, @@ -8,11 +8,11 @@ import { } from '../../config'; const populateMessagesList = ( - conversationPage: PageResult, - conversationList: ConversationMessage[], + conversationPage: PageResult, + conversationList: Conversation.ConversationMessage[], conversationDetailsList: string[], ) => { - conversationPage.data.map((message: ConversationMessage) => { + conversationPage.data.map((message: Conversation.ConversationMessage) => { conversationList.push(message); conversationDetailsList.push(`${message.id} - ${message.accept_time}`); }); @@ -27,7 +27,7 @@ const populateMessagesList = ( const contactId = getContactIdFromConfig(); const conversationId = getConversationIdFromConfig(); - const requestData: ListMessagesRequestData = { + const requestData: Conversation.ListMessagesRequestData = { app_id: appId, contact_id: contactId, conversation_id: conversationId, @@ -41,7 +41,7 @@ const populateMessagesList = ( // ---------------------------------------------- let response = await conversationService.messages.list(requestData); - const messageList: ConversationMessage[] = []; + const messageList: Conversation.ConversationMessage[] = []; const messagesDetailsList: string[] = []; // Loop on all the pages to get all the active numbers diff --git a/examples/simple-examples/src/conversation/messages/send.ts b/examples/simple-examples/src/conversation/messages/send.ts index 31bc6461..f5b592b1 100644 --- a/examples/simple-examples/src/conversation/messages/send.ts +++ b/examples/simple-examples/src/conversation/messages/send.ts @@ -1,4 +1,4 @@ -import { ContactId, SendMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendMessageRequestData = { + const requestData: Conversation.SendMessageRequestData = { sendMessageRequestBody: { app_id: appId, message: { diff --git a/examples/simple-examples/src/conversation/messages/sendCardMessage.ts b/examples/simple-examples/src/conversation/messages/sendCardMessage.ts index 1e489fd6..f377cbce 100644 --- a/examples/simple-examples/src/conversation/messages/sendCardMessage.ts +++ b/examples/simple-examples/src/conversation/messages/sendCardMessage.ts @@ -1,4 +1,4 @@ -import { ContactId, SendCardMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendCardMessageRequestData = { + const requestData: Conversation.SendCardMessageRequestData = { sendMessageRequestBody: { app_id: appId, message: { diff --git a/examples/simple-examples/src/conversation/messages/sendCarouselMessage.ts b/examples/simple-examples/src/conversation/messages/sendCarouselMessage.ts index 068be6b5..34d22546 100644 --- a/examples/simple-examples/src/conversation/messages/sendCarouselMessage.ts +++ b/examples/simple-examples/src/conversation/messages/sendCarouselMessage.ts @@ -1,4 +1,4 @@ -import { ContactId, SendCarouselMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendCarouselMessageRequestData = { + const requestData: Conversation.SendCarouselMessageRequestData = { sendMessageRequestBody: { app_id: appId, message: { diff --git a/examples/simple-examples/src/conversation/messages/sendChoiceMessage.ts b/examples/simple-examples/src/conversation/messages/sendChoiceMessage.ts index a4f624ea..ae67177d 100644 --- a/examples/simple-examples/src/conversation/messages/sendChoiceMessage.ts +++ b/examples/simple-examples/src/conversation/messages/sendChoiceMessage.ts @@ -1,4 +1,4 @@ -import { ContactId, SendChoiceMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendChoiceMessageRequestData = { + const requestData: Conversation.SendChoiceMessageRequestData = { sendMessageRequestBody: { app_id: appId, message: { diff --git a/examples/simple-examples/src/conversation/messages/sendContactInfoMessage.ts b/examples/simple-examples/src/conversation/messages/sendContactInfoMessage.ts index ea2523df..5aafd987 100644 --- a/examples/simple-examples/src/conversation/messages/sendContactInfoMessage.ts +++ b/examples/simple-examples/src/conversation/messages/sendContactInfoMessage.ts @@ -1,4 +1,4 @@ -import { ContactId, SendContactInfoMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendContactInfoMessageRequestData = { + const requestData: Conversation.SendContactInfoMessageRequestData = { sendMessageRequestBody: { app_id: appId, message: { diff --git a/examples/simple-examples/src/conversation/messages/sendListMessage.ts b/examples/simple-examples/src/conversation/messages/sendListMessage.ts index 288db425..f75f800c 100644 --- a/examples/simple-examples/src/conversation/messages/sendListMessage.ts +++ b/examples/simple-examples/src/conversation/messages/sendListMessage.ts @@ -1,4 +1,4 @@ -import { ContactId, SendListMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendListMessageRequestData = { + const requestData: Conversation.SendListMessageRequestData = { sendMessageRequestBody: { app_id: appId, message: { diff --git a/examples/simple-examples/src/conversation/messages/sendLocationMessage.ts b/examples/simple-examples/src/conversation/messages/sendLocationMessage.ts index ce766b85..6fde3b1d 100644 --- a/examples/simple-examples/src/conversation/messages/sendLocationMessage.ts +++ b/examples/simple-examples/src/conversation/messages/sendLocationMessage.ts @@ -1,4 +1,4 @@ -import { ContactId, SendLocationMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendLocationMessageRequestData = { + const requestData: Conversation.SendLocationMessageRequestData = { sendMessageRequestBody: { app_id: appId, message: { diff --git a/examples/simple-examples/src/conversation/messages/sendMediaMessage.ts b/examples/simple-examples/src/conversation/messages/sendMediaMessage.ts index 5273b8fa..ba210e63 100644 --- a/examples/simple-examples/src/conversation/messages/sendMediaMessage.ts +++ b/examples/simple-examples/src/conversation/messages/sendMediaMessage.ts @@ -1,4 +1,4 @@ -import { ContactId, SendMediaMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendMediaMessageRequestData = { + const requestData: Conversation.SendMediaMessageRequestData = { sendMessageRequestBody: { app_id: appId, message: { diff --git a/examples/simple-examples/src/conversation/messages/sendTemplateMessage.ts b/examples/simple-examples/src/conversation/messages/sendTemplateMessage.ts index 18d6f74e..ec0dfe35 100644 --- a/examples/simple-examples/src/conversation/messages/sendTemplateMessage.ts +++ b/examples/simple-examples/src/conversation/messages/sendTemplateMessage.ts @@ -1,4 +1,4 @@ -import { ContactId, SendTemplateMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendTemplateMessageRequestData = { + const requestData: Conversation.SendTemplateMessageRequestData = { sendMessageRequestBody: { app_id: appId, message: { diff --git a/examples/simple-examples/src/conversation/messages/sendTextMessage.ts b/examples/simple-examples/src/conversation/messages/sendTextMessage.ts index 9d26d3ef..40c0f013 100644 --- a/examples/simple-examples/src/conversation/messages/sendTextMessage.ts +++ b/examples/simple-examples/src/conversation/messages/sendTextMessage.ts @@ -1,4 +1,4 @@ -import { ContactId, SendTextMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -9,7 +9,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr const appId = getAppIdFromConfig(); const contactId = getContactIdFromConfig(); - const requestData: SendTextMessageRequestData = { + const requestData: Conversation.SendTextMessageRequestData = { sendMessageRequestBody: { app_id: appId, message: { diff --git a/examples/simple-examples/src/conversation/messages/update.ts b/examples/simple-examples/src/conversation/messages/update.ts index db1edf6d..ccb06b65 100644 --- a/examples/simple-examples/src/conversation/messages/update.ts +++ b/examples/simple-examples/src/conversation/messages/update.ts @@ -1,4 +1,4 @@ -import { UpdateMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getMessageIdFromConfig, initConversationService, @@ -12,7 +12,7 @@ import { const messageId = getMessageIdFromConfig(); - const requestData: UpdateMessageRequestData = { + const requestData: Conversation.UpdateMessageRequestData = { message_id: messageId, updateMessageRequestBody: { metadata: 'Updated metadata', diff --git a/examples/simple-examples/src/conversation/templates-v1/create.ts b/examples/simple-examples/src/conversation/templates-v1/create.ts index 5b35c3b3..98c7256c 100644 --- a/examples/simple-examples/src/conversation/templates-v1/create.ts +++ b/examples/simple-examples/src/conversation/templates-v1/create.ts @@ -1,4 +1,4 @@ -import { CreateTemplateRequestData, templateV1Helper } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getPrintFormat, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -6,7 +6,7 @@ import { getPrintFormat, initConversationService, printFullResponse } from '../. console.log('* Templates_CreateTemplate *'); console.log('****************************'); - const requestData: CreateTemplateRequestData = { + const requestData: Conversation.CreateTemplateRequestData = { createTemplateRequestBody: { description: 'Template v1', default_translation: 'en-US', @@ -15,7 +15,7 @@ import { getPrintFormat, initConversationService, printFullResponse } from '../. { language_code: 'en-US', version: '1', - content: templateV1Helper.buildTextMessageContent({ + content: Conversation.templateV1Helper.buildTextMessageContent({ text: 'Message from a template v1.', }), }, diff --git a/examples/simple-examples/src/conversation/templates-v1/delete.ts b/examples/simple-examples/src/conversation/templates-v1/delete.ts index bac2005a..ac17c0f3 100644 --- a/examples/simple-examples/src/conversation/templates-v1/delete.ts +++ b/examples/simple-examples/src/conversation/templates-v1/delete.ts @@ -1,4 +1,4 @@ -import { DeleteTemplateRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getTemplateIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getTemplateIdFromConfig, initConversationService, printFullResponse } f const templateId = getTemplateIdFromConfig(); - const requestData: DeleteTemplateRequestData = { + const requestData: Conversation.DeleteTemplateRequestData = { template_id: templateId, }; diff --git a/examples/simple-examples/src/conversation/templates-v1/get.ts b/examples/simple-examples/src/conversation/templates-v1/get.ts index 79de40b7..4ee1dc13 100644 --- a/examples/simple-examples/src/conversation/templates-v1/get.ts +++ b/examples/simple-examples/src/conversation/templates-v1/get.ts @@ -1,4 +1,4 @@ -import { GetTemplateRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getPrintFormat, getTemplateIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getPrintFormat, getTemplateIdFromConfig, initConversationService, print const templateId = getTemplateIdFromConfig(); - const requestData: GetTemplateRequestData = { + const requestData: Conversation.GetTemplateRequestData = { template_id: templateId, }; diff --git a/examples/simple-examples/src/conversation/templates-v1/list.ts b/examples/simple-examples/src/conversation/templates-v1/list.ts index bfe6c3e8..1232de04 100644 --- a/examples/simple-examples/src/conversation/templates-v1/list.ts +++ b/examples/simple-examples/src/conversation/templates-v1/list.ts @@ -1,4 +1,4 @@ -import { ListTemplatesRequestData, V1Template } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getPrintFormat, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -7,7 +7,7 @@ import { getPrintFormat, initConversationService, printFullResponse } from '../. console.log('***************************'); - const requestData: ListTemplatesRequestData = { + const requestData: Conversation.ListTemplatesRequestData = { }; const conversationService = initConversationService(); @@ -23,6 +23,6 @@ import { getPrintFormat, initConversationService, printFullResponse } from '../. })(); -const formatPrettyMessage = (template: V1Template) => { +const formatPrettyMessage = (template: Conversation.V1Template) => { return ` - ID: ${template.id} - Default translation: ${template.default_translation} - Available translations: ${template.translations?.map((translation) => translation.language_code).join(',')}`; }; diff --git a/examples/simple-examples/src/conversation/templates-v1/update.ts b/examples/simple-examples/src/conversation/templates-v1/update.ts index 6f07558f..fd542a6f 100644 --- a/examples/simple-examples/src/conversation/templates-v1/update.ts +++ b/examples/simple-examples/src/conversation/templates-v1/update.ts @@ -1,4 +1,4 @@ -import { templateV1Helper, UpdateTemplateRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getPrintFormat, getTemplateIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getPrintFormat, getTemplateIdFromConfig, initConversationService, print const templateId = getTemplateIdFromConfig(); - const requestData: UpdateTemplateRequestData = { + const requestData: Conversation.UpdateTemplateRequestData = { template_id: templateId, updateTemplateRequestBody: { description: 'Updated description for Template v1', @@ -19,7 +19,7 @@ import { getPrintFormat, getTemplateIdFromConfig, initConversationService, print { language_code: 'en-US', version: '1', - content: templateV1Helper.buildTextMessageContent({ + content: Conversation.templateV1Helper.buildTextMessageContent({ text: 'Message from a template v1.', }), }, @@ -27,7 +27,7 @@ import { getPrintFormat, getTemplateIdFromConfig, initConversationService, print { language_code: 'fr-FR', version: '1', - content: templateV1Helper.buildLocationMessageContent({ + content: Conversation.templateV1Helper.buildLocationMessageContent({ title: 'Phare d\'Eckmühl', label: 'Pointe de Penmarch', coordinates: { diff --git a/examples/simple-examples/src/conversation/templates-v2/create.ts b/examples/simple-examples/src/conversation/templates-v2/create.ts index 818ab5c6..4448d499 100644 --- a/examples/simple-examples/src/conversation/templates-v2/create.ts +++ b/examples/simple-examples/src/conversation/templates-v2/create.ts @@ -1,4 +1,4 @@ -import { templateV2Helper, V2CreateTemplateRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getPrintFormat, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -6,7 +6,7 @@ import { getPrintFormat, initConversationService, printFullResponse } from '../. console.log('* Templates_v2_CreateTemplate *'); console.log('*******************************'); - const requestData: V2CreateTemplateRequestData = { + const requestData: Conversation.V2CreateTemplateRequestData = { createTemplateRequestBody: { description: 'Template v2', default_translation: 'en-US', @@ -14,7 +14,7 @@ import { getPrintFormat, initConversationService, printFullResponse } from '../. { language_code: 'en-US', version: '1', - ...templateV2Helper.buildTextMessageContent({ + ...Conversation.templateV2Helper.buildTextMessageContent({ text: 'Message from a template v2.', }), }, diff --git a/examples/simple-examples/src/conversation/templates-v2/delete.ts b/examples/simple-examples/src/conversation/templates-v2/delete.ts index cdb75187..a1467542 100644 --- a/examples/simple-examples/src/conversation/templates-v2/delete.ts +++ b/examples/simple-examples/src/conversation/templates-v2/delete.ts @@ -1,4 +1,4 @@ -import { V2DeleteTemplateRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getTemplateIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getTemplateIdFromConfig, initConversationService, printFullResponse } f const templateId = getTemplateIdFromConfig(); - const requestData: V2DeleteTemplateRequestData = { + const requestData: Conversation.V2DeleteTemplateRequestData = { template_id: templateId, }; diff --git a/examples/simple-examples/src/conversation/templates-v2/get.ts b/examples/simple-examples/src/conversation/templates-v2/get.ts index eacf91c7..c974b7d9 100644 --- a/examples/simple-examples/src/conversation/templates-v2/get.ts +++ b/examples/simple-examples/src/conversation/templates-v2/get.ts @@ -1,4 +1,4 @@ -import { V2GetTemplateRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getPrintFormat, getTemplateIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getPrintFormat, getTemplateIdFromConfig, initConversationService, print const templateId = getTemplateIdFromConfig(); - const requestData: V2GetTemplateRequestData = { + const requestData: Conversation.V2GetTemplateRequestData = { template_id: templateId, }; diff --git a/examples/simple-examples/src/conversation/templates-v2/list-translations.ts b/examples/simple-examples/src/conversation/templates-v2/list-translations.ts index ba0839ac..c9a632c6 100644 --- a/examples/simple-examples/src/conversation/templates-v2/list-translations.ts +++ b/examples/simple-examples/src/conversation/templates-v2/list-translations.ts @@ -1,4 +1,4 @@ -import { templateV2Helper, V2ListTranslationsRequestData, V2TemplateTranslation } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getPrintFormat, getTemplateIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -21,7 +21,7 @@ import { getPrintFormat, getTemplateIdFromConfig, initConversationService, print // Get the first translation for the purpose of this example const translation = templateV2Response.translations[0]; - const requestData: V2ListTranslationsRequestData = { + const requestData: Conversation.V2ListTranslationsRequestData = { template_id: templateId, // Optional parameters language_code: translation.language_code, @@ -40,7 +40,7 @@ import { getPrintFormat, getTemplateIdFromConfig, initConversationService, print })(); -const formatPrettyMessage = (translation: V2TemplateTranslation) => { - const message = templateV2Helper.getMessageFromTranslation(translation); +const formatPrettyMessage = (translation: Conversation.V2TemplateTranslation) => { + const message = Conversation.templateV2Helper.getMessageFromTranslation(translation); return ` - Language code: ${translation.language_code} - Version: '${translation.version}' - Message: ${JSON.stringify(message.content)}`; }; diff --git a/examples/simple-examples/src/conversation/templates-v2/list.ts b/examples/simple-examples/src/conversation/templates-v2/list.ts index 836ad2d5..1f619c30 100644 --- a/examples/simple-examples/src/conversation/templates-v2/list.ts +++ b/examples/simple-examples/src/conversation/templates-v2/list.ts @@ -1,4 +1,4 @@ -import { V2ListTemplatesRequestData, V2TemplateResponse } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getPrintFormat, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -7,7 +7,7 @@ import { getPrintFormat, initConversationService, printFullResponse } from '../. console.log('******************************'); - const requestData: V2ListTemplatesRequestData = { + const requestData: Conversation.V2ListTemplatesRequestData = { }; const conversationService = initConversationService(); @@ -23,6 +23,6 @@ import { getPrintFormat, initConversationService, printFullResponse } from '../. })(); -const formatPrettyMessage = (template: V2TemplateResponse) => { +const formatPrettyMessage = (template: Conversation.V2TemplateResponse) => { return ` - ID: ${template.id} - Default translation: ${template.default_translation} - Version: ${template.version} - Available translations: ${template.translations?.map((translation) => translation.language_code + '(' +translation.version + ')').join(', ')}`; }; diff --git a/examples/simple-examples/src/conversation/templates-v2/update.ts b/examples/simple-examples/src/conversation/templates-v2/update.ts index 367c8c8d..0efd68b2 100644 --- a/examples/simple-examples/src/conversation/templates-v2/update.ts +++ b/examples/simple-examples/src/conversation/templates-v2/update.ts @@ -1,4 +1,4 @@ -import { templateV2Helper, V2TemplateTranslation, V2UpdateTemplateRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getPrintFormat, getTemplateIdFromConfig, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -13,7 +13,7 @@ import { getPrintFormat, getTemplateIdFromConfig, initConversationService, print template_id: templateId, }); - const requestData: V2UpdateTemplateRequestData = { + const requestData: Conversation.V2UpdateTemplateRequestData = { template_id: templateId, updateTemplateRequestBody: { version: templateV2Response.version, @@ -21,12 +21,12 @@ import { getPrintFormat, getTemplateIdFromConfig, initConversationService, print default_translation: templateV2Response.default_translation, translations: [ // Repeat previous content to not lose it on update - ...templateV2Helper.getPreviousTranslations(templateV2Response.translations), + ...Conversation.templateV2Helper.getPreviousTranslations(templateV2Response.translations), // New translation added in the scope of the update { language_code: 'fr-FR', version: '1', - ...templateV2Helper.buildLocationMessageContent({ + ...Conversation.templateV2Helper.buildLocationMessageContent({ title: 'Phare d\'Eckmühl', label: 'Pointe de Penmarch', coordinates: { @@ -51,8 +51,8 @@ import { getPrintFormat, getTemplateIdFromConfig, initConversationService, print })(); -const formatPrettyMessage = (translation: V2TemplateTranslation) => { - const message = templateV2Helper.getMessageFromTranslation(translation); +const formatPrettyMessage = (translation: Conversation.V2TemplateTranslation) => { + const message = Conversation.templateV2Helper.getMessageFromTranslation(translation); return ` - Language code: ${translation.language_code} - Version: '${translation.version}' - Message: ${JSON.stringify(message.content)}`; }; diff --git a/examples/simple-examples/src/conversation/transcoding/transcode.ts b/examples/simple-examples/src/conversation/transcoding/transcode.ts index 2a4a3eb5..213dee1e 100644 --- a/examples/simple-examples/src/conversation/transcoding/transcode.ts +++ b/examples/simple-examples/src/conversation/transcoding/transcode.ts @@ -1,4 +1,4 @@ -import { TranscodeMessageRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getPrintFormat, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getAppIdFromConfig, getPrintFormat, initConversationService, printFullR const appId = getAppIdFromConfig(); - const requestData: TranscodeMessageRequestData = { + const requestData: Conversation.TranscodeMessageRequestData = { transcodeMessageRequestBody: { app_id: appId, app_message: { diff --git a/examples/simple-examples/src/conversation/webhooks/create.ts b/examples/simple-examples/src/conversation/webhooks/create.ts index 07bde2b5..324f7137 100644 --- a/examples/simple-examples/src/conversation/webhooks/create.ts +++ b/examples/simple-examples/src/conversation/webhooks/create.ts @@ -1,4 +1,4 @@ -import { CreateWebhookRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getPrintFormat, getWebhookTargetFromConfig, @@ -14,7 +14,7 @@ import { const appId = getAppIdFromConfig(); const webhookTarget = getWebhookTargetFromConfig(); - const requestData: CreateWebhookRequestData = { + const requestData: Conversation.CreateWebhookRequestData = { webhookCreateRequestBody: { app_id: appId, target: webhookTarget, diff --git a/examples/simple-examples/src/conversation/webhooks/delete.ts b/examples/simple-examples/src/conversation/webhooks/delete.ts index 3a4ec830..a848ec5f 100644 --- a/examples/simple-examples/src/conversation/webhooks/delete.ts +++ b/examples/simple-examples/src/conversation/webhooks/delete.ts @@ -1,4 +1,4 @@ -import { DeleteWebhookRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getWebhookIdFromConfig, initConversationService, printFullResponse } from '../../config'; @@ -9,7 +9,7 @@ import { getWebhookIdFromConfig, initConversationService, printFullResponse } fr const webhookId = getWebhookIdFromConfig(); - const requestData: DeleteWebhookRequestData = { + const requestData: Conversation.DeleteWebhookRequestData = { webhook_id: webhookId, }; diff --git a/examples/simple-examples/src/conversation/webhooks/get.ts b/examples/simple-examples/src/conversation/webhooks/get.ts index 3f34bd49..271bf2ef 100644 --- a/examples/simple-examples/src/conversation/webhooks/get.ts +++ b/examples/simple-examples/src/conversation/webhooks/get.ts @@ -1,4 +1,4 @@ -import { GetWebhookRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getPrintFormat, getWebhookIdFromConfig, @@ -13,7 +13,7 @@ import { const webhookId = getWebhookIdFromConfig(); - const requestData: GetWebhookRequestData = { + const requestData: Conversation.GetWebhookRequestData = { webhook_id: webhookId, }; diff --git a/examples/simple-examples/src/conversation/webhooks/list.ts b/examples/simple-examples/src/conversation/webhooks/list.ts index f64d2bed..8034f57c 100644 --- a/examples/simple-examples/src/conversation/webhooks/list.ts +++ b/examples/simple-examples/src/conversation/webhooks/list.ts @@ -1,4 +1,4 @@ -import { ListWebhooksRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getPrintFormat, initConversationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getAppIdFromConfig, getPrintFormat, initConversationService, printFullR const appId = getAppIdFromConfig(); - const requestData: ListWebhooksRequestData = { + const requestData: Conversation.ListWebhooksRequestData = { app_id: appId, }; diff --git a/examples/simple-examples/src/conversation/webhooks/update.ts b/examples/simple-examples/src/conversation/webhooks/update.ts index 76b5ca49..fe76e9b8 100644 --- a/examples/simple-examples/src/conversation/webhooks/update.ts +++ b/examples/simple-examples/src/conversation/webhooks/update.ts @@ -1,4 +1,4 @@ -import { UpdateWebhookRequestData } from '@sinch/sdk-core'; +import { Conversation } from '@sinch/sdk-core'; import { getAppIdFromConfig, getPrintFormat, getWebhookIdFromConfig, @@ -15,7 +15,7 @@ import { const webhookId = getWebhookIdFromConfig(); const appId = getAppIdFromConfig(); - const requestData: UpdateWebhookRequestData = { + const requestData: Conversation.UpdateWebhookRequestData = { webhook_id: webhookId, update_mask: ['triggers', 'secret'], webhookUpdateRequestBody: { diff --git a/examples/simple-examples/src/numbers/active/get.ts b/examples/simple-examples/src/numbers/active/get.ts index da1b54ad..d3324cd6 100644 --- a/examples/simple-examples/src/numbers/active/get.ts +++ b/examples/simple-examples/src/numbers/active/get.ts @@ -4,7 +4,7 @@ import { initNumbersService, printFullResponse, } from '../../config'; -import { GetActiveNumberRequestData } from '@sinch/sdk-core'; +import { Numbers } from '@sinch/sdk-core'; (async () => { console.log('*********************************'); @@ -13,7 +13,7 @@ import { GetActiveNumberRequestData } from '@sinch/sdk-core'; const phoneNumber = getPhoneNumberFromConfig(); - const requestData: GetActiveNumberRequestData= { + const requestData: Numbers.GetActiveNumberRequestData= { phoneNumber, }; diff --git a/examples/simple-examples/src/numbers/active/list.ts b/examples/simple-examples/src/numbers/active/list.ts index 35501dee..126122bb 100644 --- a/examples/simple-examples/src/numbers/active/list.ts +++ b/examples/simple-examples/src/numbers/active/list.ts @@ -1,12 +1,12 @@ import { getPrintFormat, initNumbersService, printFullResponse } from '../../config'; -import { ActiveNumber, ListActiveNumbersRequestData, PageResult } from '@sinch/sdk-core'; +import { Numbers, PageResult } from '@sinch/sdk-core'; const populateActiveNumbersList = ( - activeNumbersPage: PageResult, - activeNumbersList: ActiveNumber[], + activeNumbersPage: PageResult, + activeNumbersList: Numbers.ActiveNumber[], phoneNumbersList: (string | undefined)[], ) => { - activeNumbersPage.data?.map((activeNumber: ActiveNumber) => { + activeNumbersPage.data?.map((activeNumber: Numbers.ActiveNumber) => { activeNumbersList.push(activeNumber); phoneNumbersList.push(activeNumber.phoneNumber); }); @@ -18,7 +18,7 @@ const populateActiveNumbersList = ( console.log('* NumberService_ListActiveNumbers *'); console.log('***********************************'); - const requestData: ListActiveNumbersRequestData = { + const requestData: Numbers.ListActiveNumbersRequestData = { regionCode: 'US', type: 'LOCAL', capability: 'SMS', @@ -32,7 +32,7 @@ const populateActiveNumbersList = ( // ---------------------------------------------- let response = await numbersService.activeNumber.list(requestData); - const activeNumbersList: ActiveNumber[] = []; + const activeNumbersList: Numbers.ActiveNumber[] = []; const phoneNumbersList: (string | undefined)[] = []; // Loop on all the pages to get all the active numbers diff --git a/examples/simple-examples/src/numbers/active/release.ts b/examples/simple-examples/src/numbers/active/release.ts index ed71c25d..372b86d3 100644 --- a/examples/simple-examples/src/numbers/active/release.ts +++ b/examples/simple-examples/src/numbers/active/release.ts @@ -4,7 +4,7 @@ import { initNumbersService, printFullResponse, } from '../../config'; -import { ReleaseNumberRequestData } from '@sinch/sdk-core'; +import { Numbers } from '@sinch/sdk-core'; (async () => { console.log('*******************************'); @@ -13,7 +13,7 @@ import { ReleaseNumberRequestData } from '@sinch/sdk-core'; const phoneNumber = getPhoneNumberFromConfig(); - const requestData: ReleaseNumberRequestData= { + const requestData: Numbers.ReleaseNumberRequestData= { phoneNumber, }; diff --git a/examples/simple-examples/src/numbers/active/update.ts b/examples/simple-examples/src/numbers/active/update.ts index 3360d456..d3a8c26c 100644 --- a/examples/simple-examples/src/numbers/active/update.ts +++ b/examples/simple-examples/src/numbers/active/update.ts @@ -6,7 +6,7 @@ import { initNumbersService, printFullResponse, } from '../../config'; -import { UpdateActiveNumberRequestData } from '@sinch/sdk-core'; +import { Numbers } from '@sinch/sdk-core'; (async () => { console.log('************************************'); @@ -17,9 +17,9 @@ import { UpdateActiveNumberRequestData } from '@sinch/sdk-core'; const servicePlanId = getServicePlanIdFromConfig(); const callbackUrl = getNumberCallbackUrlFromConfig(); - const requestData: UpdateActiveNumberRequestData= { + const requestData: Numbers.UpdateActiveNumberRequestData= { phoneNumber, - activeNumberRequestBody: { + updateActiveNumberRequestBody: { displayName: 'New display name updated with the Sinch Node.js SDK', smsConfiguration: { servicePlanId, diff --git a/examples/simple-examples/src/numbers/available/checkAvailability.ts b/examples/simple-examples/src/numbers/available/checkAvailability.ts index 57581c58..43f1cdab 100644 --- a/examples/simple-examples/src/numbers/available/checkAvailability.ts +++ b/examples/simple-examples/src/numbers/available/checkAvailability.ts @@ -4,7 +4,7 @@ import { initNumbersService, printFullResponse, } from '../../config'; -import { GetAvailableNumberRequestData } from '@sinch/sdk-core'; +import { Numbers } from '@sinch/sdk-core'; (async () => { console.log('************************************'); @@ -14,7 +14,7 @@ import { GetAvailableNumberRequestData } from '@sinch/sdk-core'; // Use the phone number from the .env file const phoneNumber = getPhoneNumberFromConfig(); - const requestData: GetAvailableNumberRequestData= { + const requestData: Numbers.GetAvailableNumberRequestData= { phoneNumber, }; diff --git a/examples/simple-examples/src/numbers/available/list.ts b/examples/simple-examples/src/numbers/available/list.ts index c5b5ffb2..e375c918 100644 --- a/examples/simple-examples/src/numbers/available/list.ts +++ b/examples/simple-examples/src/numbers/available/list.ts @@ -1,12 +1,12 @@ import { getPrintFormat, initNumbersService, printFullResponse } from '../../config'; -import { ListAvailableNumbersRequestData } from '@sinch/sdk-core'; +import { Numbers } from '@sinch/sdk-core'; (async () => { console.log('**************************************'); console.log('* NumberService_ListAvailableNumbers *'); console.log('**************************************'); - const requestData: ListAvailableNumbersRequestData= { + const requestData: Numbers.ListAvailableNumbersRequestData= { regionCode: 'US', type: 'LOCAL', capabilities: ['SMS', 'VOICE'], diff --git a/examples/simple-examples/src/numbers/available/rent.ts b/examples/simple-examples/src/numbers/available/rent.ts index 2e23cde6..c3b3cc92 100644 --- a/examples/simple-examples/src/numbers/available/rent.ts +++ b/examples/simple-examples/src/numbers/available/rent.ts @@ -7,10 +7,7 @@ import { getNumberCallbackUrlFromConfig, initNumbersService, } from '../../config'; -import { - RentNumberRequest, - RentNumberRequestData, -} from '@sinch/sdk-core'; +import { Numbers } from '@sinch/sdk-core'; (async () => { console.log('****************************'); @@ -21,7 +18,7 @@ import { const servicePlanId = readServicePlanId(); const appId = readApplicationKey(); - let rentNumberRequest: RentNumberRequest = { + let rentNumberRequest: Numbers.RentNumberRequest = { smsConfiguration: servicePlanId ? { servicePlanId } : undefined, voiceConfiguration: appId ? { appId } : undefined, callbackUrl, @@ -35,7 +32,7 @@ import { const phoneNumber = getPhoneNumberFromConfig(); - const requestData: RentNumberRequestData = { + const requestData: Numbers.RentNumberRequestData = { phoneNumber, rentNumberRequestBody: rentNumberRequest, }; diff --git a/examples/simple-examples/src/numbers/available/rentAny.ts b/examples/simple-examples/src/numbers/available/rentAny.ts index c2f085de..8cf8678c 100644 --- a/examples/simple-examples/src/numbers/available/rentAny.ts +++ b/examples/simple-examples/src/numbers/available/rentAny.ts @@ -6,10 +6,7 @@ import { readApplicationKey, readServicePlanId, } from '../../config'; -import { - RentAnyNumberRequest, - RentAnyNumberRequestData, -} from '@sinch/sdk-core'; +import { Numbers } from '@sinch/sdk-core'; (async () => { console.log('*******************************'); @@ -25,7 +22,7 @@ import { + 'You may want to check the value of "SINCH_SERVICE_PLAN_ID" and "SINCH_APPLICATION_KEY" in the .env file'); } - const rentAnyNumberRequest: RentAnyNumberRequest = { + const rentAnyNumberRequest: Numbers.RentAnyNumberRequest = { regionCode: 'US', type: 'LOCAL', numberPattern: { @@ -43,7 +40,7 @@ import { rentAnyNumberRequest.voiceConfiguration = { appId }; } - const requestData: RentAnyNumberRequestData = { + const requestData: Numbers.RentAnyNumberRequestData = { rentAnyNumberRequestBody: rentAnyNumberRequest, }; diff --git a/examples/simple-examples/src/numbers/callbacks/get.ts b/examples/simple-examples/src/numbers/callbacks/get.ts index 7ff55540..2a9c2202 100644 --- a/examples/simple-examples/src/numbers/callbacks/get.ts +++ b/examples/simple-examples/src/numbers/callbacks/get.ts @@ -1,4 +1,4 @@ -import { GetCallbackConfigurationRequestData } from '@sinch/sdk-core'; +import { Numbers } from '@sinch/sdk-core'; import { getPrintFormat, initNumbersService, printFullResponse } from '../../config'; (async () => { @@ -6,7 +6,7 @@ import { getPrintFormat, initNumbersService, printFullResponse } from '../../con console.log('* GetCallbackConfiguration *'); console.log('****************************'); - const requestData: GetCallbackConfigurationRequestData = {}; + const requestData: Numbers.GetCallbackConfigurationRequestData = {}; const numbersService = initNumbersService(); const response = await numbersService.callbacks.get(requestData); diff --git a/examples/simple-examples/src/numbers/callbacks/update.ts b/examples/simple-examples/src/numbers/callbacks/update.ts index b8b63c7b..77f6beb9 100644 --- a/examples/simple-examples/src/numbers/callbacks/update.ts +++ b/examples/simple-examples/src/numbers/callbacks/update.ts @@ -1,4 +1,4 @@ -import { UpdateCallbackConfigurationRequestData } from '@sinch/sdk-core'; +import { Numbers } from '@sinch/sdk-core'; import { getHmacSecretFromConfig, getPrintFormat, @@ -14,8 +14,8 @@ import * as process from 'process'; const hmacSecret = getHmacSecretFromConfig(); - const requestData: UpdateCallbackConfigurationRequestData = { - callbackConfigurationUpdateRequestBody: { + const requestData: Numbers.UpdateCallbackConfigurationRequestData = { + updateCallbackConfigurationRequestBody: { hmacSecret, }, }; diff --git a/examples/simple-examples/src/numbers/regions/list.ts b/examples/simple-examples/src/numbers/regions/list.ts index 506ce29b..e7c1aef6 100644 --- a/examples/simple-examples/src/numbers/regions/list.ts +++ b/examples/simple-examples/src/numbers/regions/list.ts @@ -1,4 +1,4 @@ -import { ListAvailableRegionsRequestData } from '@sinch/sdk-core'; +import { Numbers } from '@sinch/sdk-core'; import { getPrintFormat, initNumbersService, printFullResponse } from '../../config'; (async () => { @@ -6,7 +6,7 @@ import { getPrintFormat, initNumbersService, printFullResponse } from '../../con console.log('* NumberService_ListAvailableRegions *'); console.log('**************************************'); - const requestData: ListAvailableRegionsRequestData = { + const requestData: Numbers.ListAvailableRegionsRequestData = { types: ['LOCAL','MOBILE'], }; diff --git a/examples/simple-examples/src/sms/batches/cancel.ts b/examples/simple-examples/src/sms/batches/cancel.ts index d8a032ea..ffa5e5fa 100644 --- a/examples/simple-examples/src/sms/batches/cancel.ts +++ b/examples/simple-examples/src/sms/batches/cancel.ts @@ -4,7 +4,7 @@ import { initSmsServiceWithServicePlanId, printFullResponse, } from '../../config'; -import { CancelBatchMessageRequestData } from '@sinch/sdk-core'; +import { Sms } from '@sinch/sdk-core'; (async () => { console.log('**********************'); @@ -13,7 +13,7 @@ import { CancelBatchMessageRequestData } from '@sinch/sdk-core'; const batchIdInTheFuture = getBatchIdFromConfig(); - const requestData: CancelBatchMessageRequestData= { + const requestData: Sms.CancelBatchMessageRequestData= { batch_id: batchIdInTheFuture, }; diff --git a/examples/simple-examples/src/sms/batches/delivery-feedback.ts b/examples/simple-examples/src/sms/batches/delivery-feedback.ts index 77f62f67..889f7f46 100644 --- a/examples/simple-examples/src/sms/batches/delivery-feedback.ts +++ b/examples/simple-examples/src/sms/batches/delivery-feedback.ts @@ -3,7 +3,7 @@ import { getRecipientPhoneNumberFromConfig, initSmsServiceWithServicePlanId, } from '../../config'; -import { DeliveryFeedbackRequestData } from '@sinch/sdk-core'; +import { Sms } from '@sinch/sdk-core'; (async () => { console.log('********************'); @@ -13,7 +13,7 @@ import { DeliveryFeedbackRequestData } from '@sinch/sdk-core'; const batchIdInTheFuture = getBatchIdFromConfig(); const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); - const requestData: DeliveryFeedbackRequestData= { + const requestData: Sms.DeliveryFeedbackRequestData= { batch_id: batchIdInTheFuture, deliveryFeedbackRequestBody: { recipients: [ diff --git a/examples/simple-examples/src/sms/batches/dry-run.ts b/examples/simple-examples/src/sms/batches/dry-run.ts index 25cae327..35f7e4a4 100644 --- a/examples/simple-examples/src/sms/batches/dry-run.ts +++ b/examples/simple-examples/src/sms/batches/dry-run.ts @@ -5,7 +5,7 @@ import { initSmsServiceWithServicePlanId, printFullResponse, } from '../../config'; -import { DryRunRequestData } from '@sinch/sdk-core'; +import { Sms } from '@sinch/sdk-core'; (async () => { console.log('***********'); @@ -15,7 +15,7 @@ import { DryRunRequestData } from '@sinch/sdk-core'; const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); const senderPhoneNumber = getPhoneNumberFromConfig(); - const requestData: DryRunRequestData= { + const requestData: Sms.DryRunRequestData= { dryRunRequestBody: { type: 'mt_text', to: [ diff --git a/examples/simple-examples/src/sms/batches/get.ts b/examples/simple-examples/src/sms/batches/get.ts index 552a10d1..92cdfc76 100644 --- a/examples/simple-examples/src/sms/batches/get.ts +++ b/examples/simple-examples/src/sms/batches/get.ts @@ -4,7 +4,7 @@ import { printFullResponse, initSmsServiceWithServicePlanId, } from '../../config'; -import { GetBatchMessageRequestData } from '@sinch/sdk-core'; +import { Sms } from '@sinch/sdk-core'; (async () => { console.log('*******************'); @@ -13,7 +13,7 @@ import { GetBatchMessageRequestData } from '@sinch/sdk-core'; const batchId = getBatchIdFromConfig(); - const requestData: GetBatchMessageRequestData= { + const requestData: Sms.GetBatchMessageRequestData= { batch_id: batchId, }; diff --git a/examples/simple-examples/src/sms/batches/list.ts b/examples/simple-examples/src/sms/batches/list.ts index c2214711..6a5441e5 100644 --- a/examples/simple-examples/src/sms/batches/list.ts +++ b/examples/simple-examples/src/sms/batches/list.ts @@ -1,10 +1,9 @@ import { getPrintFormat, initSmsServiceWithServicePlanId, printFullResponse } from '../../config'; -import { ListBatchesRequestData, PageResult } from '@sinch/sdk-core'; -import { SendSMSResponse } from '@sinch/sms/src'; +import { Sms, PageResult } from '@sinch/sdk-core'; const populateBatchesList = ( - batchListPage: PageResult, - fullBatchesList: SendSMSResponse[], + batchListPage: PageResult, + fullBatchesList: Sms.SendSMSResponse[], batchesList: string[], ) => { fullBatchesList.push(...batchListPage.data); @@ -22,7 +21,7 @@ const populateBatchesList = ( oneWeekAgo.setDate(oneWeekAgo.getDate() - 7); oneWeekAgo.setHours(0, 0, 0, 0); - const requestData: ListBatchesRequestData= { + const requestData: Sms.ListBatchesRequestData= { start_date: oneWeekAgo, page_size: 2, }; @@ -34,7 +33,7 @@ const populateBatchesList = ( // ---------------------------------------------- let response = await smsService.batches.list(requestData); - const fullBatchesList: SendSMSResponse[] = []; + const fullBatchesList: Sms.SendSMSResponse[] = []; const batchesList: string[] = []; // Loop on all the pages to get all the batches diff --git a/examples/simple-examples/src/sms/batches/replace.ts b/examples/simple-examples/src/sms/batches/replace.ts index 41aec5a2..b8a6010b 100644 --- a/examples/simple-examples/src/sms/batches/replace.ts +++ b/examples/simple-examples/src/sms/batches/replace.ts @@ -5,7 +5,7 @@ import { initSmsServiceWithServicePlanId, printFullResponse, } from '../../config'; -import { BinaryRequest, ReplaceBatchMessageRequestData, textToHex } from '@sinch/sdk-core'; +import { Sms, textToHex } from '@sinch/sdk-core'; (async () => { console.log('****************'); @@ -16,7 +16,7 @@ import { BinaryRequest, ReplaceBatchMessageRequestData, textToHex } from '@sinch const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); const senderPhoneNumber = getPhoneNumberFromConfig(); - const requestData: ReplaceBatchMessageRequestData= { + const requestData: Sms.ReplaceBatchMessageRequestData= { batch_id: batchIdInTheFuture, replaceBatchMessageRequestBody: { from: senderPhoneNumber, @@ -28,7 +28,7 @@ import { BinaryRequest, ReplaceBatchMessageRequestData, textToHex } from '@sinch delivery_report: 'none', type: 'mt_binary', client_reference: 'Sinch Node.js SDK', - } as BinaryRequest, + } as Sms.BinaryRequest, }; const smsService = initSmsServiceWithServicePlanId(); diff --git a/examples/simple-examples/src/sms/batches/send.ts b/examples/simple-examples/src/sms/batches/send.ts index 49f02dd0..4fba2a77 100644 --- a/examples/simple-examples/src/sms/batches/send.ts +++ b/examples/simple-examples/src/sms/batches/send.ts @@ -5,7 +5,7 @@ import { initSmsServiceWithServicePlanId, printFullResponse, } from '../../config'; -import { SendSMSRequestData } from '@sinch/sdk-core'; +import { Sms } from '@sinch/sdk-core'; (async () => { console.log('***********'); @@ -18,7 +18,7 @@ import { SendSMSRequestData } from '@sinch/sdk-core'; const oneDayLater = new Date(); oneDayLater.setDate(oneDayLater.getDate() +1); - const requestData: SendSMSRequestData= { + const requestData: Sms.SendSMSRequestData= { sendSMSRequestBody: { type: 'mt_text', to: [ diff --git a/examples/simple-examples/src/sms/batches/sendBinaryMessage.ts b/examples/simple-examples/src/sms/batches/sendBinaryMessage.ts index 9b9e1823..2efe09f7 100644 --- a/examples/simple-examples/src/sms/batches/sendBinaryMessage.ts +++ b/examples/simple-examples/src/sms/batches/sendBinaryMessage.ts @@ -1,4 +1,4 @@ -import { SendBinarySMSRequestData, textToHex } from '@sinch/sdk-core'; +import { Sms, textToHex } from '@sinch/sdk-core'; import { getPhoneNumberFromConfig, getPrintFormat, @@ -15,7 +15,7 @@ import { const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); const senderPhoneNumber = getPhoneNumberFromConfig(); - const requestData: SendBinarySMSRequestData = { + const requestData: Sms.SendBinarySMSRequestData = { sendSMSRequestBody: { type: 'mt_binary', to: [ diff --git a/examples/simple-examples/src/sms/batches/sendMediaMessage.ts b/examples/simple-examples/src/sms/batches/sendMediaMessage.ts index 5187a046..efb7b812 100644 --- a/examples/simple-examples/src/sms/batches/sendMediaMessage.ts +++ b/examples/simple-examples/src/sms/batches/sendMediaMessage.ts @@ -1,4 +1,4 @@ -import { SendMediaSMSRequestData } from '@sinch/sdk-core'; +import { Sms } from '@sinch/sdk-core'; import { getPhoneNumberFromConfig, getPrintFormat, @@ -15,7 +15,7 @@ import { const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); const senderPhoneNumber = getPhoneNumberFromConfig(); - const requestData: SendMediaSMSRequestData = { + const requestData: Sms.SendMediaSMSRequestData = { sendSMSRequestBody: { type: 'mt_media', to: [ diff --git a/examples/simple-examples/src/sms/batches/sendTextMessage.ts b/examples/simple-examples/src/sms/batches/sendTextMessage.ts index efb97f8e..f76d779f 100644 --- a/examples/simple-examples/src/sms/batches/sendTextMessage.ts +++ b/examples/simple-examples/src/sms/batches/sendTextMessage.ts @@ -1,4 +1,4 @@ -import { SendTextSMSRequestData } from '@sinch/sdk-core'; +import { Sms } from '@sinch/sdk-core'; import { getPhoneNumberFromConfig, getPrintFormat, @@ -15,7 +15,7 @@ import { const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); const senderPhoneNumber = getPhoneNumberFromConfig(); - const requestData: SendTextSMSRequestData = { + const requestData: Sms.SendTextSMSRequestData = { sendSMSRequestBody: { type: 'mt_text', to: [ diff --git a/examples/simple-examples/src/sms/batches/update.ts b/examples/simple-examples/src/sms/batches/update.ts index 763e6bc3..dfc55f51 100644 --- a/examples/simple-examples/src/sms/batches/update.ts +++ b/examples/simple-examples/src/sms/batches/update.ts @@ -5,7 +5,7 @@ import { initSmsServiceWithServicePlanId, printFullResponse, } from '../../config'; -import { ApiUpdateTextMtMessage, UpdateBatchMessageRequestData } from '@sinch/sdk-core'; +import { Sms } from '@sinch/sdk-core'; (async () => { console.log('**********************'); @@ -16,7 +16,7 @@ import { ApiUpdateTextMtMessage, UpdateBatchMessageRequestData } from '@sinch/sd const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); const senderPhoneNumber = getPhoneNumberFromConfig(); - const requestData: UpdateBatchMessageRequestData= { + const requestData: Sms.UpdateBatchMessageRequestData= { batch_id: batchId, updateBatchMessageRequestBody: { from: senderPhoneNumber, @@ -29,7 +29,7 @@ import { ApiUpdateTextMtMessage, UpdateBatchMessageRequestData } from '@sinch/sd body: 'Hi ${name}! This is an updated message', delivery_report: 'none', type: 'mt_text', - } as ApiUpdateTextMtMessage, + } as Sms.ApiUpdateTextMtMessage, }; const smsService = initSmsServiceWithServicePlanId(); diff --git a/examples/simple-examples/src/sms/delivery-reports/getByBatchId.ts b/examples/simple-examples/src/sms/delivery-reports/getByBatchId.ts index b9ce3255..740e3690 100644 --- a/examples/simple-examples/src/sms/delivery-reports/getByBatchId.ts +++ b/examples/simple-examples/src/sms/delivery-reports/getByBatchId.ts @@ -4,7 +4,7 @@ import { initSmsServiceWithServicePlanId, printFullResponse, } from '../../config'; -import { GetDeliveryReportByBatchIdRequestData, MessageDeliveryStatus } from '@sinch/sdk-core'; +import { Sms } from '@sinch/sdk-core'; (async () => { console.log('******************************'); @@ -13,7 +13,7 @@ import { GetDeliveryReportByBatchIdRequestData, MessageDeliveryStatus } from '@s const batchId = getBatchIdFromConfig(); - const requestData: GetDeliveryReportByBatchIdRequestData = { + const requestData: Sms.GetDeliveryReportByBatchIdRequestData = { batch_id: batchId, }; @@ -30,7 +30,7 @@ import { GetDeliveryReportByBatchIdRequestData, MessageDeliveryStatus } from '@s if (printFormat === 'pretty') { const statuses: string[] = []; - response.statuses.map((status: MessageDeliveryStatus) => { + response.statuses.map((status: Sms.MessageDeliveryStatus) => { statuses.push(`${status.count} messages have the status ${status.code} - ${status.status}`); }); console.log(`Delivery report from batch ID: ${response.batch_id} - Type: ${response.type} - Statuses: ${statuses}`); diff --git a/examples/simple-examples/src/sms/delivery-reports/getForNumber.ts b/examples/simple-examples/src/sms/delivery-reports/getForNumber.ts index 66d333a2..e8b170aa 100644 --- a/examples/simple-examples/src/sms/delivery-reports/getForNumber.ts +++ b/examples/simple-examples/src/sms/delivery-reports/getForNumber.ts @@ -5,7 +5,7 @@ import { initSmsServiceWithServicePlanId, printFullResponse, } from '../../config'; -import { GetDeliveryReportByPhoneNumberRequestData } from '@sinch/sdk-core'; +import { Sms } from '@sinch/sdk-core'; (async () => { console.log('**********************************'); @@ -15,7 +15,7 @@ import { GetDeliveryReportByPhoneNumberRequestData } from '@sinch/sdk-core'; const batchId = getBatchIdFromConfig(); const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); - const requestData: GetDeliveryReportByPhoneNumberRequestData = { + const requestData: Sms.GetDeliveryReportByPhoneNumberRequestData = { batch_id: batchId, recipient_msisdn: recipientPhoneNumber, }; diff --git a/examples/simple-examples/src/sms/delivery-reports/list.ts b/examples/simple-examples/src/sms/delivery-reports/list.ts index 0c2045f8..976ccef2 100644 --- a/examples/simple-examples/src/sms/delivery-reports/list.ts +++ b/examples/simple-examples/src/sms/delivery-reports/list.ts @@ -1,13 +1,12 @@ import { getPrintFormat, initSmsServiceWithServicePlanId, printFullResponse } from '../../config'; import { - ListDeliveryReportsRequestData, PageResult, - RecipientDeliveryReport, + Sms, } from '@sinch/sdk-core'; const populateDeliveryReportsList = ( - deliveryReportsListPage: PageResult, - fullDeliveryReportsList: RecipientDeliveryReport[], + deliveryReportsListPage: PageResult, + fullDeliveryReportsList: Sms.RecipientDeliveryReport[], deliveryReportsList: string[], ) => { fullDeliveryReportsList.push(...deliveryReportsListPage.data); @@ -25,7 +24,7 @@ const populateDeliveryReportsList = ( oneWeekAgo.setDate(oneWeekAgo.getDate() - 7); oneWeekAgo.setHours(0, 0, 0, 0); - const requestData: ListDeliveryReportsRequestData= { + const requestData: Sms.ListDeliveryReportsRequestData= { start_date: oneWeekAgo, }; @@ -42,7 +41,7 @@ const populateDeliveryReportsList = ( throw error; } - const fullDeliveryReportsList: RecipientDeliveryReport[] = []; + const fullDeliveryReportsList: Sms.RecipientDeliveryReport[] = []; const deliveryReportsList: string[] = []; // Loop on all the pages to get all the delivery reports diff --git a/examples/simple-examples/src/sms/groups/create/create.ts b/examples/simple-examples/src/sms/groups/create/create.ts index ac74e48e..df6a5878 100644 --- a/examples/simple-examples/src/sms/groups/create/create.ts +++ b/examples/simple-examples/src/sms/groups/create/create.ts @@ -1,4 +1,4 @@ -import { CreateGroupRequestData, SmsService } from '@sinch/sdk-core'; +import { Sms, SmsService } from '@sinch/sdk-core'; import { getPrintFormat, printFullResponse } from '../../../config'; export const create = async(smsService: SmsService) => { @@ -6,13 +6,13 @@ export const create = async(smsService: SmsService) => { console.log('* CreateGroup *'); console.log('***************'); - const requestData: CreateGroupRequestData = { + const requestData: Sms.CreateGroupRequestData = { createGroupRequestBody: { name: `Group_${new Date().getTime()}`, members: [ - "+11111111100", - "+22222222200", - "+33333333300", + '+11111111100', + '+22222222200', + '+33333333300', ], }, }; diff --git a/examples/simple-examples/src/sms/groups/delete/delete.ts b/examples/simple-examples/src/sms/groups/delete/delete.ts index f2c71c03..e5a8a97f 100644 --- a/examples/simple-examples/src/sms/groups/delete/delete.ts +++ b/examples/simple-examples/src/sms/groups/delete/delete.ts @@ -1,4 +1,4 @@ -import { DeleteGroupRequestData, SmsService } from '@sinch/sdk-core'; +import { Sms, SmsService } from '@sinch/sdk-core'; import { getGroupIdFromConfig } from '../../../config'; export const deleteGroup = async(smsService: SmsService) => { @@ -8,7 +8,7 @@ export const deleteGroup = async(smsService: SmsService) => { const groupId = getGroupIdFromConfig(); - const requestData: DeleteGroupRequestData = { + const requestData: Sms.DeleteGroupRequestData = { group_id: groupId, }; diff --git a/examples/simple-examples/src/sms/groups/get/get.ts b/examples/simple-examples/src/sms/groups/get/get.ts index 7d0353f6..2d24b866 100644 --- a/examples/simple-examples/src/sms/groups/get/get.ts +++ b/examples/simple-examples/src/sms/groups/get/get.ts @@ -1,4 +1,4 @@ -import { GetGroupRequestData, SmsService } from '@sinch/sdk-core'; +import { Sms, SmsService } from '@sinch/sdk-core'; import { getGroupIdFromConfig, getPrintFormat, printFullResponse } from '../../../config'; export const get = async(smsService: SmsService) => { @@ -8,7 +8,7 @@ export const get = async(smsService: SmsService) => { const groupId = getGroupIdFromConfig(); - const requestData: GetGroupRequestData = { + const requestData: Sms.GetGroupRequestData = { group_id: groupId, }; diff --git a/examples/simple-examples/src/sms/groups/getPhoneNumbers/getPhoneNumbers.ts b/examples/simple-examples/src/sms/groups/getPhoneNumbers/getPhoneNumbers.ts index 48a2c043..f4e2d299 100644 --- a/examples/simple-examples/src/sms/groups/getPhoneNumbers/getPhoneNumbers.ts +++ b/examples/simple-examples/src/sms/groups/getPhoneNumbers/getPhoneNumbers.ts @@ -1,4 +1,4 @@ -import { ListMembersRequestData, SmsService } from '@sinch/sdk-core'; +import { Sms, SmsService } from '@sinch/sdk-core'; import { getGroupIdFromConfig, getPrintFormat, printFullResponse } from '../../../config'; export const getPhoneNumbers = async(smsService: SmsService) => { @@ -8,7 +8,7 @@ export const getPhoneNumbers = async(smsService: SmsService) => { const groupId = getGroupIdFromConfig(); - const requestData: ListMembersRequestData = { + const requestData: Sms.ListMembersRequestData = { group_id: groupId, }; diff --git a/examples/simple-examples/src/sms/groups/list/list.ts b/examples/simple-examples/src/sms/groups/list/list.ts index a7b220f8..da28f28d 100644 --- a/examples/simple-examples/src/sms/groups/list/list.ts +++ b/examples/simple-examples/src/sms/groups/list/list.ts @@ -1,20 +1,19 @@ import { - CreateGroupResponse, - ListGroupsRequestData, + Sms, PageResult, SmsService, } from '@sinch/sdk-core'; import { getPrintFormat, printFullResponse } from '../../../config'; const populateGroupsList = ( - groupsPage: PageResult, - fullGroupsList: CreateGroupResponse[], + groupsPage: PageResult, + fullGroupsList: Sms.CreateGroupResponse[], groupsList: string[], ) => { // Populate the data structure that holds the response content fullGroupsList.push(...groupsPage.data); // Populate the data structure that holds the response content for pretty print - groupsPage.data.map((group: CreateGroupResponse) => { + groupsPage.data.map((group: Sms.CreateGroupResponse) => { groupsList.push(`Group ID: ${group.id} - Group name: ${group.name}`); }); }; @@ -24,7 +23,7 @@ export const list = async(smsService: SmsService) => { console.log('* ListGroups *'); console.log('**************'); - const requestData: ListGroupsRequestData = { + const requestData: Sms.ListGroupsRequestData = { page_size: 1, }; @@ -40,7 +39,7 @@ export const list = async(smsService: SmsService) => { } // Init data structure to hold the response content - const fullGroupsList: CreateGroupResponse[] = []; + const fullGroupsList: Sms.CreateGroupResponse[] = []; // Init data structure to hold the response content for pretty print const groupsList: string[] = []; diff --git a/examples/simple-examples/src/sms/groups/replace/replace.ts b/examples/simple-examples/src/sms/groups/replace/replace.ts index 7c01a246..de23f155 100644 --- a/examples/simple-examples/src/sms/groups/replace/replace.ts +++ b/examples/simple-examples/src/sms/groups/replace/replace.ts @@ -1,4 +1,4 @@ -import { ReplaceGroupRequestData, SmsService } from '@sinch/sdk-core'; +import { Sms, SmsService } from '@sinch/sdk-core'; import { getGroupIdFromConfig, getPrintFormat, printFullResponse } from '../../../config'; export const replace = async(smsService: SmsService) => { @@ -8,7 +8,7 @@ export const replace = async(smsService: SmsService) => { const groupId = getGroupIdFromConfig(); - const requestData: ReplaceGroupRequestData = { + const requestData: Sms.ReplaceGroupRequestData = { group_id: groupId, replaceGroupRequestBody: { members: [ diff --git a/examples/simple-examples/src/sms/groups/update/update.ts b/examples/simple-examples/src/sms/groups/update/update.ts index 94ce6534..50230b10 100644 --- a/examples/simple-examples/src/sms/groups/update/update.ts +++ b/examples/simple-examples/src/sms/groups/update/update.ts @@ -1,4 +1,4 @@ -import { SmsService, UpdateGroupRequestData } from '@sinch/sdk-core'; +import { SmsService, Sms } from '@sinch/sdk-core'; import { getGroupIdFromConfig, getPrintFormat, printFullResponse } from '../../../config'; export const update = async(smsService: SmsService) => { @@ -8,7 +8,7 @@ export const update = async(smsService: SmsService) => { const groupId = getGroupIdFromConfig(); - const requestData: UpdateGroupRequestData = { + const requestData: Sms.UpdateGroupRequestData = { group_id: groupId, updateGroupRequestBody: { name: `update_${new Date().getTime()}`, diff --git a/examples/simple-examples/src/sms/inbounds/get.ts b/examples/simple-examples/src/sms/inbounds/get.ts index 6d8e06bb..eeee52e8 100644 --- a/examples/simple-examples/src/sms/inbounds/get.ts +++ b/examples/simple-examples/src/sms/inbounds/get.ts @@ -4,7 +4,7 @@ import { initSmsServiceWithServicePlanId, printFullResponse, } from '../../config'; -import { GetInboundMessageRequestData } from '@sinch/sdk-core'; +import { Sms } from '@sinch/sdk-core'; (async () => { console.log('**************************'); @@ -13,7 +13,7 @@ import { GetInboundMessageRequestData } from '@sinch/sdk-core'; const inboundId = getInboundIdFromConfig(); - const requestData: GetInboundMessageRequestData = { + const requestData: Sms.GetInboundMessageRequestData = { inbound_id: inboundId, }; diff --git a/examples/simple-examples/src/sms/inbounds/list.ts b/examples/simple-examples/src/sms/inbounds/list.ts index a36d09ab..9fa3f71a 100644 --- a/examples/simple-examples/src/sms/inbounds/list.ts +++ b/examples/simple-examples/src/sms/inbounds/list.ts @@ -5,14 +5,13 @@ import { printFullResponse, } from '../../config'; import { - InboundMessageResponse, - ListInboundMessagesRequestData, + Sms, PageResult, } from '@sinch/sdk-core'; const populateInboundMessagesList = ( - inboundMessagesListPage: PageResult, - fullInboundMessagesList: InboundMessageResponse[], + inboundMessagesListPage: PageResult, + fullInboundMessagesList: Sms.InboundMessageResponse[], inboundMessagesList: string[], ) => { fullInboundMessagesList.push(...inboundMessagesListPage.data); @@ -31,7 +30,7 @@ const populateInboundMessagesList = ( oneWeekAgo.setHours(0, 0, 0, 0); const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); - const requestData: ListInboundMessagesRequestData= { + const requestData: Sms.ListInboundMessagesRequestData= { start_date: oneWeekAgo, to: recipientPhoneNumber, }; @@ -49,7 +48,7 @@ const populateInboundMessagesList = ( throw error; } - const fullInboundMessagesList: InboundMessageResponse[] = []; + const fullInboundMessagesList: Sms.InboundMessageResponse[] = []; const inboundMessagesList: string[] = []; // Loop on all the pages to get all the batches diff --git a/examples/simple-examples/src/verification/verification-status/verification-by-id.ts b/examples/simple-examples/src/verification/verification-status/verification-by-id.ts index 19d3f509..b506deef 100644 --- a/examples/simple-examples/src/verification/verification-status/verification-by-id.ts +++ b/examples/simple-examples/src/verification/verification-status/verification-by-id.ts @@ -1,4 +1,4 @@ -import { VerificationStatusByIdRequestData } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationIdFromConfig, @@ -13,7 +13,7 @@ import { const verificationId = getVerificationIdFromConfig(); - const requestData: VerificationStatusByIdRequestData = { + const requestData: Verification.VerificationStatusByIdRequestData = { id: verificationId, }; diff --git a/examples/simple-examples/src/verification/verification-status/verification-by-identity.ts b/examples/simple-examples/src/verification/verification-status/verification-by-identity.ts index 9965fa50..b8bf2539 100644 --- a/examples/simple-examples/src/verification/verification-status/verification-by-identity.ts +++ b/examples/simple-examples/src/verification/verification-status/verification-by-identity.ts @@ -1,4 +1,4 @@ -import { VerificationStatusByIdentityRequestData } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationIdentityFromConfig, initVerificationService, printFullResponse } from '../../config'; (async () => { @@ -8,7 +8,7 @@ import { getPrintFormat, getVerificationIdentityFromConfig, initVerificationServ const verificationIdentity = getVerificationIdentityFromConfig(); - const requestData: VerificationStatusByIdentityRequestData = { + const requestData: Verification.VerificationStatusByIdentityRequestData = { endpoint: verificationIdentity, method: 'sms', }; diff --git a/examples/simple-examples/src/verification/verification-status/verification-by-reference.ts b/examples/simple-examples/src/verification/verification-status/verification-by-reference.ts index 3abee010..b2dc90bb 100644 --- a/examples/simple-examples/src/verification/verification-status/verification-by-reference.ts +++ b/examples/simple-examples/src/verification/verification-status/verification-by-reference.ts @@ -1,4 +1,4 @@ -import { VerificationStatusByReferenceRequestData } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationReferenceFromConfig, @@ -13,7 +13,7 @@ import { const verificationReference = getVerificationReferenceFromConfig(); - const requestData: VerificationStatusByReferenceRequestData = { + const requestData: Verification.VerificationStatusByReferenceRequestData = { reference: verificationReference, }; diff --git a/examples/simple-examples/src/verification/verifications/callout/report-with-id_callout.ts b/examples/simple-examples/src/verification/verifications/callout/report-with-id_callout.ts index 84640a79..60575953 100644 --- a/examples/simple-examples/src/verification/verifications/callout/report-with-id_callout.ts +++ b/examples/simple-examples/src/verification/verifications/callout/report-with-id_callout.ts @@ -1,4 +1,4 @@ -import { verificationsHelper } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationCodeFromConfig, @@ -15,7 +15,7 @@ import { const verificationId = getVerificationIdFromConfig(); const verificationCode = getVerificationCodeFromConfig(); - const requestData = verificationsHelper.buildReportCalloutVerificationByIdRequest( + const requestData = Verification.reportVerificationByIdHelper.buildCalloutRequest( verificationId, verificationCode); const verificationService = initVerificationService(); diff --git a/examples/simple-examples/src/verification/verifications/callout/report-with-identity_callout.ts b/examples/simple-examples/src/verification/verifications/callout/report-with-identity_callout.ts index 2bab3852..23662c77 100644 --- a/examples/simple-examples/src/verification/verifications/callout/report-with-identity_callout.ts +++ b/examples/simple-examples/src/verification/verifications/callout/report-with-identity_callout.ts @@ -1,8 +1,10 @@ -import { verificationsHelper } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationCodeFromConfig, - getVerificationIdentityFromConfig, initVerificationService, printFullResponse, + getVerificationIdentityFromConfig, + initVerificationService, + printFullResponse, } from '../../../config'; (async () => { @@ -13,7 +15,7 @@ import { const verificationIdentity = getVerificationIdentityFromConfig(); const verificationCode = getVerificationCodeFromConfig(); - const requestData = verificationsHelper.buildReportCalloutVerificationByIdentityRequest( + const requestData = Verification.reportVerificationByIdentityHelper.buildCalloutRequest( verificationIdentity, verificationCode); const verificationService = initVerificationService(); diff --git a/examples/simple-examples/src/verification/verifications/callout/start-callout.ts b/examples/simple-examples/src/verification/verifications/callout/start-callout.ts index 8a4c0d2e..1a0a6ddb 100644 --- a/examples/simple-examples/src/verification/verifications/callout/start-callout.ts +++ b/examples/simple-examples/src/verification/verifications/callout/start-callout.ts @@ -1,4 +1,4 @@ -import { verificationsHelper } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationIdentityFromConfig, @@ -13,7 +13,7 @@ import { const verificationIdentity = getVerificationIdentityFromConfig(); - const requestData = verificationsHelper.buildStartCalloutVerificationRequest( + const requestData = Verification.startVerificationHelper.buildCalloutRequest( verificationIdentity, `test-reference-for-callout-verification_${verificationIdentity}`, ); diff --git a/examples/simple-examples/src/verification/verifications/flashcall/report-with-id_flashcall.ts b/examples/simple-examples/src/verification/verifications/flashcall/report-with-id_flashcall.ts index 6992a046..df690087 100644 --- a/examples/simple-examples/src/verification/verifications/flashcall/report-with-id_flashcall.ts +++ b/examples/simple-examples/src/verification/verifications/flashcall/report-with-id_flashcall.ts @@ -1,4 +1,4 @@ -import { verificationsHelper } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationCliFromConfig, @@ -15,7 +15,7 @@ import { const verificationId = getVerificationIdFromConfig(); const verificationCli = getVerificationCliFromConfig(); - const requestData = verificationsHelper.buildReportFlashCallVerificationByIdRequest( + const requestData = Verification.reportVerificationByIdHelper.buildFlashCallRequest( verificationId, verificationCli); const verificationService = initVerificationService(); diff --git a/examples/simple-examples/src/verification/verifications/flashcall/report-with-identity_flashcall.ts b/examples/simple-examples/src/verification/verifications/flashcall/report-with-identity_flashcall.ts index 9b9e52ce..f93e37cd 100644 --- a/examples/simple-examples/src/verification/verifications/flashcall/report-with-identity_flashcall.ts +++ b/examples/simple-examples/src/verification/verifications/flashcall/report-with-identity_flashcall.ts @@ -1,4 +1,4 @@ -import { verificationsHelper } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationCliFromConfig, @@ -15,7 +15,7 @@ import { const verificationIdentity = getVerificationIdentityFromConfig(); const verificationCli = getVerificationCliFromConfig(); - const requestData = verificationsHelper.buildReportFlashCallVerificationByIdentityRequest( + const requestData = Verification.reportVerificationByIdentityHelper.buildFlashCallRequest( verificationIdentity, verificationCli); const verificationService = initVerificationService(); diff --git a/examples/simple-examples/src/verification/verifications/flashcall/start-flashcall.ts b/examples/simple-examples/src/verification/verifications/flashcall/start-flashcall.ts index fb66dc0f..125cf583 100644 --- a/examples/simple-examples/src/verification/verifications/flashcall/start-flashcall.ts +++ b/examples/simple-examples/src/verification/verifications/flashcall/start-flashcall.ts @@ -1,4 +1,4 @@ -import { verificationsHelper } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationIdentityFromConfig, @@ -13,7 +13,7 @@ import { const verificationIdentity = getVerificationIdentityFromConfig(); - const requestData = verificationsHelper.buildStartFlashCallVerificationRequest( + const requestData = Verification.startVerificationHelper.buildFlashCallRequest( verificationIdentity, `test-reference-for-flashCall-verification_${verificationIdentity}`, 20, diff --git a/examples/simple-examples/src/verification/verifications/seamless/start-seamless.ts b/examples/simple-examples/src/verification/verifications/seamless/start-seamless.ts index 7a590279..c72e5555 100644 --- a/examples/simple-examples/src/verification/verifications/seamless/start-seamless.ts +++ b/examples/simple-examples/src/verification/verifications/seamless/start-seamless.ts @@ -1,4 +1,4 @@ -import { verificationsHelper } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationIdentityFromConfig, @@ -13,7 +13,7 @@ import { const verificationIdentity = getVerificationIdentityFromConfig(); - const requestData = verificationsHelper.buildStartSeamlessVerificationRequest( + const requestData = Verification.startVerificationHelper.buildSeamlessRequest( verificationIdentity, `test-reference-for-seamless-verification_${verificationIdentity}`, ); diff --git a/examples/simple-examples/src/verification/verifications/sms/report-with-id_sms.ts b/examples/simple-examples/src/verification/verifications/sms/report-with-id_sms.ts index c8205d38..41a4536d 100644 --- a/examples/simple-examples/src/verification/verifications/sms/report-with-id_sms.ts +++ b/examples/simple-examples/src/verification/verifications/sms/report-with-id_sms.ts @@ -1,4 +1,4 @@ -import { verificationsHelper } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationCodeFromConfig, @@ -15,7 +15,7 @@ import { const verificationId = getVerificationIdFromConfig(); const verificationCode = getVerificationCodeFromConfig(); - const requestData = verificationsHelper.buildReportSmsVerificationByIdRequest( + const requestData = Verification.reportVerificationByIdHelper.buildSmsRequest( verificationId, verificationCode); const verificationService = initVerificationService(); diff --git a/examples/simple-examples/src/verification/verifications/sms/report-with-identity_sms.ts b/examples/simple-examples/src/verification/verifications/sms/report-with-identity_sms.ts index 89160f60..7ce8d82b 100644 --- a/examples/simple-examples/src/verification/verifications/sms/report-with-identity_sms.ts +++ b/examples/simple-examples/src/verification/verifications/sms/report-with-identity_sms.ts @@ -1,4 +1,4 @@ -import { verificationsHelper } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationCodeFromConfig, @@ -15,7 +15,7 @@ import { const verificationIdentity = getVerificationIdentityFromConfig(); const verificationCode = getVerificationCodeFromConfig(); - const requestData = verificationsHelper.buildReportSmsVerificationByIdentityRequest( + const requestData = Verification.reportVerificationByIdentityHelper.buildSmsRequest( verificationIdentity, verificationCode); const verificationService = initVerificationService(); diff --git a/examples/simple-examples/src/verification/verifications/sms/start-sms.ts b/examples/simple-examples/src/verification/verifications/sms/start-sms.ts index a432bec5..846413a7 100644 --- a/examples/simple-examples/src/verification/verifications/sms/start-sms.ts +++ b/examples/simple-examples/src/verification/verifications/sms/start-sms.ts @@ -1,4 +1,4 @@ -import { verificationsHelper } from '@sinch/sdk-core'; +import { Verification } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationIdentityFromConfig, @@ -13,7 +13,7 @@ import { const verificationIdentity = getVerificationIdentityFromConfig(); - const requestData = verificationsHelper.buildStartSmsVerificationRequest( + const requestData = Verification.startVerificationHelper.buildSmsRequest( verificationIdentity, `test-reference-for-sms-verification_${verificationIdentity}`, ); diff --git a/examples/simple-examples/src/voice/applications/assignNumbers.ts b/examples/simple-examples/src/voice/applications/assignNumbers.ts index 4faa0c43..587a87fc 100644 --- a/examples/simple-examples/src/voice/applications/assignNumbers.ts +++ b/examples/simple-examples/src/voice/applications/assignNumbers.ts @@ -3,7 +3,7 @@ import { getPhoneNumberFromConfig, initVoiceService, } from '../../config'; -import { AssignNumbersRequestData } from '@sinch/sdk-core'; +import { Voice } from '@sinch/sdk-core'; (async () => { console.log('*****************'); @@ -13,7 +13,7 @@ import { AssignNumbersRequestData } from '@sinch/sdk-core'; const phoneNumber = getPhoneNumberFromConfig(); const applicationKey = getApplicationKeyFromConfig(); - const requestData: AssignNumbersRequestData = { + const requestData: Voice.AssignNumbersRequestData = { assignNumbersRequestBody: { numbers: [phoneNumber], applicationkey: applicationKey, diff --git a/examples/simple-examples/src/voice/applications/getCallbackURLs.ts b/examples/simple-examples/src/voice/applications/getCallbackURLs.ts index d739829e..352cc14e 100644 --- a/examples/simple-examples/src/voice/applications/getCallbackURLs.ts +++ b/examples/simple-examples/src/voice/applications/getCallbackURLs.ts @@ -4,7 +4,7 @@ import { initVoiceService, printFullResponse, } from '../../config'; -import { GetCallbackURLsRequestData } from '@sinch/sdk-core'; +import { Voice } from '@sinch/sdk-core'; (async () => { console.log('*******************'); @@ -13,7 +13,7 @@ import { GetCallbackURLsRequestData } from '@sinch/sdk-core'; const applicationKey = getApplicationKeyFromConfig(); - const requestData: GetCallbackURLsRequestData = { + const requestData: Voice.GetCallbackURLsRequestData = { applicationkey: applicationKey, }; diff --git a/examples/simple-examples/src/voice/applications/getNumbers.ts b/examples/simple-examples/src/voice/applications/getNumbers.ts index a5be6348..502f6746 100644 --- a/examples/simple-examples/src/voice/applications/getNumbers.ts +++ b/examples/simple-examples/src/voice/applications/getNumbers.ts @@ -1,12 +1,16 @@ -import { getPrintFormat, initVoiceService, printFullResponse } from '../../config'; -import { GetNumbersRequestData } from '@sinch/sdk-core'; +import { + getPrintFormat, + initVoiceService, + printFullResponse, +} from '../../config'; +import { Voice } from '@sinch/sdk-core'; (async () => { console.log('**************'); console.log('* GetNumbers *'); console.log('**************'); - const requestData: GetNumbersRequestData = {}; + const requestData: Voice.GetNumbersRequestData = {}; const voiceService = initVoiceService(); let response; diff --git a/examples/simple-examples/src/voice/applications/queryNumber.ts b/examples/simple-examples/src/voice/applications/queryNumber.ts index 9b0517ba..09371ace 100644 --- a/examples/simple-examples/src/voice/applications/queryNumber.ts +++ b/examples/simple-examples/src/voice/applications/queryNumber.ts @@ -4,7 +4,7 @@ import { initVoiceService, printFullResponse, } from '../../config'; -import { QueryNumberRequestData } from '@sinch/sdk-core'; +import { Voice } from '@sinch/sdk-core'; (async () => { console.log('***********************'); @@ -13,7 +13,7 @@ import { QueryNumberRequestData } from '@sinch/sdk-core'; const phoneNumber = getPhoneNumberFromConfig(); - const requestData: QueryNumberRequestData = { + const requestData: Voice.QueryNumberRequestData = { number: phoneNumber, }; diff --git a/examples/simple-examples/src/voice/applications/unassignNumber.ts b/examples/simple-examples/src/voice/applications/unassignNumber.ts index bfb528fb..77e030ef 100644 --- a/examples/simple-examples/src/voice/applications/unassignNumber.ts +++ b/examples/simple-examples/src/voice/applications/unassignNumber.ts @@ -3,7 +3,7 @@ import { getPhoneNumberFromConfig, initVoiceService, } from '../../config'; -import { UnassignNumberRequestData } from '@sinch/sdk-core'; +import { Voice } from '@sinch/sdk-core'; (async () => { console.log('******************'); @@ -13,7 +13,7 @@ import { UnassignNumberRequestData } from '@sinch/sdk-core'; const phoneNumber = getPhoneNumberFromConfig(); const applicationKey = getApplicationKeyFromConfig(); - const requestData: UnassignNumberRequestData = { + const requestData: Voice.UnassignNumberRequestData = { unassignNumbersRequestBody: { number: phoneNumber, applicationkey: applicationKey, diff --git a/examples/simple-examples/src/voice/applications/updateCallbackURLs.ts b/examples/simple-examples/src/voice/applications/updateCallbackURLs.ts index 5bc15f53..176edde8 100644 --- a/examples/simple-examples/src/voice/applications/updateCallbackURLs.ts +++ b/examples/simple-examples/src/voice/applications/updateCallbackURLs.ts @@ -2,7 +2,7 @@ import { getApplicationKeyFromConfig, initVoiceService, } from '../../config'; -import { UpdateCallbackURLsRequestData } from '@sinch/sdk-core'; +import { Voice } from '@sinch/sdk-core'; (async () => { console.log('**********************'); @@ -11,7 +11,7 @@ import { UpdateCallbackURLsRequestData } from '@sinch/sdk-core'; const applicationKey = getApplicationKeyFromConfig(); - const requestData: UpdateCallbackURLsRequestData = { + const requestData: Voice.UpdateCallbackURLsRequestData = { applicationkey: applicationKey, updateCallbacksRequestBody: { url: { diff --git a/examples/simple-examples/src/voice/callouts/conference.ts b/examples/simple-examples/src/voice/callouts/conference.ts index 23b92786..151ee5f5 100644 --- a/examples/simple-examples/src/voice/callouts/conference.ts +++ b/examples/simple-examples/src/voice/callouts/conference.ts @@ -5,7 +5,7 @@ import { initVoiceService, printFullResponse, } from '../../config'; -import { ConferenceCalloutRequestData, VoiceRegion } from '@sinch/sdk-core'; +import { Voice, VoiceRegion } from '@sinch/sdk-core'; (async () => { console.log('*************************'); @@ -16,7 +16,7 @@ import { ConferenceCalloutRequestData, VoiceRegion } from '@sinch/sdk-core'; const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); const conferenceId = getConferenceIdFromConfig(); - const requestData: ConferenceCalloutRequestData = { + const requestData: Voice.ConferenceCalloutRequestData = { conferenceCalloutRequestBody: { method: 'conferenceCallout', conferenceCallout: { diff --git a/examples/simple-examples/src/voice/callouts/custom.ts b/examples/simple-examples/src/voice/callouts/custom.ts index cee0b33d..b6d273c8 100644 --- a/examples/simple-examples/src/voice/callouts/custom.ts +++ b/examples/simple-examples/src/voice/callouts/custom.ts @@ -6,13 +6,7 @@ import { initVoiceService, printFullResponse, } from '../../config'; -import { - aceActionHelper, - customCalloutHelper, - CustomCalloutRequestData, - iceActionHelper, - iceInstructionHelper, -} from '@sinch/sdk-core'; +import { Voice } from '@sinch/sdk-core'; (async () => { console.log('*********************'); @@ -23,7 +17,7 @@ import { const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); const callbackUrl = getVoiceCallBackUrl(); - const requestData: CustomCalloutRequestData = { + const requestData: Voice.CustomCalloutRequestData = { customCalloutRequestBody: { method: 'customCallout', customCallout: { @@ -33,19 +27,19 @@ import { endpoint: recipientPhoneNumber, }, custom: 'Custom text', - ice: customCalloutHelper.formatIceResponse( - iceActionHelper.connectPstn({ + ice: Voice.customCalloutHelper.formatIceResponse( + Voice.iceActionHelper.connectPstn({ number: recipientPhoneNumber, cli: callingNumber, }), - iceInstructionHelper.say('Welcome to Sinch.', 'en-US/male'), - iceInstructionHelper.startRecording({ + Voice.iceInstructionHelper.say('Welcome to Sinch.', 'en-US/male'), + Voice.iceInstructionHelper.startRecording({ destinationUrl: 'To specify', credentials: 'To specify', }), ), - ace: customCalloutHelper.formatAceResponse( - aceActionHelper.runMenu({ + ace: Voice.customCalloutHelper.formatAceResponse( + Voice.aceActionHelper.runMenu({ locale: 'Kimberly', enableVoice: true, barge: true, diff --git a/examples/simple-examples/src/voice/callouts/tts.ts b/examples/simple-examples/src/voice/callouts/tts.ts index ac6c92ce..74b52598 100644 --- a/examples/simple-examples/src/voice/callouts/tts.ts +++ b/examples/simple-examples/src/voice/callouts/tts.ts @@ -5,7 +5,7 @@ import { initVoiceService, printFullResponse, } from '../../config'; -import { TtsCalloutRequestData, VoiceRegion } from '@sinch/sdk-core'; +import { Voice, VoiceRegion } from '@sinch/sdk-core'; (async () => { console.log('******************'); @@ -15,7 +15,7 @@ import { TtsCalloutRequestData, VoiceRegion } from '@sinch/sdk-core'; const callingNumber = getPhoneNumberFromConfig(); const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); - const requestData: TtsCalloutRequestData = { + const requestData: Voice.TtsCalloutRequestData = { ttsCalloutRequestBody: { method: 'ttsCallout', ttsCallout: { diff --git a/examples/simple-examples/src/voice/calls/get.ts b/examples/simple-examples/src/voice/calls/get.ts index 492d0213..30d9d881 100644 --- a/examples/simple-examples/src/voice/calls/get.ts +++ b/examples/simple-examples/src/voice/calls/get.ts @@ -4,7 +4,7 @@ import { initVoiceService, printFullResponse, } from '../../config'; -import { GetCallResultRequestData, VoiceRegion } from '@sinch/sdk-core'; +import { Voice, VoiceRegion } from '@sinch/sdk-core'; (async () => { console.log('******************'); @@ -13,7 +13,7 @@ import { GetCallResultRequestData, VoiceRegion } from '@sinch/sdk-core'; const callId = getCallIdFromConfig(); - const requestData: GetCallResultRequestData = { + const requestData: Voice.GetCallResultRequestData = { callId, }; diff --git a/examples/simple-examples/src/voice/calls/manageWithCallLeg.ts b/examples/simple-examples/src/voice/calls/manageWithCallLeg.ts index 3ec32f1c..8c3837ed 100644 --- a/examples/simple-examples/src/voice/calls/manageWithCallLeg.ts +++ b/examples/simple-examples/src/voice/calls/manageWithCallLeg.ts @@ -2,7 +2,7 @@ import { getCallIdFromConfig, initVoiceService, } from '../../config'; -import { ManageWithCallLegRequestData, VoiceRegion } from '@sinch/sdk-core'; +import { Voice, VoiceRegion } from '@sinch/sdk-core'; (async () => { console.log('*************************'); @@ -11,7 +11,7 @@ import { ManageWithCallLegRequestData, VoiceRegion } from '@sinch/sdk-core'; const callId = getCallIdFromConfig(); - const requestData: ManageWithCallLegRequestData = { + const requestData: Voice.ManageWithCallLegRequestData = { callId, callLeg: 'callee', manageWithCallLegRequestBody: { diff --git a/examples/simple-examples/src/voice/calls/update.ts b/examples/simple-examples/src/voice/calls/update.ts index 53697296..d1e87d89 100644 --- a/examples/simple-examples/src/voice/calls/update.ts +++ b/examples/simple-examples/src/voice/calls/update.ts @@ -2,7 +2,7 @@ import { getCallIdFromConfig, initVoiceService, } from '../../config'; -import { UpdateCallRequestData, VoiceRegion } from '@sinch/sdk-core'; +import { Voice, VoiceRegion } from '@sinch/sdk-core'; (async () => { console.log('**************'); @@ -11,7 +11,7 @@ import { UpdateCallRequestData, VoiceRegion } from '@sinch/sdk-core'; const callId = getCallIdFromConfig(); - const requestData: UpdateCallRequestData = { + const requestData: Voice.UpdateCallRequestData = { callId, updateCallRequestBody: { instructions: [ diff --git a/examples/simple-examples/src/voice/conferences/get.ts b/examples/simple-examples/src/voice/conferences/get.ts index c84d31d3..2a3f0970 100644 --- a/examples/simple-examples/src/voice/conferences/get.ts +++ b/examples/simple-examples/src/voice/conferences/get.ts @@ -4,7 +4,7 @@ import { initVoiceService, printFullResponse, } from '../../config'; -import { GetConferenceInfoRequestData, VoiceRegion } from '@sinch/sdk-core'; +import { Voice, VoiceRegion } from '@sinch/sdk-core'; (async () => { console.log('*********************'); @@ -13,7 +13,7 @@ import { GetConferenceInfoRequestData, VoiceRegion } from '@sinch/sdk-core'; const conferenceId = getConferenceIdFromConfig(); - const requestData: GetConferenceInfoRequestData = { + const requestData: Voice.GetConferenceInfoRequestData = { conferenceId, }; diff --git a/examples/simple-examples/src/voice/conferences/kickAll.ts b/examples/simple-examples/src/voice/conferences/kickAll.ts index 24d20a0c..81ab6fc1 100644 --- a/examples/simple-examples/src/voice/conferences/kickAll.ts +++ b/examples/simple-examples/src/voice/conferences/kickAll.ts @@ -2,7 +2,7 @@ import { getConferenceIdFromConfig, initVoiceService, } from '../../config'; -import { KickAllRequestData, VoiceRegion } from '@sinch/sdk-core'; +import { Voice, VoiceRegion } from '@sinch/sdk-core'; (async () => { console.log('*********************'); @@ -11,7 +11,7 @@ import { KickAllRequestData, VoiceRegion } from '@sinch/sdk-core'; const conferenceId = getConferenceIdFromConfig(); - const requestData: KickAllRequestData = { + const requestData: Voice.KickAllRequestData = { conferenceId, }; diff --git a/examples/simple-examples/src/voice/conferences/kickParticipant.ts b/examples/simple-examples/src/voice/conferences/kickParticipant.ts index 96c7277e..6c7f188a 100644 --- a/examples/simple-examples/src/voice/conferences/kickParticipant.ts +++ b/examples/simple-examples/src/voice/conferences/kickParticipant.ts @@ -3,7 +3,7 @@ import { getConferenceIdFromConfig, initVoiceService, } from '../../config'; -import { KickParticipantRequestData, VoiceRegion } from '@sinch/sdk-core'; +import { Voice, VoiceRegion } from '@sinch/sdk-core'; (async () => { console.log('*****************************'); @@ -13,7 +13,7 @@ import { KickParticipantRequestData, VoiceRegion } from '@sinch/sdk-core'; const conferenceId = getConferenceIdFromConfig(); const callId = getCallIdFromConfig(); - const requestData: KickParticipantRequestData = { + const requestData: Voice.KickParticipantRequestData = { conferenceId, callId, }; diff --git a/examples/simple-examples/src/voice/conferences/manageParticipant.ts b/examples/simple-examples/src/voice/conferences/manageParticipant.ts index 4d15a201..0749ce8b 100644 --- a/examples/simple-examples/src/voice/conferences/manageParticipant.ts +++ b/examples/simple-examples/src/voice/conferences/manageParticipant.ts @@ -3,7 +3,7 @@ import { getConferenceIdFromConfig, initVoiceService, } from '../../config'; -import { ManageParticipantRequestData, VoiceRegion } from '@sinch/sdk-core'; +import { Voice, VoiceRegion } from '@sinch/sdk-core'; (async () => { console.log('*******************************'); @@ -13,7 +13,7 @@ import { ManageParticipantRequestData, VoiceRegion } from '@sinch/sdk-core'; const conferenceId = getConferenceIdFromConfig(); const callId = getCallIdFromConfig(); - const requestData: ManageParticipantRequestData = { + const requestData: Voice.ManageParticipantRequestData = { conferenceId, callId, manageParticipantRequestBody: { diff --git a/examples/webhooks/src/services/conversation-event.service.ts b/examples/webhooks/src/services/conversation-event.service.ts index f60fff03..87f06779 100644 --- a/examples/webhooks/src/services/conversation-event.service.ts +++ b/examples/webhooks/src/services/conversation-event.service.ts @@ -2,11 +2,8 @@ import { Injectable } from '@nestjs/common'; import { SinchClient, ConversationWebhookEventParsed, - ContactMessage, ConversationService, - messageBuilder, - ContactId, - SendMessageRequestData, + Conversation, } from '@sinch/sdk-core'; @Injectable() @@ -25,23 +22,23 @@ export class ConversationEventService { return new SinchClient({ projectId, keyId, keySecret }).conversation; }; - private buildContactMessage(contactMessage: ContactMessage) { + private buildContactMessage(contactMessage: Conversation.ContactMessage) { if ('text_message' in contactMessage && contactMessage.text_message) { - return messageBuilder.text({ + return Conversation.messageBuilder.text({ text: `Parrot mode 🦜: ${contactMessage.text_message.text}`, }); } if ('media_message' in contactMessage && contactMessage.media_message) { - return messageBuilder.media({ + return Conversation.messageBuilder.media({ url: contactMessage.media_message.url, }); } if ('fallback_message' in contactMessage && contactMessage.fallback_message && contactMessage.fallback_message.reason) { - return messageBuilder.text({ + return Conversation.messageBuilder.text({ text: `Error: ${contactMessage.fallback_message.reason.code} (${contactMessage.fallback_message.reason.sub_code})\n${contactMessage.fallback_message.reason.description}` }); } - return messageBuilder.text({ + return Conversation.messageBuilder.text({ text: `Impossible to handle the incoming message`, }); } @@ -54,7 +51,7 @@ export class ConversationEventService { const contactMessage = message.contact_message!; const channelIdentityTo = message.channel_identity!; console.log(`A new message has been received on the channel '${channelIdentityTo.channel}' (identity: ${channelIdentityTo.identity}) from the contact ID '${message.contact_id}':\n${JSON.stringify(contactMessage, null, 2)}`); - const requestData: SendMessageRequestData = { + const requestData: Conversation.SendMessageRequestData = { sendMessageRequestBody: { app_id: event.app_id!, recipient: { diff --git a/examples/webhooks/src/services/sms-event.service.ts b/examples/webhooks/src/services/sms-event.service.ts index 966860b3..53d6686e 100644 --- a/examples/webhooks/src/services/sms-event.service.ts +++ b/examples/webhooks/src/services/sms-event.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common'; -import { DeliveryReport, MOBinary, MOText, SmsCallback } from '@sinch/sdk-core'; +import { Sms, SmsCallback } from '@sinch/sdk-core'; @Injectable() export class SmsEventService { @@ -7,25 +7,25 @@ export class SmsEventService { handleEvent(event: SmsCallback): void { console.log(`:: INCOMING EVENT :: ${event.type}`); if (event.type === 'delivery_report_sms' || event.type === 'delivery_report_mms') { - return this.handleDeliveryReportEvent(event as DeliveryReport); + return this.handleDeliveryReportEvent(event as Sms.DeliveryReport); } else if (event.type === 'mo_text') { - return this.handleSmsEvent(event as MOText); + return this.handleSmsEvent(event as Sms.MOText); } else if (event.type === 'mo_binary') { - return this.handleMmsEvent(event as MOBinary); + return this.handleMmsEvent(event as Sms.MOBinary); } else { throw new Error(`Unexpected event: ${JSON.stringify(event)}`); } } - private handleDeliveryReportEvent(event: DeliveryReport): void { + private handleDeliveryReportEvent(event: Sms.DeliveryReport): void { console.log(`The batch ${event.batch_id} has the following statuses:\n${event.statuses.map((status) => ' - \'' + status.status + '\' for the recipients: ' + status.recipients.join(', ')).join('\n')} `); } - private handleSmsEvent(event: MOText): void { + private handleSmsEvent(event: Sms.MOText): void { console.log(`A SMS sent by ${event.from} has been received by ${event.to} at ${event.received_at}. The content is:\n"${event.body}"`); } - private handleMmsEvent(event: MOBinary): void { + private handleMmsEvent(event: Sms.MOBinary): void { console.log(`A MMS sent by ${event.from} has been received by ${event.to} at ${event.received_at}.`); } } diff --git a/examples/webhooks/src/services/verification-event.service.ts b/examples/webhooks/src/services/verification-event.service.ts index de1b9959..ca8ce9d7 100644 --- a/examples/webhooks/src/services/verification-event.service.ts +++ b/examples/webhooks/src/services/verification-event.service.ts @@ -1,12 +1,8 @@ import { Injectable } from '@nestjs/common'; import { Response } from 'express'; import { - CalloutRequestEventResponse, - FlashCallRequestEventResponse, - SMSRequestEventResponse, + Verification, VerificationCallback, - VerificationRequestEvent, - VerificationResultEvent, } from '@sinch/sdk-core'; @Injectable() @@ -16,18 +12,18 @@ export class VerificationEventService { console.log(`:: INCOMING EVENT :: ${event.event}`); switch (event.event) { case 'VerificationRequestEvent': - return this.handleVerificationRequestEvent(event as VerificationRequestEvent, res); + return this.handleVerificationRequestEvent(event as Verification.VerificationRequestEvent, res); case 'VerificationResultEvent': - return this.handleVerificationResultEvent(event as VerificationResultEvent, res); + return this.handleVerificationResultEvent(event as Verification.VerificationResultEvent, res); default: throw new Error(`Unexpected event: ${JSON.stringify(event)}`); } } - private handleVerificationRequestEvent(event: VerificationRequestEvent, res: Response) { + private handleVerificationRequestEvent(event: Verification.VerificationRequestEvent, res: Response) { switch (event.method) { case 'sms': - const smsRequestEventResponse: SMSRequestEventResponse = { + const smsRequestEventResponse: Verification.SMSRequestEventResponse = { action: 'allow', sms: { code: '123456' @@ -36,7 +32,7 @@ export class VerificationEventService { res.status(200).json(smsRequestEventResponse); break; case 'callout': - const calloutRequestEventResponse: CalloutRequestEventResponse = { + const calloutRequestEventResponse: Verification.CalloutRequestEventResponse = { action: 'allow', callout: { code: '123456', @@ -48,7 +44,7 @@ export class VerificationEventService { res.status(200).json(calloutRequestEventResponse); break; case 'flashcall': - const flashcallRequestEventResponse: FlashCallRequestEventResponse = { + const flashcallRequestEventResponse: Verification.FlashCallRequestEventResponse = { action: 'allow', flashCall: { dialTimeout: 5000 @@ -61,7 +57,7 @@ export class VerificationEventService { } } - private handleVerificationResultEvent(event: VerificationResultEvent, res: Response) { + private handleVerificationResultEvent(event: Verification.VerificationResultEvent, res: Response) { console.log(`Result of the verification:\n - method: ${event.method}\n - identity: ${event.identity.endpoint}\n - status: ${event.status}\n - reason: ${event.reason}`) res.status(200).send(); } diff --git a/examples/webhooks/src/services/voice-event.service.ts b/examples/webhooks/src/services/voice-event.service.ts index fcda0688..ba85be68 100644 --- a/examples/webhooks/src/services/voice-event.service.ts +++ b/examples/webhooks/src/services/voice-event.service.ts @@ -1,20 +1,8 @@ import { Injectable } from '@nestjs/common'; import { Response } from 'express'; import { - aceActionHelper, - AceRequest, - AceSvamletBuilder, - DiceRequest, - iceActionHelper, - iceInstructionHelper, - IceRequest, - IceSvamletBuilder, - NotifyRequest, - pieActionHelper, - pieInstructionHelper, - PieRequest, - PieSvamletBuilder, VoiceCallback, + Voice, } from '@sinch/sdk-core'; @Injectable() @@ -24,38 +12,38 @@ export class VoiceEventService { console.log(`:: INCOMING EVENT :: ${event.event}`); switch (event.event) { case 'ice': - this.handleIceRequest(event as IceRequest, res); + this.handleIceRequest(event as Voice.IceRequest, res); break; case 'ace': - this.handleAceRequest(event as AceRequest, res); + this.handleAceRequest(event as Voice.AceRequest, res); break; case 'dice': - this.handleDiceRequest(event as DiceRequest, res); + this.handleDiceRequest(event as Voice.DiceRequest, res); break; case 'pie': - this.handlePieRequest(event as PieRequest, res); + this.handlePieRequest(event as Voice.PieRequest, res); break; case 'notify': - this.handleNotifyRequest(event as NotifyRequest, res); + this.handleNotifyRequest(event as Voice.NotifyRequest, res); break; default: throw new Error(`Unexpected event: ${JSON.stringify(event)}`); } } - private handleIceRequest(event: IceRequest, res: Response) { + private handleIceRequest(event: Voice.IceRequest, res: Response) { console.log(`ICE request: CLI = ${event.cli} - To = ${event.to?.endpoint} (${event.to?.type})`) - const iceResponse = new IceSvamletBuilder() - .setAction(iceActionHelper.hangup()) - .addInstruction(iceInstructionHelper.say('Thank you for calling Sinch! This call will now end.', 'en-US')) + const iceResponse = new Voice.IceSvamletBuilder() + .setAction(Voice.iceActionHelper.hangup()) + .addInstruction(Voice.iceInstructionHelper.say('Thank you for calling Sinch! This call will now end.', 'en-US')) .build(); res.status(200).json(iceResponse); } - private handleAceRequest(event: AceRequest, res: Response) { + private handleAceRequest(event: Voice.AceRequest, res: Response) { console.log(`ACE request: Call answered at '${event.timestamp?.toISOString()}'`); - const aceResponse = new AceSvamletBuilder() - .setAction(aceActionHelper.runMenu({ + const aceResponse = new Voice.AceSvamletBuilder() + .setAction(Voice.aceActionHelper.runMenu({ barge: true, menus: [ { @@ -85,22 +73,22 @@ export class VoiceEventService { res.status(200).json(aceResponse); } - private handleDiceRequest(event: DiceRequest, res: Response) { + private handleDiceRequest(event: Voice.DiceRequest, res: Response) { console.log(`DICE request: Call disconnected at '${event.timestamp?.toISOString()}' with the reason '${event.reason}'.`); res.status(200).send(); } - private handlePieRequest(event: PieRequest, res: Response) { + private handlePieRequest(event: Voice.PieRequest, res: Response) { console.log(`PIE request: IVR menu choice: '${event.menuResult?.value}'`); - const pieResponse = new PieSvamletBuilder() - .setAction(pieActionHelper.hangup()) - .addInstruction(pieInstructionHelper.say('Thanks for your input. The call will end after some music.')) - .addInstruction(pieInstructionHelper.playFiles(['https://samples-files.com/samples/Audio/mp3/sample-file-4.mp3'])) + const pieResponse = new Voice.PieSvamletBuilder() + .setAction(Voice.pieActionHelper.hangup()) + .addInstruction(Voice.pieInstructionHelper.say('Thanks for your input. The call will end after some music.')) + .addInstruction(Voice.pieInstructionHelper.playFiles(['https://samples-files.com/samples/Audio/mp3/sample-file-4.mp3'])) .build(); res.status(200).send(pieResponse); } - private handleNotifyRequest(event: NotifyRequest, res: Response) { + private handleNotifyRequest(event: Voice.NotifyRequest, res: Response) { console.log(`Notification received: "${event.type}"`); res.status(200).send(); } diff --git a/packages/conversation/README.md b/packages/conversation/README.md index 8bf8f926..3cedab11 100644 --- a/packages/conversation/README.md +++ b/packages/conversation/README.md @@ -41,8 +41,7 @@ import { ConversationService, SinchClient, UnifiedCredentials, - SendMessageRequestData, - SendMessageResponse, + Conversation, } from '@sinch/sdk-core'; const credentials: UnifiedCredentials = { @@ -56,7 +55,7 @@ const sinch = new SinchClient(credentials); const conversationService: ConversationService = sinch.conversation; // Build the request data -const requestData: SendMessageRequestData = { +const requestData: Conversation.SendMessageRequestData = { sendMessageRequestBody: { app_id: 'CONVERSATION_APP_ID', message: { @@ -74,7 +73,7 @@ const requestData: SendMessageRequestData = { }; // Use the 'conversation' service registered on the Sinch client -const result: SendMessageResponse +const result: Conversation.SendMessageResponse = await conversationService.messages.send(requestData); ``` @@ -88,8 +87,7 @@ import { } from '@sinch/sdk-client'; import { ConversationService, - SendMessageRequestData, - SendMessageResponse, + Conversation, } from '@sinch/conversation'; const credentials: UnifiedCredentials = { @@ -102,7 +100,7 @@ const credentials: UnifiedCredentials = { const conversationService = new ConversationService(options); // Build the request data -const requestData: SendMessageRequestData = { +const requestData: Conversation.SendMessageRequestData = { sendMessageRequestBody: { app_id: 'CONVERSATION_APP_ID', message: { @@ -120,7 +118,7 @@ const requestData: SendMessageRequestData = { }; // Use the standalone declaration of the 'conversation' service -const result: SendMessageResponse +const result: Conversation.SendMessageResponse = await conversationService.messages.send(requestData); ``` @@ -130,7 +128,7 @@ All the methods that interact with the Sinch APIs use Promises. You can use `awa ```typescript // Method 1: Wait for the Promise to complete -let result: SendMessageResponse; +let result: Conversation.SendMessageResponse; try { result = await conversationService.messages.send(requestData); console.log(`Message sent successfully. Message Id: ${result.id}`); diff --git a/packages/conversation/src/index.ts b/packages/conversation/src/index.ts index 20936a85..078adbec 100644 --- a/packages/conversation/src/index.ts +++ b/packages/conversation/src/index.ts @@ -1,3 +1,3 @@ -export * from './models'; +export * as Conversation from './models'; export * from './rest'; export * from '@sinch/sdk-client'; diff --git a/packages/conversation/src/models/v1/enums.ts b/packages/conversation/src/models/v1/enums.ts index e715ca56..5fe74f1e 100644 --- a/packages/conversation/src/models/v1/enums.ts +++ b/packages/conversation/src/models/v1/enums.ts @@ -41,3 +41,5 @@ export type ProcessingMode = 'CONVERSATION' | 'DISPATCH'; export type ProcessingStrategy = 'DEFAULT' | 'DISPATCH_ONLY'; export type WebhookTargetType = 'DISMISS' | 'HTTP'; + +export type MessageSource = 'CONVERSATION_SOURCE' | 'DISPATCH_SOURCE'; diff --git a/packages/conversation/src/models/v1/index.ts b/packages/conversation/src/models/v1/index.ts index da0f794f..89982cdf 100644 --- a/packages/conversation/src/models/v1/index.ts +++ b/packages/conversation/src/models/v1/index.ts @@ -107,5 +107,6 @@ export * from './whatsapp-interactive-text-header'; export * from './whatsapp-interactive-video-header'; export * from './enums'; export * from './helper'; +export * from './requests'; export * from './mod-callback-events'; export * from './mod-credentials'; diff --git a/packages/conversation/src/models/v1/requests/app/app-request-data.ts b/packages/conversation/src/models/v1/requests/app/app-request-data.ts new file mode 100644 index 00000000..30915d98 --- /dev/null +++ b/packages/conversation/src/models/v1/requests/app/app-request-data.ts @@ -0,0 +1,25 @@ +import { AppCreateRequest } from '../../app-create-request'; +import { AppUpdateRequest } from '../../app-update-request'; + +export interface CreateAppRequestData { + /** The app to create. */ + 'appCreateRequestBody': AppCreateRequest; +} +export interface DeleteAppRequestData { + /** The unique ID of the app. You can find this on the [Sinch Dashboard](https://dashboard.sinch.com/convapi/apps). */ + 'app_id': string; +} +export interface GetAppRequestData { + /** The unique ID of the app. You can find this on the [Sinch Dashboard](https://dashboard.sinch.com/convapi/apps). */ + 'app_id': string; +} +export interface ListAppsRequestData { +} +export interface UpdateAppRequestData { + /** The unique ID of the app. You can find this on the [Sinch Dashboard](https://dashboard.sinch.com/convapi/apps). */ + 'app_id': string; + /** The updated app. */ + 'appUpdateRequestBody': AppUpdateRequest; + /** The set of field mask paths. */ + 'update_mask'?: Array; +} diff --git a/packages/conversation/src/models/v1/requests/capability/capability-request-data.ts b/packages/conversation/src/models/v1/requests/capability/capability-request-data.ts new file mode 100644 index 00000000..e447be18 --- /dev/null +++ b/packages/conversation/src/models/v1/requests/capability/capability-request-data.ts @@ -0,0 +1,7 @@ +import { Recipient } from '../../recipient'; +import { LookupCapabilityRequest } from '../../lookup-capability-request'; + +export interface LookupCapabilityRequestData { + /** The lookup capability request. */ + 'lookupCapabilityRequestBody': LookupCapabilityRequest; +} diff --git a/packages/conversation/src/models/v1/requests/contact/contact-request-data.ts b/packages/conversation/src/models/v1/requests/contact/contact-request-data.ts new file mode 100644 index 00000000..695745c0 --- /dev/null +++ b/packages/conversation/src/models/v1/requests/contact/contact-request-data.ts @@ -0,0 +1,49 @@ +import { ContactCreateRequest } from '../../contact-create-request'; +import { Recipient } from '../../recipient'; +import { GetChannelProfileRequest } from '../../get-channel-profile-request'; +import { ConversationChannel } from '../../conversation-channel'; +import { MergeContactRequest } from '../../merge-contact-request'; +import { Contact } from '../../contact'; + +export interface CreateContactRequestData { + /** The contact to create. */ + 'contactCreateRequestBody': ContactCreateRequest; +} +export interface DeleteContactRequestData { + /** The unique ID of the contact. */ + 'contact_id': string; +} +export interface GetChannelProfileRequestData { + /** */ + 'getChannelProfileRequestBody': GetChannelProfileRequest; +} +export interface GetContactRequestData { + /** The unique ID of the contact. */ + 'contact_id': string; +} +export interface ListContactsRequestData { + /** Optional. The maximum number of contacts to fetch. The default is 10 and the maximum is 20. */ + 'page_size'?: number; + /** Optional. Next page token previously returned if any. */ + 'page_token'?: string; + /** Optional. Contact identifier in an external system. If used, `channel` and `identity` query parameters can\'t be used. */ + 'external_id'?: string; + /** Optional. Specifies a channel, and must be set to one of the enum values. If set, the `identity` parameter must be set and `external_id` can\'t be used. Used in conjunction with `identity` to uniquely identify the specified channel identity. */ + 'channel'?: ConversationChannel; + /** Optional. If set, the `channel` parameter must be set and `external_id` can\'t be used. Used in conjunction with `channel` to uniquely identify the specified channel identity. This will differ from channel to channel. For example, a phone number for SMS, WhatsApp, and Viber Business. */ + 'identity'?: string; +} +export interface MergeContactRequestData { + /** The unique ID of the contact that should be kept when merging two contacts. */ + 'destination_id': string; + /** The contact to be removed. */ + 'mergeContactRequestBody': MergeContactRequest; +} +export interface UpdateContactRequestData { + /** The unique ID of the contact. */ + 'contact_id': string; + /** The updated contact. */ + 'updateContactRequestBody': Contact; + /** The set of field mask paths. */ + 'update_mask'?: Array; +} diff --git a/packages/conversation/src/models/v1/requests/conversation/conversation-request-data.ts b/packages/conversation/src/models/v1/requests/conversation/conversation-request-data.ts new file mode 100644 index 00000000..c2be28fc --- /dev/null +++ b/packages/conversation/src/models/v1/requests/conversation/conversation-request-data.ts @@ -0,0 +1,72 @@ +import { CreateConversationRequest } from '../../create-conversation-request'; +import { InjectConversationEventRequest } from '../../inject-conversation-event-request'; +import { InjectMessageRequest } from '../../inject-message-request'; +import { ConversationChannel } from '../../conversation-channel'; +import { Conversation } from '../../conversation'; +import { ConversationMetadataUpdateStrategy } from '../../enums'; + +export interface CreateConversationRequestData { + /** The conversation to create. ID will be generated for the conversation and any ID in the given conversation will be ignored. */ + 'createConversationRequestBody': CreateConversationRequest; +} +export interface DeleteConversationRequestData { + /** The unique ID of the conversation. This is generated by the system. */ + 'conversation_id': string; +} +export interface GetConversationRequestData { + /** The unique ID of the conversation. This is generated by the system. */ + 'conversation_id': string; +} +export interface InjectEventRequestData { + /** The unique ID of the conversation. This is generated by the system. */ + 'conversation_id': string; + /** Inject event request */ + 'injectConversationEventRequestBody': InjectConversationEventRequest; +} +export interface InjectMessageRequestData { + /** The ID of the conversation. */ + 'conversation_id': string; + /** Message to be injected. */ + 'injectMessageRequestBody': InjectMessageRequest; +} +export interface ListConversationsRequestData { + /** Required. True if only active conversations should be listed. */ + 'only_active': boolean; + /** The ID of the app involved in the conversations. Note that either `app_id` or `contact_id` is required in order for the operation to function correctly. */ + 'app_id'?: string; + /** Resource name (ID) of the contact. Note that either `app_id` or `contact_id` is required in order for the operation to function correctly. */ + 'contact_id'?: string; + /** The maximum number of conversations to fetch. Defaults to 10 and the maximum is 20. */ + 'page_size'?: number; + /** Next page token previously returned if any. */ + 'page_token'?: string; + /** Only fetch conversations from the `active_channel` */ + 'active_channel'?: ConversationChannel; +} +export interface ListRecentConversationsRequestData { + /** The application ID */ + 'app_id': string; + /** True if only active conversations should be listed. Default is false. */ + 'only_active'?: boolean; + /** The maximum number of conversations to fetch. Defaults to 10 and the maximum value is 50. */ + 'page_size'?: number; + /** Next page token previously returned if any. When specifying this token, make sure to use the same values + * for the other parameters from the request that originated the token, otherwise the paged results may be inconsistent. */ + 'page_token'?: string; + /** Whether to sort conversations by newest message first or oldest. Default is DESC (newest first) */ + 'order'?: 'ASC' | 'DESC'; +} +export interface StopActiveConversationRequestData { + /** The unique ID of the conversation. This is generated by the system. */ + 'conversation_id': string; +} +export interface UpdateConversationRequestData { + /** The unique ID of the conversation. This is generated by the system. */ + 'conversation_id': string; + /** The updated conversation. */ + 'updateConversationRequestBody': Conversation; + /** The set of field mask paths. */ + 'update_mask'?: Array; + /** Update strategy for the `conversation_metadata` field. */ + 'metadata_update_strategy'?: ConversationMetadataUpdateStrategy; +} diff --git a/packages/conversation/src/models/v1/requests/events/events-request-data.ts b/packages/conversation/src/models/v1/requests/events/events-request-data.ts new file mode 100644 index 00000000..9b9db7e0 --- /dev/null +++ b/packages/conversation/src/models/v1/requests/events/events-request-data.ts @@ -0,0 +1,56 @@ +import { Recipient } from '../../recipient'; +import { + SendAgentJoinedEventRequest, SendAgentLeftEventRequest, + SendCommentReplyEventRequest, + SendComposingEndEventRequest, + SendComposingEventRequest, + SendEventRequest, SendGenericEventRequest, +} from '../../send-event-request'; + +export interface DeleteEventRequestData { + /** The unique ID of the event. */ + 'event_id': string; +} +export interface GetEventRequestData { + /** The unique ID of the event. */ + 'event_id': string; +} +export interface ListEventsRequestData { + /** Resource name (id) of the conversation. One of conversation_id or contact_id needs to be present. */ + 'conversation_id'?: string; + /** Resource name (id) of the contact. One of conversation_id or contact_id needs to be present. */ + 'contact_id'?: string; + /** Maximum number of events to fetch. Defaults to 10 and the maximum is 20. */ + 'page_size'?: number; + /** Next page token previously returned if any. When specifying this token, make sure to use the same values + * for the other parameters from the request that originated the token, otherwise the paged results may be inconsistent. */ + 'page_token'?: string; +} +export interface SendEventRequestData { + /** The event to be sent. */ + 'sendEventRequestBody': SendEventRequest; +} +export interface SendComposingEventRequestData { + /** The event to be sent. */ + 'sendEventRequestBody': SendComposingEventRequest; +} +export interface SendComposingEndEventRequestData { + /** The event to be sent. */ + 'sendEventRequestBody': SendComposingEndEventRequest; +} +export interface SendCommentReplyEventRequestData { + /** The event to be sent. */ + 'sendEventRequestBody': SendCommentReplyEventRequest; +} +export interface SendAgentJoinedEventRequestData { + /** The event to be sent. */ + 'sendEventRequestBody': SendAgentJoinedEventRequest; +} +export interface SendAgentLeftEventRequestData { + /** The event to be sent. */ + 'sendEventRequestBody': SendAgentLeftEventRequest; +} +export interface SendGenericEventRequestData { + /** The event to be sent. */ + 'sendEventRequestBody': SendGenericEventRequest; +} diff --git a/packages/conversation/src/models/v1/requests/index.ts b/packages/conversation/src/models/v1/requests/index.ts new file mode 100644 index 00000000..6836e2ff --- /dev/null +++ b/packages/conversation/src/models/v1/requests/index.ts @@ -0,0 +1,10 @@ +export * from './app/app-request-data'; +export * from './capability/capability-request-data'; +export * from './contact/contact-request-data'; +export * from './conversation/conversation-request-data'; +export * from './events/events-request-data'; +export * from './messages/messages-request-data'; +export * from './templates-v1/templates-v1-request-data'; +export * from './templates-v2/templates-v2-request-data'; +export * from './transcoding/transcoding-request-data'; +export * from './webhooks/webhooks-request-data'; diff --git a/packages/conversation/src/models/v1/requests/messages/messages-request-data.ts b/packages/conversation/src/models/v1/requests/messages/messages-request-data.ts new file mode 100644 index 00000000..791d76ef --- /dev/null +++ b/packages/conversation/src/models/v1/requests/messages/messages-request-data.ts @@ -0,0 +1,101 @@ +import { ConversationMessagesView, MessageSource } from '../../enums'; +import { ConversationChannel } from '../../conversation-channel'; +import { Recipient } from '../../recipient'; +import { + SendCardMessageRequest, + SendCarouselMessageRequest, + SendChoiceMessageRequest, + SendContactInfoMessageRequest, + SendListMessageRequest, + SendLocationMessageRequest, + SendMediaMessageRequest, + SendMessageRequest, SendTemplateMessageRequest, SendTextMessageRequest, +} from '../../send-message-request'; +import { UpdateMessageRequest } from '../../update-message-request'; + +export interface DeleteMessageRequestData { + /** The unique ID of the message. */ + 'message_id': string; + /** Specifies the message source for which the request will be processed. Used for operations on messages in Dispatch Mode. For more information, see [Processing Modes](../../../../../conversation/processing-modes/). */ + 'messages_source'?: MessageSource; +} +export interface GetMessageRequestData { + /** The unique ID of the message. */ + 'message_id': string; + /** Specifies the message source for which the request will be processed. Used for operations on messages in Dispatch Mode. For more information, see [Processing Modes](../../../../../conversation/processing-modes/). */ + 'messages_source'?: MessageSource; +} +export interface ListMessagesRequestData { + /** Resource name (ID) of the conversation. */ + 'conversation_id'?: string; + /** Resource name (ID) of the contact. */ + 'contact_id'?: string; + /** Id of the app. */ + 'app_id'?: string; + /** Channel identity of the contact. */ + 'channel_identity'?: string; + /** Filter messages with `accept_time` after this timestamp. Must be before `end_time` if that is specified. */ + 'start_time'?: Date; + /** Filter messages with `accept_time` before this timestamp. */ + 'end_time'?: Date; + /** Maximum number of messages to fetch. Defaults to 10 and the maximum is 1000. */ + 'page_size'?: number; + /** Next page token previously returned if any. When specifying this token, make sure to use the same values for the other parameters from the request that originated the token, otherwise the paged results may be inconsistent. */ + 'page_token'?: string; + /** */ + 'view'?: ConversationMessagesView; + /** Specifies the message source for which the request will be processed. Used for operations on messages in Dispatch Mode. For more information, see [Processing Modes](../../../../../conversation/processing-modes/). */ + 'messages_source'?: MessageSource; + /** If true, fetch only recipient originated messages. Available only when `messages_source` is `DISPATCH_SOURCE`. */ + 'only_recipient_originated'?: boolean; + /** Only fetch messages from the `channel`. */ + 'channel'?: ConversationChannel; +} +export interface SendMessageRequestData { + /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ + 'sendMessageRequestBody': SendMessageRequest; +} +export interface SendCardMessageRequestData { + /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ + 'sendMessageRequestBody': SendCardMessageRequest; +} +export interface SendCarouselMessageRequestData { + /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ + 'sendMessageRequestBody': SendCarouselMessageRequest; +} +export interface SendChoiceMessageRequestData { + /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ + 'sendMessageRequestBody': SendChoiceMessageRequest; +} +export interface SendContactInfoMessageRequestData { + /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ + 'sendMessageRequestBody': SendContactInfoMessageRequest; +} +export interface SendListMessageRequestData { + /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ + 'sendMessageRequestBody': SendListMessageRequest; +} +export interface SendLocationMessageRequestData { + /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ + 'sendMessageRequestBody': SendLocationMessageRequest; +} +export interface SendMediaMessageRequestData { + /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ + 'sendMessageRequestBody': SendMediaMessageRequest; +} +export interface SendTemplateMessageRequestData { + /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ + 'sendMessageRequestBody': SendTemplateMessageRequest; +} +export interface SendTextMessageRequestData { + /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ + 'sendMessageRequestBody': SendTextMessageRequest; +} +export interface UpdateMessageRequestData { + /** The unique ID of the message. */ + 'message_id': string; + /** Update message metadata request. */ + 'updateMessageRequestBody': UpdateMessageRequest; + /** Specifies the message source for which the request will be processed. Used for operations on messages in Dispatch Mode. For more information, see [Processing Modes](../../../../../conversation/processing-modes/). */ + 'messages_source'?: 'CONVERSATION_SOURCE' | 'DISPATCH_SOURCE'; +} diff --git a/packages/conversation/src/models/v1/requests/templates-v1/templates-v1-request-data.ts b/packages/conversation/src/models/v1/requests/templates-v1/templates-v1-request-data.ts new file mode 100644 index 00000000..55946f5f --- /dev/null +++ b/packages/conversation/src/models/v1/requests/templates-v1/templates-v1-request-data.ts @@ -0,0 +1,24 @@ +import { V1Template } from '../../v1-template'; + +export interface CreateTemplateRequestData { + /** Required. The template to create. */ + 'createTemplateRequestBody': V1Template; +} +export interface DeleteTemplateRequestData { + /** Required. The ID of the template to fetch. */ + 'template_id': string; +} +export interface GetTemplateRequestData { + /** Required. The ID of the template to fetch. */ + 'template_id': string; +} +export interface ListTemplatesRequestData { +} +export interface UpdateTemplateRequestData { + /** The id of the template to be updated. Specified or automatically generated during template creation. Unique per project. */ + 'template_id': string; + /** Required. The updated template. */ + 'updateTemplateRequestBody': V1Template; + /** The set of field mask paths. */ + 'update_mask'?: Array; +} diff --git a/packages/conversation/src/models/v1/requests/templates-v2/templates-v2-request-data.ts b/packages/conversation/src/models/v1/requests/templates-v2/templates-v2-request-data.ts new file mode 100644 index 00000000..a1ec21e5 --- /dev/null +++ b/packages/conversation/src/models/v1/requests/templates-v2/templates-v2-request-data.ts @@ -0,0 +1,30 @@ +import { V2Template } from '../../v2-template'; + +export interface V2CreateTemplateRequestData { + /** Required. The template to create. */ + 'createTemplateRequestBody': V2Template; +} +export interface V2DeleteTemplateRequestData { + /** Required. The ID of the template to delete. */ + 'template_id': string; +} +export interface V2GetTemplateRequestData { + /** Required. The ID of the template to fetch. */ + 'template_id': string; +} +export interface V2ListTemplatesRequestData { +} +export interface V2ListTranslationsRequestData { + /** Required. The template ID. */ + 'template_id': string; + /** Optional. The translation's language code. */ + 'language_code'?: string; + /** Optional. The translation's version. */ + 'translation_version'?: string; +} +export interface V2UpdateTemplateRequestData { + /** The id of the template to be updated. Specified or automatically generated during template creation. Unique per project. */ + 'template_id': string; + /** Required. The updated template. */ + 'updateTemplateRequestBody': V2Template; +} diff --git a/packages/conversation/src/models/v1/requests/transcoding/transcoding-request-data.ts b/packages/conversation/src/models/v1/requests/transcoding/transcoding-request-data.ts new file mode 100644 index 00000000..187643f4 --- /dev/null +++ b/packages/conversation/src/models/v1/requests/transcoding/transcoding-request-data.ts @@ -0,0 +1,6 @@ +import { TranscodeMessageRequest } from '../../transcode-message-request'; + +export interface TranscodeMessageRequestData { + /** The message to be transcoded, and the app and channels for which the message is to be transcoded. */ + 'transcodeMessageRequestBody': TranscodeMessageRequest; +} diff --git a/packages/conversation/src/models/v1/requests/webhooks/webhooks-request-data.ts b/packages/conversation/src/models/v1/requests/webhooks/webhooks-request-data.ts new file mode 100644 index 00000000..4212795a --- /dev/null +++ b/packages/conversation/src/models/v1/requests/webhooks/webhooks-request-data.ts @@ -0,0 +1,26 @@ +import { Webhook } from '../../webhook'; + +export interface CreateWebhookRequestData { + /** Required. The Webhook to create */ + 'webhookCreateRequestBody': Webhook; +} +export interface DeleteWebhookRequestData { + /** The unique ID of the webhook. */ + 'webhook_id': string; +} +export interface GetWebhookRequestData { + /** The unique ID of the webhook. */ + 'webhook_id': string; +} +export interface ListWebhooksRequestData { + /** The unique ID of the app. You can find this on the [Sinch Dashboard](https://dashboard.sinch.com/convapi/apps). */ + 'app_id': string; +} +export interface UpdateWebhookRequestData { + /** The unique ID of the webhook. */ + 'webhook_id': string; + /** Required. The Webhook to update */ + 'webhookUpdateRequestBody': Webhook; + /** The set of field mask paths. */ + 'update_mask'?: Array; +} diff --git a/packages/conversation/src/rest/v1/app/app-api.jest.fixture.ts b/packages/conversation/src/rest/v1/app/app-api.jest.fixture.ts index f9d80dde..c9c61c02 100644 --- a/packages/conversation/src/rest/v1/app/app-api.jest.fixture.ts +++ b/packages/conversation/src/rest/v1/app/app-api.jest.fixture.ts @@ -1,6 +1,13 @@ -import { AppResponse } from '../../../models'; -import { ListAppsResponse } from '../../../models'; -import { AppApi, CreateAppRequestData, DeleteAppRequestData, GetAppRequestData, ListAppsRequestData, UpdateAppRequestData } from './app-api'; +import { AppApi } from './app-api'; +import { + AppResponse, + ListAppsResponse, + CreateAppRequestData, + DeleteAppRequestData, + GetAppRequestData, + ListAppsRequestData, + UpdateAppRequestData, +} from '../../../models'; export class AppApiFixture implements Partial> { @@ -25,4 +32,3 @@ export class AppApiFixture implements Partial> { */ public update: jest.Mock, [UpdateAppRequestData]> = jest.fn(); } - diff --git a/packages/conversation/src/rest/v1/app/app-api.ts b/packages/conversation/src/rest/v1/app/app-api.ts index 78d481d2..e06cdd8a 100644 --- a/packages/conversation/src/rest/v1/app/app-api.ts +++ b/packages/conversation/src/rest/v1/app/app-api.ts @@ -3,36 +3,16 @@ import { SinchClientParameters, } from '@sinch/sdk-client'; import { - AppCreateRequest, AppResponse, - AppUpdateRequest, + CreateAppRequestData, + DeleteAppRequestData, + GetAppRequestData, + ListAppsRequestData, ListAppsResponse, + UpdateAppRequestData, } from '../../../models'; import { ConversationDomainApi } from '../conversation-domain-api'; -export interface CreateAppRequestData { - /** The app to create. */ - 'appCreateRequestBody': AppCreateRequest; -} -export interface DeleteAppRequestData { - /** The unique ID of the app. You can find this on the [Sinch Dashboard](https://dashboard.sinch.com/convapi/apps). */ - 'app_id': string; -} -export interface GetAppRequestData { - /** The unique ID of the app. You can find this on the [Sinch Dashboard](https://dashboard.sinch.com/convapi/apps). */ - 'app_id': string; -} -export interface ListAppsRequestData { -} -export interface UpdateAppRequestData { - /** The unique ID of the app. You can find this on the [Sinch Dashboard](https://dashboard.sinch.com/convapi/apps). */ - 'app_id': string; - /** The updated app. */ - 'appUpdateRequestBody': AppUpdateRequest; - /** The set of field mask paths. */ - 'update_mask'?: Array; -} - export class AppApi extends ConversationDomainApi { /** diff --git a/packages/conversation/src/rest/v1/capability/capability-api.jest.fixture.ts b/packages/conversation/src/rest/v1/capability/capability-api.jest.fixture.ts index 863c2a1b..16a904bf 100644 --- a/packages/conversation/src/rest/v1/capability/capability-api.jest.fixture.ts +++ b/packages/conversation/src/rest/v1/capability/capability-api.jest.fixture.ts @@ -1,5 +1,9 @@ -import { LookupCapabilityResponse, Recipient } from '../../../models'; -import { CapabilityApi, LookupCapabilityRequestData } from './capability-api'; +import { CapabilityApi } from './capability-api'; +import { + LookupCapabilityRequestData, + LookupCapabilityResponse, + Recipient, +} from '../../../models'; export class CapabilityApiFixture implements Partial> { @@ -12,4 +16,3 @@ export class CapabilityApiFixture implements Partial> { > = jest.fn(); } - diff --git a/packages/conversation/src/rest/v1/capability/capability-api.ts b/packages/conversation/src/rest/v1/capability/capability-api.ts index e62cd2fa..d2e10baf 100644 --- a/packages/conversation/src/rest/v1/capability/capability-api.ts +++ b/packages/conversation/src/rest/v1/capability/capability-api.ts @@ -3,17 +3,12 @@ import { SinchClientParameters, } from '@sinch/sdk-client'; import { - LookupCapabilityRequest, + LookupCapabilityRequestData, LookupCapabilityResponse, Recipient, } from '../../../models'; import { ConversationDomainApi } from '../conversation-domain-api'; -export interface LookupCapabilityRequestData { - /** The lookup capability request. */ - 'lookupCapabilityRequestBody': LookupCapabilityRequest; -} - export class CapabilityApi extends ConversationDomainApi { /** diff --git a/packages/conversation/src/rest/v1/contact/contact-api.jest.fixture.ts b/packages/conversation/src/rest/v1/contact/contact-api.jest.fixture.ts index 87fa1fa1..38d81f02 100644 --- a/packages/conversation/src/rest/v1/contact/contact-api.jest.fixture.ts +++ b/packages/conversation/src/rest/v1/contact/contact-api.jest.fixture.ts @@ -1,7 +1,8 @@ -import { Contact, Recipient } from '../../../models'; -import { GetChannelProfileResponse } from '../../../models'; +import { ApiListPromise } from '@sinch/sdk-client'; +import { ContactApi } from './contact-api'; import { - ContactApi, + Contact, + Recipient, CreateContactRequestData, DeleteContactRequestData, GetChannelProfileRequestData, @@ -9,8 +10,8 @@ import { ListContactsRequestData, MergeContactRequestData, UpdateContactRequestData, -} from './contact-api'; -import { ApiListPromise } from '@sinch/sdk-client'; + GetChannelProfileResponse, +} from '../../../models'; export class ContactApiFixture implements Partial> { @@ -46,4 +47,3 @@ export class ContactApiFixture implements Partial> { */ public update: jest.Mock, [UpdateContactRequestData]> = jest.fn(); } - diff --git a/packages/conversation/src/rest/v1/contact/contact-api.ts b/packages/conversation/src/rest/v1/contact/contact-api.ts index 11b0f181..2d3d3f21 100644 --- a/packages/conversation/src/rest/v1/contact/contact-api.ts +++ b/packages/conversation/src/rest/v1/contact/contact-api.ts @@ -9,58 +9,17 @@ import { } from '@sinch/sdk-client'; import { Contact, - ContactCreateRequest, - ConversationChannel, - GetChannelProfileRequest, + CreateContactRequestData, + DeleteContactRequestData, + GetChannelProfileRequestData, GetChannelProfileResponse, - MergeContactRequest, + GetContactRequestData, + ListContactsRequestData, + MergeContactRequestData, Recipient, + UpdateContactRequestData, } from '../../../models'; import { ConversationDomainApi } from '../conversation-domain-api'; - -export interface CreateContactRequestData { - /** The contact to create. */ - 'contactCreateRequestBody': ContactCreateRequest; -} -export interface DeleteContactRequestData { - /** The unique ID of the contact. */ - 'contact_id': string; -} -export interface GetChannelProfileRequestData { - /** */ - 'getChannelProfileRequestBody': GetChannelProfileRequest; -} -export interface GetContactRequestData { - /** The unique ID of the contact. */ - 'contact_id': string; -} -export interface ListContactsRequestData { - /** Optional. The maximum number of contacts to fetch. The default is 10 and the maximum is 20. */ - 'page_size'?: number; - /** Optional. Next page token previously returned if any. */ - 'page_token'?: string; - /** Optional. Contact identifier in an external system. If used, `channel` and `identity` query parameters can\'t be used. */ - 'external_id'?: string; - /** Optional. Specifies a channel, and must be set to one of the enum values. If set, the `identity` parameter must be set and `external_id` can\'t be used. Used in conjunction with `identity` to uniquely identify the specified channel identity. */ - 'channel'?: ConversationChannel; - /** Optional. If set, the `channel` parameter must be set and `external_id` can\'t be used. Used in conjunction with `channel` to uniquely identify the specified channel identity. This will differ from channel to channel. For example, a phone number for SMS, WhatsApp, and Viber Business. */ - 'identity'?: string; -} -export interface MergeContactRequestData { - /** The unique ID of the contact that should be kept when merging two contacts. */ - 'destination_id': string; - /** The contact to be removed. */ - 'mergeContactRequestBody': MergeContactRequest; -} -export interface UpdateContactRequestData { - /** The unique ID of the contact. */ - 'contact_id': string; - /** The updated contact. */ - 'updateContactRequestBody': Contact; - /** The set of field mask paths. */ - 'update_mask'?: Array; -} - export class ContactApi extends ConversationDomainApi { /** diff --git a/packages/conversation/src/rest/v1/conversation/conversation-api.jest.fixture.ts b/packages/conversation/src/rest/v1/conversation/conversation-api.jest.fixture.ts index b71a5c0a..713a3036 100644 --- a/packages/conversation/src/rest/v1/conversation/conversation-api.jest.fixture.ts +++ b/packages/conversation/src/rest/v1/conversation/conversation-api.jest.fixture.ts @@ -1,6 +1,9 @@ -import { Conversation, ConversationRecentMessage, InjectEventResponse } from '../../../models'; +import { ApiListPromise } from '@sinch/sdk-client'; +import { ConversationApi } from './conversation-api'; import { - ConversationApi, + Conversation, + ConversationRecentMessage, + InjectEventResponse, CreateConversationRequestData, DeleteConversationRequestData, GetConversationRequestData, @@ -10,8 +13,7 @@ import { ListRecentConversationsRequestData, StopActiveConversationRequestData, UpdateConversationRequestData, -} from './conversation-api'; -import { ApiListPromise } from '@sinch/sdk-client'; +} from '../../../models'; export class ConversationApiFixture implements Partial> { @@ -53,4 +55,3 @@ export class ConversationApiFixture implements Partial */ public update: jest.Mock, [UpdateConversationRequestData]> = jest.fn(); } - diff --git a/packages/conversation/src/rest/v1/conversation/conversation-api.ts b/packages/conversation/src/rest/v1/conversation/conversation-api.ts index fb90f6f1..5fc11c5a 100644 --- a/packages/conversation/src/rest/v1/conversation/conversation-api.ts +++ b/packages/conversation/src/rest/v1/conversation/conversation-api.ts @@ -9,82 +9,20 @@ import { } from '@sinch/sdk-client'; import { Conversation, - ConversationChannel, - InjectMessageRequest, - ConversationMetadataUpdateStrategy, ConversationRecentMessage, - CreateConversationRequest, + CreateConversationRequestData, + DeleteConversationRequestData, + GetConversationRequestData, + InjectEventRequestData, InjectEventResponse, - InjectConversationEventRequest, + InjectMessageRequestData, + ListConversationsRequestData, + ListRecentConversationsRequestData, + StopActiveConversationRequestData, + UpdateConversationRequestData, } from '../../../models'; import { ConversationDomainApi } from '../conversation-domain-api'; -export interface CreateConversationRequestData { - /** The conversation to create. ID will be generated for the conversation and any ID in the given conversation will be ignored. */ - 'createConversationRequestBody': CreateConversationRequest; -} -export interface DeleteConversationRequestData { - /** The unique ID of the conversation. This is generated by the system. */ - 'conversation_id': string; -} -export interface GetConversationRequestData { - /** The unique ID of the conversation. This is generated by the system. */ - 'conversation_id': string; -} -export interface InjectEventRequestData { - /** The unique ID of the conversation. This is generated by the system. */ - 'conversation_id': string; - /** Inject event request */ - 'injectConversationEventRequestBody': InjectConversationEventRequest; -} -export interface InjectMessageRequestData { - /** The ID of the conversation. */ - 'conversation_id': string; - /** Message to be injected. */ - 'injectMessageRequestBody': InjectMessageRequest; -} -export interface ListConversationsRequestData { - /** Required. True if only active conversations should be listed. */ - 'only_active': boolean; - /** The ID of the app involved in the conversations. Note that either `app_id` or `contact_id` is required in order for the operation to function correctly. */ - 'app_id'?: string; - /** Resource name (ID) of the contact. Note that either `app_id` or `contact_id` is required in order for the operation to function correctly. */ - 'contact_id'?: string; - /** The maximum number of conversations to fetch. Defaults to 10 and the maximum is 20. */ - 'page_size'?: number; - /** Next page token previously returned if any. */ - 'page_token'?: string; - /** Only fetch conversations from the `active_channel` */ - 'active_channel'?: ConversationChannel; -} -export interface ListRecentConversationsRequestData { - /** The application ID */ - 'app_id': string; - /** True if only active conversations should be listed. Default is false. */ - 'only_active'?: boolean; - /** The maximum number of conversations to fetch. Defaults to 10 and the maximum value is 50. */ - 'page_size'?: number; - /** Next page token previously returned if any. When specifying this token, make sure to use the same values - * for the other parameters from the request that originated the token, otherwise the paged results may be inconsistent. */ - 'page_token'?: string; - /** Whether to sort conversations by newest message first or oldest. Default is DESC (newest first) */ - 'order'?: 'ASC' | 'DESC'; -} -export interface StopActiveConversationRequestData { - /** The unique ID of the conversation. This is generated by the system. */ - 'conversation_id': string; -} -export interface UpdateConversationRequestData { - /** The unique ID of the conversation. This is generated by the system. */ - 'conversation_id': string; - /** The updated conversation. */ - 'updateConversationRequestBody': Conversation; - /** The set of field mask paths. */ - 'update_mask'?: Array; - /** Update strategy for the `conversation_metadata` field. */ - 'metadata_update_strategy'?: ConversationMetadataUpdateStrategy; -} - export class ConversationApi extends ConversationDomainApi { /** diff --git a/packages/conversation/src/rest/v1/enums.ts b/packages/conversation/src/rest/v1/enums.ts deleted file mode 100644 index a6a425ee..00000000 --- a/packages/conversation/src/rest/v1/enums.ts +++ /dev/null @@ -1 +0,0 @@ -export type MessageSource = 'CONVERSATION_SOURCE' | 'DISPATCH_SOURCE'; diff --git a/packages/conversation/src/rest/v1/events/events-api.jest.fixture.ts b/packages/conversation/src/rest/v1/events/events-api.jest.fixture.ts index 2abf5497..f11484a9 100644 --- a/packages/conversation/src/rest/v1/events/events-api.jest.fixture.ts +++ b/packages/conversation/src/rest/v1/events/events-api.jest.fixture.ts @@ -1,7 +1,9 @@ -import { ConversationEvent, Recipient, SendEventResponse } from '../../../models'; +import { ApiListPromise } from '@sinch/sdk-client'; +import { EventsApi } from './events-api'; import { + ConversationEvent, DeleteEventRequestData, - EventsApi, + Recipient, GetEventRequestData, ListEventsRequestData, SendAgentJoinedEventRequestData, @@ -11,8 +13,8 @@ import { SendComposingEventRequestData, SendEventRequestData, SendGenericEventRequestData, -} from './events-api'; -import { ApiListPromise } from '@sinch/sdk-client'; + SendEventResponse, +} from '../../../models'; export class EventsApiFixture implements Partial> { @@ -75,4 +77,3 @@ export class EventsApiFixture implements Partial> { [SendGenericEventRequestData] > = jest.fn(); } - diff --git a/packages/conversation/src/rest/v1/events/events-api.ts b/packages/conversation/src/rest/v1/events/events-api.ts index 496e878c..87afe850 100644 --- a/packages/conversation/src/rest/v1/events/events-api.ts +++ b/packages/conversation/src/rest/v1/events/events-api.ts @@ -10,66 +10,21 @@ import { import { Conversation, ConversationEvent, + DeleteEventRequestData, + GetEventRequestData, + ListEventsRequestData, Recipient, - SendAgentJoinedEventRequest, - SendAgentLeftEventRequest, - SendCommentReplyEventRequest, - SendComposingEndEventRequest, - SendComposingEventRequest, - SendEventRequest, + SendAgentJoinedEventRequestData, + SendAgentLeftEventRequestData, + SendCommentReplyEventRequestData, + SendComposingEndEventRequestData, + SendComposingEventRequestData, + SendEventRequestData, SendEventResponse, - SendGenericEventRequest, + SendGenericEventRequestData, } from '../../../models'; import { ConversationDomainApi } from '../conversation-domain-api'; -export interface DeleteEventRequestData { - /** The unique ID of the event. */ - 'event_id': string; -} -export interface GetEventRequestData { - /** The unique ID of the event. */ - 'event_id': string; -} -export interface ListEventsRequestData { - /** Resource name (id) of the conversation. One of conversation_id or contact_id needs to be present. */ - 'conversation_id'?: string; - /** Resource name (id) of the contact. One of conversation_id or contact_id needs to be present. */ - 'contact_id'?: string; - /** Maximum number of events to fetch. Defaults to 10 and the maximum is 20. */ - 'page_size'?: number; - /** Next page token previously returned if any. When specifying this token, make sure to use the same values - * for the other parameters from the request that originated the token, otherwise the paged results may be inconsistent. */ - 'page_token'?: string; -} -export interface SendEventRequestData { - /** The event to be sent. */ - 'sendEventRequestBody': SendEventRequest; -} -export interface SendComposingEventRequestData { - /** The event to be sent. */ - 'sendEventRequestBody': SendComposingEventRequest; -} -export interface SendComposingEndEventRequestData { - /** The event to be sent. */ - 'sendEventRequestBody': SendComposingEndEventRequest; -} -export interface SendCommentReplyEventRequestData { - /** The event to be sent. */ - 'sendEventRequestBody': SendCommentReplyEventRequest; -} -export interface SendAgentJoinedEventRequestData { - /** The event to be sent. */ - 'sendEventRequestBody': SendAgentJoinedEventRequest; -} -export interface SendAgentLeftEventRequestData { - /** The event to be sent. */ - 'sendEventRequestBody': SendAgentLeftEventRequest; -} -export interface SendGenericEventRequestData { - /** The event to be sent. */ - 'sendEventRequestBody': SendGenericEventRequest; -} - export class EventsApi extends ConversationDomainApi { /** diff --git a/packages/conversation/src/rest/v1/index.ts b/packages/conversation/src/rest/v1/index.ts index d86bda6b..8e762f14 100644 --- a/packages/conversation/src/rest/v1/index.ts +++ b/packages/conversation/src/rest/v1/index.ts @@ -9,5 +9,4 @@ export * from './templates-v1'; export * from './templates-v2'; export * from './transcoding'; export * from './webhooks'; -export * from './enums'; export * from './conversation-service'; diff --git a/packages/conversation/src/rest/v1/messages/messages-api.jest.fixture.ts b/packages/conversation/src/rest/v1/messages/messages-api.jest.fixture.ts index 62e4a839..d1d2c579 100644 --- a/packages/conversation/src/rest/v1/messages/messages-api.jest.fixture.ts +++ b/packages/conversation/src/rest/v1/messages/messages-api.jest.fixture.ts @@ -1,6 +1,9 @@ -import { ConversationMessage, Recipient, SendMessageResponse } from '../../../models'; +import { ApiListPromise } from '@sinch/sdk-client'; +import { MessagesApi } from './messages-api'; import { - MessagesApi, + ConversationMessage, + Recipient, + SendMessageResponse, DeleteMessageRequestData, GetMessageRequestData, ListMessagesRequestData, @@ -15,8 +18,7 @@ import { SendMediaMessageRequestData, SendTemplateMessageRequestData, SendMessageRequestData, -} from './messages-api'; -import { ApiListPromise } from '@sinch/sdk-client'; +} from '../../../models'; export class MessagesApiFixture implements Partial> { diff --git a/packages/conversation/src/rest/v1/messages/messages-api.ts b/packages/conversation/src/rest/v1/messages/messages-api.ts index 9f13262b..3eebda13 100644 --- a/packages/conversation/src/rest/v1/messages/messages-api.ts +++ b/packages/conversation/src/rest/v1/messages/messages-api.ts @@ -8,112 +8,25 @@ import { SinchClientParameters, } from '@sinch/sdk-client'; import { - ConversationChannel, ConversationMessage, - ConversationMessagesView, + DeleteMessageRequestData, + GetMessageRequestData, + ListMessagesRequestData, Recipient, - SendCardMessageRequest, - SendCarouselMessageRequest, - SendChoiceMessageRequest, - SendContactInfoMessageRequest, - SendListMessageRequest, - SendLocationMessageRequest, - SendMediaMessageRequest, - SendMessageRequest, + SendCardMessageRequestData, + SendCarouselMessageRequestData, + SendChoiceMessageRequestData, + SendContactInfoMessageRequestData, + SendListMessageRequestData, + SendLocationMessageRequestData, + SendMediaMessageRequestData, + SendMessageRequestData, SendMessageResponse, - SendTemplateMessageRequest, - SendTextMessageRequest, - UpdateMessageRequest, + SendTemplateMessageRequestData, + SendTextMessageRequestData, + UpdateMessageRequestData, } from '../../../models'; import { ConversationDomainApi } from '../conversation-domain-api'; -import { MessageSource } from '../enums'; - -export interface DeleteMessageRequestData { - /** The unique ID of the message. */ - 'message_id': string; - /** Specifies the message source for which the request will be processed. Used for operations on messages in Dispatch Mode. For more information, see [Processing Modes](../../../../../conversation/processing-modes/). */ - 'messages_source'?: MessageSource; -} -export interface GetMessageRequestData { - /** The unique ID of the message. */ - 'message_id': string; - /** Specifies the message source for which the request will be processed. Used for operations on messages in Dispatch Mode. For more information, see [Processing Modes](../../../../../conversation/processing-modes/). */ - 'messages_source'?: MessageSource; -} -export interface ListMessagesRequestData { - /** Resource name (ID) of the conversation. */ - 'conversation_id'?: string; - /** Resource name (ID) of the contact. */ - 'contact_id'?: string; - /** Id of the app. */ - 'app_id'?: string; - /** Channel identity of the contact. */ - 'channel_identity'?: string; - /** Filter messages with `accept_time` after this timestamp. Must be before `end_time` if that is specified. */ - 'start_time'?: Date; - /** Filter messages with `accept_time` before this timestamp. */ - 'end_time'?: Date; - /** Maximum number of messages to fetch. Defaults to 10 and the maximum is 1000. */ - 'page_size'?: number; - /** Next page token previously returned if any. When specifying this token, make sure to use the same values for the other parameters from the request that originated the token, otherwise the paged results may be inconsistent. */ - 'page_token'?: string; - /** */ - 'view'?: ConversationMessagesView; - /** Specifies the message source for which the request will be processed. Used for operations on messages in Dispatch Mode. For more information, see [Processing Modes](../../../../../conversation/processing-modes/). */ - 'messages_source'?: MessageSource; - /** If true, fetch only recipient originated messages. Available only when `messages_source` is `DISPATCH_SOURCE`. */ - 'only_recipient_originated'?: boolean; - /** Only fetch messages from the `channel`. */ - 'channel'?: ConversationChannel; -} -export interface SendMessageRequestData { - /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ - 'sendMessageRequestBody': SendMessageRequest; -} -export interface SendCardMessageRequestData { - /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ - 'sendMessageRequestBody': SendCardMessageRequest; -} -export interface SendCarouselMessageRequestData { - /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ - 'sendMessageRequestBody': SendCarouselMessageRequest; -} -export interface SendChoiceMessageRequestData { - /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ - 'sendMessageRequestBody': SendChoiceMessageRequest; -} -export interface SendContactInfoMessageRequestData { - /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ - 'sendMessageRequestBody': SendContactInfoMessageRequest; -} -export interface SendListMessageRequestData { - /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ - 'sendMessageRequestBody': SendListMessageRequest; -} -export interface SendLocationMessageRequestData { - /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ - 'sendMessageRequestBody': SendLocationMessageRequest; -} -export interface SendMediaMessageRequestData { - /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ - 'sendMessageRequestBody': SendMediaMessageRequest; -} -export interface SendTemplateMessageRequestData { - /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ - 'sendMessageRequestBody': SendTemplateMessageRequest; -} -export interface SendTextMessageRequestData { - /** This is the request body for sending a message. `app_id`, `recipient`, and `message` are all required fields. */ - 'sendMessageRequestBody': SendTextMessageRequest; -} -export interface UpdateMessageRequestData { - /** The unique ID of the message. */ - 'message_id': string; - /** Update message metadata request. */ - 'updateMessageRequestBody': UpdateMessageRequest; - /** Specifies the message source for which the request will be processed. Used for operations on messages in Dispatch Mode. For more information, see [Processing Modes](../../../../../conversation/processing-modes/). */ - 'messages_source'?: 'CONVERSATION_SOURCE' | 'DISPATCH_SOURCE'; -} export class MessagesApi extends ConversationDomainApi { diff --git a/packages/conversation/src/rest/v1/templates-v1/templates-v1-api.jest.fixture.ts b/packages/conversation/src/rest/v1/templates-v1/templates-v1-api.jest.fixture.ts index bb79cc99..fc2a3ca3 100644 --- a/packages/conversation/src/rest/v1/templates-v1/templates-v1-api.jest.fixture.ts +++ b/packages/conversation/src/rest/v1/templates-v1/templates-v1-api.jest.fixture.ts @@ -1,5 +1,13 @@ -import { V1Template, V1ListTemplatesResponse } from '../../../models'; -import { TemplatesV1Api, CreateTemplateRequestData, DeleteTemplateRequestData, GetTemplateRequestData, ListTemplatesRequestData, UpdateTemplateRequestData } from './templates-v1-api'; +import { TemplatesV1Api } from './templates-v1-api'; +import { + V1Template, + V1ListTemplatesResponse, + CreateTemplateRequestData, + DeleteTemplateRequestData, + GetTemplateRequestData, + ListTemplatesRequestData, + UpdateTemplateRequestData, +} from '../../../models'; export class TemplatesV1ApiFixture implements Partial> { @@ -24,4 +32,3 @@ export class TemplatesV1ApiFixture implements Partial> */ public update: jest.Mock, [UpdateTemplateRequestData]> = jest.fn(); } - diff --git a/packages/conversation/src/rest/v1/templates-v1/templates-v1-api.ts b/packages/conversation/src/rest/v1/templates-v1/templates-v1-api.ts index 795e0068..ca0730bb 100644 --- a/packages/conversation/src/rest/v1/templates-v1/templates-v1-api.ts +++ b/packages/conversation/src/rest/v1/templates-v1/templates-v1-api.ts @@ -1,6 +1,11 @@ import { V1Template, V1ListTemplatesResponse, + CreateTemplateRequestData, + DeleteTemplateRequestData, + GetTemplateRequestData, + ListTemplatesRequestData, + UpdateTemplateRequestData, } from '../../../models'; import { RequestBody, @@ -8,29 +13,6 @@ import { } from '@sinch/sdk-client'; import { ConversationDomainApi } from '../conversation-domain-api'; -export interface CreateTemplateRequestData { - /** Required. The template to create. */ - 'createTemplateRequestBody': V1Template; -} -export interface DeleteTemplateRequestData { - /** Required. The ID of the template to fetch. */ - 'template_id': string; -} -export interface GetTemplateRequestData { - /** Required. The ID of the template to fetch. */ - 'template_id': string; -} -export interface ListTemplatesRequestData { -} -export interface UpdateTemplateRequestData { - /** The id of the template to be updated. Specified or automatically generated during template creation. Unique per project. */ - 'template_id': string; - /** Required. The updated template. */ - 'updateTemplateRequestBody': V1Template; - /** The set of field mask paths. */ - 'update_mask'?: Array; -} - export class TemplatesV1Api extends ConversationDomainApi { /** diff --git a/packages/conversation/src/rest/v1/templates-v2/templates-v2-api.jest.fixture.ts b/packages/conversation/src/rest/v1/templates-v2/templates-v2-api.jest.fixture.ts index 9d6fc0e6..a83e0939 100644 --- a/packages/conversation/src/rest/v1/templates-v2/templates-v2-api.jest.fixture.ts +++ b/packages/conversation/src/rest/v1/templates-v2/templates-v2-api.jest.fixture.ts @@ -1,5 +1,15 @@ -import { V2ListTemplatesResponse, V2ListTranslationsResponse, V2TemplateResponse } from '../../../models'; -import { TemplatesV2Api, V2CreateTemplateRequestData, V2DeleteTemplateRequestData, V2GetTemplateRequestData, V2ListTemplatesRequestData, V2ListTranslationsRequestData, V2UpdateTemplateRequestData } from './templates-v2-api'; +import { TemplatesV2Api } from './templates-v2-api'; +import { + V2ListTemplatesResponse, + V2ListTranslationsResponse, + V2TemplateResponse, + V2CreateTemplateRequestData, + V2DeleteTemplateRequestData, + V2GetTemplateRequestData, + V2ListTemplatesRequestData, + V2ListTranslationsRequestData, + V2UpdateTemplateRequestData, +} from '../../../models'; export class TemplatesV2ApiFixture implements Partial> { @@ -28,4 +38,3 @@ export class TemplatesV2ApiFixture implements Partial> */ public update: jest.Mock, [V2UpdateTemplateRequestData]> = jest.fn(); } - diff --git a/packages/conversation/src/rest/v1/templates-v2/templates-v2-api.ts b/packages/conversation/src/rest/v1/templates-v2/templates-v2-api.ts index 5ec58177..700cb247 100644 --- a/packages/conversation/src/rest/v1/templates-v2/templates-v2-api.ts +++ b/packages/conversation/src/rest/v1/templates-v2/templates-v2-api.ts @@ -1,8 +1,13 @@ import { + V2CreateTemplateRequestData, + V2DeleteTemplateRequestData, + V2GetTemplateRequestData, + V2ListTemplatesRequestData, V2ListTemplatesResponse, + V2ListTranslationsRequestData, V2ListTranslationsResponse, - V2Template, V2TemplateResponse, + V2UpdateTemplateRequestData, } from '../../../models'; import { RequestBody, @@ -10,35 +15,6 @@ import { } from '@sinch/sdk-client'; import { ConversationDomainApi } from '../conversation-domain-api'; -export interface V2CreateTemplateRequestData { - /** Required. The template to create. */ - 'createTemplateRequestBody': V2Template; -} -export interface V2DeleteTemplateRequestData { - /** Required. The ID of the template to delete. */ - 'template_id': string; -} -export interface V2GetTemplateRequestData { - /** Required. The ID of the template to fetch. */ - 'template_id': string; -} -export interface V2ListTemplatesRequestData { -} -export interface V2ListTranslationsRequestData { - /** Required. The template ID. */ - 'template_id': string; - /** Optional. The translation's language code. */ - 'language_code'?: string; - /** Optional. The translation's version. */ - 'translation_version'?: string; -} -export interface V2UpdateTemplateRequestData { - /** The id of the template to be updated. Specified or automatically generated during template creation. Unique per project. */ - 'template_id': string; - /** Required. The updated template. */ - 'updateTemplateRequestBody': V2Template; -} - export class TemplatesV2Api extends ConversationDomainApi { /** diff --git a/packages/conversation/src/rest/v1/transcoding/transcoding-api.jest.fixture.ts b/packages/conversation/src/rest/v1/transcoding/transcoding-api.jest.fixture.ts index b401c559..d06e6a3c 100644 --- a/packages/conversation/src/rest/v1/transcoding/transcoding-api.jest.fixture.ts +++ b/packages/conversation/src/rest/v1/transcoding/transcoding-api.jest.fixture.ts @@ -1,5 +1,8 @@ -import { TranscodeMessageResponse } from '../../../models'; -import { TranscodingApi, TranscodeMessageRequestData } from './transcoding-api'; +import { TranscodingApi } from './transcoding-api'; +import { + TranscodeMessageResponse, + TranscodeMessageRequestData, +} from '../../../models'; export class TranscodingApiFixture implements Partial> { @@ -8,4 +11,3 @@ export class TranscodingApiFixture implements Partial> */ public transcodeMessage: jest.Mock, [TranscodeMessageRequestData]> = jest.fn(); } - diff --git a/packages/conversation/src/rest/v1/transcoding/transcoding-api.ts b/packages/conversation/src/rest/v1/transcoding/transcoding-api.ts index 446513be..9b08d0c9 100644 --- a/packages/conversation/src/rest/v1/transcoding/transcoding-api.ts +++ b/packages/conversation/src/rest/v1/transcoding/transcoding-api.ts @@ -3,15 +3,11 @@ import { SinchClientParameters, } from '@sinch/sdk-client'; import { - TranscodeMessageRequest, + TranscodeMessageRequestData, TranscodeMessageResponse, } from '../../../models'; import { ConversationDomainApi } from '../conversation-domain-api'; -export interface TranscodeMessageRequestData { - /** The message to be transcoded, and the app and channels for which the message is to be transcoded. */ - 'transcodeMessageRequestBody': TranscodeMessageRequest; -} export class TranscodingApi extends ConversationDomainApi { diff --git a/packages/conversation/src/rest/v1/webhooks/webhooks-api.jest.fixture.ts b/packages/conversation/src/rest/v1/webhooks/webhooks-api.jest.fixture.ts index 39131f5f..433e1630 100644 --- a/packages/conversation/src/rest/v1/webhooks/webhooks-api.jest.fixture.ts +++ b/packages/conversation/src/rest/v1/webhooks/webhooks-api.jest.fixture.ts @@ -1,6 +1,13 @@ -import { ListWebhooksResponse } from '../../../models'; -import { Webhook } from '../../../models'; -import { WebhooksApi, CreateWebhookRequestData, DeleteWebhookRequestData, GetWebhookRequestData, ListWebhooksRequestData, UpdateWebhookRequestData } from './webhooks-api'; +import { WebhooksApi } from './webhooks-api'; +import { + Webhook, + CreateWebhookRequestData, + DeleteWebhookRequestData, + GetWebhookRequestData, + ListWebhooksRequestData, + ListWebhooksResponse, + UpdateWebhookRequestData, +} from '../../../models'; export class WebhooksApiFixture implements Partial> { @@ -25,4 +32,3 @@ export class WebhooksApiFixture implements Partial> { */ public update: jest.Mock, [UpdateWebhookRequestData]> = jest.fn(); } - diff --git a/packages/conversation/src/rest/v1/webhooks/webhooks-api.ts b/packages/conversation/src/rest/v1/webhooks/webhooks-api.ts index 758295bb..166ec363 100644 --- a/packages/conversation/src/rest/v1/webhooks/webhooks-api.ts +++ b/packages/conversation/src/rest/v1/webhooks/webhooks-api.ts @@ -3,36 +3,16 @@ import { SinchClientParameters, } from '@sinch/sdk-client'; import { + CreateWebhookRequestData, + DeleteWebhookRequestData, + GetWebhookRequestData, + ListWebhooksRequestData, ListWebhooksResponse, + UpdateWebhookRequestData, Webhook, } from '../../../models'; import { ConversationDomainApi } from '../conversation-domain-api'; -export interface CreateWebhookRequestData { - /** Required. The Webhook to create */ - 'webhookCreateRequestBody': Webhook; -} -export interface DeleteWebhookRequestData { - /** The unique ID of the webhook. */ - 'webhook_id': string; -} -export interface GetWebhookRequestData { - /** The unique ID of the webhook. */ - 'webhook_id': string; -} -export interface ListWebhooksRequestData { - /** The unique ID of the app. You can find this on the [Sinch Dashboard](https://dashboard.sinch.com/convapi/apps). */ - 'app_id': string; -} -export interface UpdateWebhookRequestData { - /** The unique ID of the webhook. */ - 'webhook_id': string; - /** Required. The Webhook to update */ - 'webhookUpdateRequestBody': Webhook; - /** The set of field mask paths. */ - 'update_mask'?: Array; -} - export class WebhooksApi extends ConversationDomainApi { /** diff --git a/packages/conversation/tests/events-mocks.ts b/packages/conversation/tests/events-mocks.ts index c4e99420..40aaf292 100644 --- a/packages/conversation/tests/events-mocks.ts +++ b/packages/conversation/tests/events-mocks.ts @@ -1,27 +1,20 @@ -import { - AgentJoinedEvent, - AgentLeftEvent, - CommentReplyEvent, - ComposingEndEvent, - ComposingEvent, - GenericEvent, -} from '../src'; +import { Conversation } from '../src'; -export const composingEvent: ComposingEvent = { +export const composingEvent: Conversation.ComposingEvent = { composing_event: {}, }; -export const composingEndEvent: ComposingEndEvent = { +export const composingEndEvent: Conversation.ComposingEndEvent = { composing_end_event: {}, }; -export const commentReplyEvent: CommentReplyEvent = { +export const commentReplyEvent: Conversation.CommentReplyEvent = { comment_reply_event: { text: 'Reply comment content', }, }; -export const agentJoinedEvent: AgentJoinedEvent = { +export const agentJoinedEvent: Conversation.AgentJoinedEvent = { agent_joined_event: { agent: { display_name: 'Agent name', @@ -30,7 +23,7 @@ export const agentJoinedEvent: AgentJoinedEvent = { }, }; -export const agentLeftEvent: AgentLeftEvent = { +export const agentLeftEvent: Conversation.AgentLeftEvent = { agent_left_event: { agent: { display_name: 'Agent name', @@ -39,7 +32,7 @@ export const agentLeftEvent: AgentLeftEvent = { }, }; -export const genericEvent: GenericEvent = { +export const genericEvent: Conversation.GenericEvent = { generic_event: { payload: { some: 'data', diff --git a/packages/conversation/tests/messages-mocks.ts b/packages/conversation/tests/messages-mocks.ts index 14655d22..294f64a5 100644 --- a/packages/conversation/tests/messages-mocks.ts +++ b/packages/conversation/tests/messages-mocks.ts @@ -1,33 +1,14 @@ -import { - CardMessage, - CardMessageItem, - CarouselMessage, - CarouselMessageItem, - ChoiceMessage, - ChoiceMessageItem, - ContactInfoMessage, - ContactInfoMessageItem, - ListMessage, - ListMessageItem, - LocationMessage, - LocationMessageItem, - MediaMessage, - MediaMessageItem, - TemplateMessage, - TemplateMessageItem, - TextMessage, - TextMessageItem, -} from '../src'; - -export const textMessageItem: TextMessageItem = { +import { Conversation } from '../src'; + +export const textMessageItem: Conversation.TextMessageItem = { text: 'text message', }; -export const textMessage: TextMessage = { +export const textMessage: Conversation.TextMessage = { text_message: textMessageItem, }; -export const cardMessageItem: CardMessageItem = { +export const cardMessageItem: Conversation.CardMessageItem = { title: 'title', description: 'description', media_message: { @@ -48,11 +29,11 @@ export const cardMessageItem: CardMessageItem = { ], }; -export const cardMessage: CardMessage = { +export const cardMessage: Conversation.CardMessage = { card_message: cardMessageItem, }; -export const carouselMessageItem: CarouselMessageItem = { +export const carouselMessageItem: Conversation.CarouselMessageItem = { cards: [ { title: 'card #1', @@ -101,11 +82,11 @@ export const carouselMessageItem: CarouselMessageItem = { ], }; -export const carouselMessage: CarouselMessage = { +export const carouselMessage: Conversation.CarouselMessage = { carousel_message: carouselMessageItem, }; -export const choiceMessageItem: ChoiceMessageItem = { +export const choiceMessageItem: Conversation.ChoiceMessageItem = { text_message: { text: 'Choose your icecream flavor', }, @@ -123,11 +104,11 @@ export const choiceMessageItem: ChoiceMessageItem = { ], }; -export const choiceMessage: ChoiceMessage = { +export const choiceMessage: Conversation.ChoiceMessage = { choice_message: choiceMessageItem, }; -export const contactInfoMessageItem: ContactInfoMessageItem = { +export const contactInfoMessageItem: Conversation.ContactInfoMessageItem = { name: { full_name: 'Full Name', }, @@ -139,11 +120,11 @@ export const contactInfoMessageItem: ContactInfoMessageItem = { ], }; -export const contactInfoMessage: ContactInfoMessage = { +export const contactInfoMessage: Conversation.ContactInfoMessage = { contact_info_message: contactInfoMessageItem, }; -export const locationMessageItem: LocationMessageItem = { +export const locationMessageItem: Conversation.LocationMessageItem = { title: 'Phare d\'Eckmühl', label: 'Pointe de Penmarch', coordinates: { @@ -152,20 +133,20 @@ export const locationMessageItem: LocationMessageItem = { }, }; -export const locationMessage: LocationMessage = { +export const locationMessage: Conversation.LocationMessage = { location_message: locationMessageItem, }; -export const mediaMessageItem: MediaMessageItem = { +export const mediaMessageItem: Conversation.MediaMessageItem = { url: 'https://url-to-media.com', thumbnail_url: 'https://url-to-thumbnail.com', }; -export const mediaMessage: MediaMessage = { +export const mediaMessage: Conversation.MediaMessage = { media_message: mediaMessageItem, }; -export const templateMessageItem: TemplateMessageItem = { +export const templateMessageItem: Conversation.TemplateMessageItem = { omni_template: { template_id: 'templateId', version: '1', @@ -183,11 +164,11 @@ export const templateMessageItem: TemplateMessageItem = { }, }; -export const templateMessage: TemplateMessage = { +export const templateMessage: Conversation.TemplateMessage = { template_message: templateMessageItem, }; -export const listMessageItem: ListMessageItem = { +export const listMessageItem: Conversation.ListMessageItem = { title: 'Choose your icecream flavor', description: 'The best icecream in town!', sections: [ @@ -231,6 +212,6 @@ export const listMessageItem: ListMessageItem = { }, }; -export const listMessage: ListMessage = { +export const listMessage: Conversation.ListMessage = { list_message: listMessageItem, }; diff --git a/packages/conversation/tests/models/v1/helper.test.ts b/packages/conversation/tests/models/v1/helper.test.ts index 05065280..e68fd1cd 100644 --- a/packages/conversation/tests/models/v1/helper.test.ts +++ b/packages/conversation/tests/models/v1/helper.test.ts @@ -1,10 +1,4 @@ -import { - V2TemplateTranslation, - MessageType, - templateV1Helper, - templateV2Helper, - messageBuilder, -} from '../../../src'; +import { Conversation } from '../../../src'; import { cardMessage, cardMessageItem, @@ -30,99 +24,99 @@ describe('Conversation models helpers', () => { describe('Templates V1 helper', () => { it('should build a TextMessage', () => { - const builtMessage = templateV1Helper.buildTextMessageContent(textMessageItem); + const builtMessage = Conversation.templateV1Helper.buildTextMessageContent(textMessageItem); expect(builtMessage).toBe(JSON.stringify(textMessage)); }); it('should build a CardMessage', () => { - const builtMessage = templateV1Helper.buildCardMessageContent(cardMessageItem); + const builtMessage = Conversation.templateV1Helper.buildCardMessageContent(cardMessageItem); expect(builtMessage).toBe(JSON.stringify(cardMessage)); }); it('should build a CarouselMessage', () => { - const builtMessage = templateV1Helper.buildCarouselMessageContent(carouselMessageItem); + const builtMessage = Conversation.templateV1Helper.buildCarouselMessageContent(carouselMessageItem); expect(builtMessage).toBe(JSON.stringify(carouselMessage)); }); it('should build a ChoiceMessage', () => { - const builtMessage = templateV1Helper.buildChoiceMessageContent(choiceMessageItem); + const builtMessage = Conversation.templateV1Helper.buildChoiceMessageContent(choiceMessageItem); expect(builtMessage).toBe(JSON.stringify(choiceMessage)); }); it('should build a ContactInfoMessage', () => { - const builtMessage = templateV1Helper.buildContactInfoMessageContent(contactInfoMessageItem); + const builtMessage = Conversation.templateV1Helper.buildContactInfoMessageContent(contactInfoMessageItem); expect(builtMessage).toEqual(JSON.stringify(contactInfoMessage)); }); it('should build a LocationMessage', () => { - const builtMessage = templateV1Helper.buildLocationMessageContent(locationMessageItem); + const builtMessage = Conversation.templateV1Helper.buildLocationMessageContent(locationMessageItem); expect(builtMessage).toBe(JSON.stringify(locationMessage)); }); it('should build a MediaMessage', () => { - const builtMessage = templateV1Helper.buildMediaMessageContent(mediaMessageItem); + const builtMessage = Conversation.templateV1Helper.buildMediaMessageContent(mediaMessageItem); expect(builtMessage).toBe(JSON.stringify(mediaMessage)); }); it('should build a TemplateMessage', () => { - const builtMessage = templateV1Helper.buildTemplateMessageContent(templateMessageItem); + const builtMessage = Conversation.templateV1Helper.buildTemplateMessageContent(templateMessageItem); expect(builtMessage).toBe(JSON.stringify(templateMessage)); }); it('should build a ListMessage', () => { - const builtMessage = templateV1Helper.buildListMessageContent(listMessageItem); + const builtMessage = Conversation.templateV1Helper.buildListMessageContent(listMessageItem); expect(builtMessage).toBe(JSON.stringify(listMessage)); }); }); describe('Templates V2 helper', () => { it('should build a TextMessage', () => { - const builtTextMessage = templateV2Helper.buildTextMessageContent(textMessageItem); + const builtTextMessage = Conversation.templateV2Helper.buildTextMessageContent(textMessageItem); expect(builtTextMessage).toEqual(textMessage); }); it('should build a CardMessage', () => { - const builtTextMessage = templateV2Helper.buildCardMessageContent(cardMessageItem); + const builtTextMessage = Conversation.templateV2Helper.buildCardMessageContent(cardMessageItem); expect(builtTextMessage).toEqual(cardMessage); }); it('should build a CarouselMessage', () => { - const builtMessage = templateV2Helper.buildCarouselMessageContent(carouselMessageItem); + const builtMessage = Conversation.templateV2Helper.buildCarouselMessageContent(carouselMessageItem); expect(builtMessage).toEqual(carouselMessage); }); it('should build a ChoiceMessage', () => { - const builtMessage = templateV2Helper.buildChoiceMessageContent(choiceMessageItem); + const builtMessage = Conversation.templateV2Helper.buildChoiceMessageContent(choiceMessageItem); expect(builtMessage).toEqual(choiceMessage); }); it('should build a ContactInfoMessage', () => { - const builtMessage = templateV2Helper.buildContactInfoMessageContent(contactInfoMessageItem); + const builtMessage = Conversation.templateV2Helper.buildContactInfoMessageContent(contactInfoMessageItem); expect(builtMessage).toEqual(contactInfoMessage); }); it('should build a LocationMessage', () => { - const builtMessage = templateV2Helper.buildLocationMessageContent(locationMessageItem); + const builtMessage = Conversation.templateV2Helper.buildLocationMessageContent(locationMessageItem); expect(builtMessage).toEqual(locationMessage); }); it('should build a MediaMessage', () => { - const builtMessage = templateV2Helper.buildMediaMessageContent(mediaMessageItem); + const builtMessage = Conversation.templateV2Helper.buildMediaMessageContent(mediaMessageItem); expect(builtMessage).toEqual(mediaMessage); }); it('should build a TemplateMessage', () => { - const builtMessage = templateV2Helper.buildTemplateMessageContent(templateMessageItem); + const builtMessage = Conversation.templateV2Helper.buildTemplateMessageContent(templateMessageItem); expect(builtMessage).toEqual(templateMessage); }); it('should build a ListMessage', () => { - const builtMessage = templateV2Helper.buildListMessageContent(listMessageItem); + const builtMessage = Conversation.templateV2Helper.buildListMessageContent(listMessageItem); expect(builtMessage).toEqual(listMessage); }); it('should get the message content from the translation', () => { - let templateTranslation: V2TemplateTranslation; + let templateTranslation: Conversation.V2TemplateTranslation; const translationIdentifier = { version: '1', language_code: 'en-US', @@ -131,66 +125,75 @@ describe('Conversation models helpers', () => { ...translationIdentifier, ...textMessage, }; - expect(templateV2Helper.getMessageFromTranslation(templateTranslation).type).toBe(MessageType.TEXT); + expect(Conversation.templateV2Helper.getMessageFromTranslation(templateTranslation).type) + .toBe(Conversation.MessageType.TEXT); templateTranslation = { ...translationIdentifier, ...cardMessage, }; - expect(templateV2Helper.getMessageFromTranslation(templateTranslation).type).toBe(MessageType.CARD); + expect(Conversation.templateV2Helper.getMessageFromTranslation(templateTranslation).type) + .toBe(Conversation.MessageType.CARD); templateTranslation = { ...translationIdentifier, ...choiceMessage, }; - expect(templateV2Helper.getMessageFromTranslation(templateTranslation).type).toBe(MessageType.CHOICE); + expect(Conversation.templateV2Helper.getMessageFromTranslation(templateTranslation).type) + .toBe(Conversation.MessageType.CHOICE); templateTranslation = { ...translationIdentifier, ...carouselMessage, }; - expect(templateV2Helper.getMessageFromTranslation(templateTranslation).type).toBe(MessageType.CAROUSEL); + expect(Conversation.templateV2Helper.getMessageFromTranslation(templateTranslation).type) + .toBe(Conversation.MessageType.CAROUSEL); templateTranslation = { ...translationIdentifier, ...contactInfoMessage, }; - expect(templateV2Helper.getMessageFromTranslation(templateTranslation).type).toBe(MessageType.CONTACT_INFO); + expect(Conversation.templateV2Helper.getMessageFromTranslation(templateTranslation).type) + .toBe(Conversation.MessageType.CONTACT_INFO); templateTranslation = { ...translationIdentifier, ...listMessage, }; - expect(templateV2Helper.getMessageFromTranslation(templateTranslation).type).toBe(MessageType.LIST); + expect(Conversation.templateV2Helper.getMessageFromTranslation(templateTranslation).type) + .toBe(Conversation.MessageType.LIST); templateTranslation = { ...translationIdentifier, ...locationMessage, }; - expect(templateV2Helper.getMessageFromTranslation(templateTranslation).type).toBe(MessageType.LOCATION); + expect(Conversation.templateV2Helper.getMessageFromTranslation(templateTranslation).type) + .toBe(Conversation.MessageType.LOCATION); templateTranslation = { ...translationIdentifier, ...mediaMessage, }; - expect(templateV2Helper.getMessageFromTranslation(templateTranslation).type).toBe(MessageType.MEDIA); + expect(Conversation.templateV2Helper.getMessageFromTranslation(templateTranslation).type) + .toBe(Conversation.MessageType.MEDIA); templateTranslation = { ...translationIdentifier, ...templateMessage, }; - expect(templateV2Helper.getMessageFromTranslation(templateTranslation).type).toBe(MessageType.TEMPLATE); + expect(Conversation.templateV2Helper.getMessageFromTranslation(templateTranslation).type) + .toBe(Conversation.MessageType.TEMPLATE); }); it('should filter out the latest translations', () => { - const version1Translation: V2TemplateTranslation = { + const version1Translation: Conversation.V2TemplateTranslation = { version: '1', language_code: 'en-US', text_message: { text: 'text', }, }; - const latestTranslation: V2TemplateTranslation = { + const latestTranslation: Conversation.V2TemplateTranslation = { version: 'latest', language_code: 'en-US', text_message: { @@ -198,7 +201,7 @@ describe('Conversation models helpers', () => { }, }; const translations = [version1Translation, latestTranslation]; - const filteredTranslations = templateV2Helper.getPreviousTranslations(translations); + const filteredTranslations = Conversation.templateV2Helper.getPreviousTranslations(translations); expect(filteredTranslations.length).toBe(1); expect(filteredTranslations[0].version).toBe('1'); }); @@ -206,42 +209,42 @@ describe('Conversation models helpers', () => { describe('Message builder helper', () => { it('should build a TextMessage', () => { - const builtTextMessage = messageBuilder.text(textMessageItem); + const builtTextMessage = Conversation.messageBuilder.text(textMessageItem); expect(builtTextMessage).toEqual(textMessage); }); it('should build a CardMessage', () => { - const builtTextMessage = messageBuilder.card(cardMessageItem); + const builtTextMessage = Conversation.messageBuilder.card(cardMessageItem); expect(builtTextMessage).toEqual(cardMessage); }); it('should build a CarouselMessage', () => { - const builtMessage = messageBuilder.carousel(carouselMessageItem); + const builtMessage = Conversation.messageBuilder.carousel(carouselMessageItem); expect(builtMessage).toEqual(carouselMessage); }); it('should build a ChoiceMessage', () => { - const builtMessage = messageBuilder.choice(choiceMessageItem); + const builtMessage = Conversation.messageBuilder.choice(choiceMessageItem); expect(builtMessage).toEqual(choiceMessage); }); it('should build a LocationMessage', () => { - const builtMessage = messageBuilder.location(locationMessageItem); + const builtMessage = Conversation.messageBuilder.location(locationMessageItem); expect(builtMessage).toEqual(locationMessage); }); it('should build a MediaMessage', () => { - const builtMessage = messageBuilder.media(mediaMessageItem); + const builtMessage = Conversation.messageBuilder.media(mediaMessageItem); expect(builtMessage).toEqual(mediaMessage); }); it('should build a TemplateMessage', () => { - const builtMessage = messageBuilder.template(templateMessageItem); + const builtMessage = Conversation.messageBuilder.template(templateMessageItem); expect(builtMessage).toEqual(templateMessage); }); it('should build a ListMessage', () => { - const builtMessage = messageBuilder.list(listMessageItem); + const builtMessage = Conversation.messageBuilder.list(listMessageItem); expect(builtMessage).toEqual(listMessage); }); }); diff --git a/packages/conversation/tests/rest/v1/app/app-api.test.ts b/packages/conversation/tests/rest/v1/app/app-api.test.ts index 0c98c15d..f3119460 100644 --- a/packages/conversation/tests/rest/v1/app/app-api.test.ts +++ b/packages/conversation/tests/rest/v1/app/app-api.test.ts @@ -1,26 +1,8 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - AppResponse, - CreateAppRequestData, - DeleteAppRequestData, - GetAppRequestData, - ListAppsRequestData, - UpdateAppRequestData, - ChannelCredentialsAppleBC, - ChannelCredentialsInstagram, - ChannelCredentialsKakaoTalk, - ChannelCredentialsKakaoTalkChat, - ChannelCredentialsLine, - ChannelCredentialsMessenger, - ChannelCredentialsMms, - ChannelCredentialsRcs, - ChannelCredentialsSms, - ListAppsResponse, AppApi, AppApiFixture, - ChannelCredentialsTelegram, - ChannelCredentialsViber, - ChannelCredentialsViberBM, ChannelCredentialsWeChat, ChannelCredentialsWhatsApp, + Conversation, } from '../../../../src'; describe('AppApi', () => { @@ -42,7 +24,7 @@ describe('AppApi', () => { describe ('createApp', () => { it('should make a POST request to create a new Conversation App', async () => { // Given - const channelCredentialsAppleBC: ChannelCredentialsAppleBC = { + const channelCredentialsAppleBC: Conversation.ChannelCredentialsAppleBC = { channel: 'APPLEBC', applebc_credentials: { business_chat_account_id: 'apple_business_chat_account_id', @@ -51,35 +33,35 @@ describe('AppApi', () => { apple_pay_certificate_password: 'apple_pay_certificate_password', }, }; - const channelCredentialsInstagram: ChannelCredentialsInstagram = { + const channelCredentialsInstagram: Conversation.ChannelCredentialsInstagram = { channel: 'INSTAGRAM', instagram_credentials: { token: 'instagram_channel_token', business_account_id: 'instagram_business_account_id', }, }; - const channelCredentialsKakaoTalk: ChannelCredentialsKakaoTalk = { + const channelCredentialsKakaoTalk: Conversation.ChannelCredentialsKakaoTalk = { channel: 'KAKAOTALK', kakaotalk_credentials: { kakaotalk_plus_friend_id: 'kakaotalk_friend_id', kakaotalk_sender_key: 'kakaotalk_sender_key', }, }; - const channelCredentialsKakaoTalkChat: ChannelCredentialsKakaoTalkChat = { + const channelCredentialsKakaoTalkChat: Conversation.ChannelCredentialsKakaoTalkChat = { channel: 'KAKAOTALKCHAT', kakaotalkchat_credentials: { kakaotalk_plus_friend_id: 'kakaotalk_friend_id', api_key: 'info_bank_api_key', }, }; - const channelCredentialsLine: ChannelCredentialsLine = { + const channelCredentialsLine: Conversation.ChannelCredentialsLine = { channel: 'LINE', line_credentials: { token: 'line_token', secret: 'line_secret', }, }; - const channelCredentialsMms: ChannelCredentialsMms = { + const channelCredentialsMms: Conversation.ChannelCredentialsMms = { channel: 'MMS', mms_credentials: { account_id: 'mms_account_id', @@ -91,20 +73,20 @@ describe('AppApi', () => { default_sender: 'default_sender', }, }; - const channelCredentialsMessenger: ChannelCredentialsMessenger = { + const channelCredentialsMessenger: Conversation.ChannelCredentialsMessenger = { channel: 'MESSENGER', static_token: { token: 'messenger_static_token', }, }; - const channelCredentialsRcs: ChannelCredentialsRcs = { + const channelCredentialsRcs: Conversation.ChannelCredentialsRcs = { channel: 'RCS', static_bearer: { claimed_identity: 'rcs_claimed_identity', token: 'rcs_token', }, }; - const channelCredentialsSms: ChannelCredentialsSms = { + const channelCredentialsSms: Conversation.ChannelCredentialsSms = { channel: 'SMS', static_bearer: { claimed_identity: 'sms_claimed_identity', @@ -117,26 +99,26 @@ describe('AppApi', () => { // sms_app_id: 'sms_app_id', // }, // }; - const channelCredentialsTelegram: ChannelCredentialsTelegram = { + const channelCredentialsTelegram: Conversation.ChannelCredentialsTelegram = { channel: 'TELEGRAM', telegram_credentials: { token: 'telegram_token', }, }; - const channelCredentialsViber: ChannelCredentialsViber = { + const channelCredentialsViber: Conversation.ChannelCredentialsViber = { channel: 'VIBER', static_token: { token: 'viber_token', }, }; - const channelCredentialsViberBM: ChannelCredentialsViberBM = { + const channelCredentialsViberBM: Conversation.ChannelCredentialsViberBM = { channel: 'VIBERBM', static_bearer: { claimed_identity: 'viberbm_claimed_identity', token: 'viberbm_token', }, }; - const channelCredentialsWeChat: ChannelCredentialsWeChat = { + const channelCredentialsWeChat: Conversation.ChannelCredentialsWeChat = { channel: 'WECHAT', wechat_credentials: { app_id: 'wechat_app_id', @@ -145,14 +127,14 @@ describe('AppApi', () => { aes_key: 'wechat_aes_key', }, }; - const channelCredetialsWhatsApp: ChannelCredentialsWhatsApp = { + const channelCredetialsWhatsApp: Conversation.ChannelCredentialsWhatsApp = { channel: 'WHATSAPP', static_bearer: { claimed_identity: 'whatsapp_claimed_identity', token: 'whatsapp_token', }, }; - const requestData: CreateAppRequestData = { + const requestData: Conversation.CreateAppRequestData = { appCreateRequestBody: { display_name: 'Test App', channel_credentials: [ @@ -174,7 +156,7 @@ describe('AppApi', () => { ], }, }; - const expectedResponse: AppResponse = { + const expectedResponse: Conversation.AppResponse = { id: 'app_id', display_name: 'Test App', }; @@ -193,7 +175,7 @@ describe('AppApi', () => { describe ('deleteApp', () => { it('should make a DELETE request to delete the specified App ID', async () => { // Given - const requestData: DeleteAppRequestData = { + const requestData: Conversation.DeleteAppRequestData = { app_id: 'app_id', }; const expectedResponse: any = {}; @@ -212,10 +194,10 @@ describe('AppApi', () => { describe ('getApp', () => { it('should make a GET request to retrieve the particular app as specified by the App ID', async () => { // Given - const requestData: GetAppRequestData = { + const requestData: Conversation.GetAppRequestData = { app_id: 'app_id', }; - const expectedResponse: AppResponse = { + const expectedResponse: Conversation.AppResponse = { id: 'app_id', display_name: 'Test App', }; @@ -234,8 +216,8 @@ describe('AppApi', () => { describe ('listApps', () => { it('should make a GET request to get the list of all apps', async () => { // Given - const requestData: ListAppsRequestData = {}; - const expectedResponse: ListAppsResponse = { + const requestData: Conversation.ListAppsRequestData = {}; + const expectedResponse: Conversation.ListAppsResponse = { apps: [ { id: 'app_id', @@ -258,13 +240,13 @@ describe('AppApi', () => { describe ('updateApp', () => { it('should make a PATCH request to update a particular app as specified by the App ID', async () => { // Given - const requestData: UpdateAppRequestData = { + const requestData: Conversation.UpdateAppRequestData = { app_id: 'app_id', appUpdateRequestBody: { display_name: 'New display name', }, }; - const expectedResponse: AppResponse = { + const expectedResponse: Conversation.AppResponse = { id: 'app_id', display_name: 'New display name', }; diff --git a/packages/conversation/tests/rest/v1/capability/capability-api.test.ts b/packages/conversation/tests/rest/v1/capability/capability-api.test.ts index c64a21c0..ef2edf1d 100644 --- a/packages/conversation/tests/rest/v1/capability/capability-api.test.ts +++ b/packages/conversation/tests/rest/v1/capability/capability-api.test.ts @@ -1,13 +1,9 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - ContactId, - IdentifiedBy, - LookupCapabilityRequest, - LookupCapabilityRequestData, - LookupCapabilityResponse, - Recipient, + CapabilityApi, + CapabilityApiFixture, + Conversation, } from '../../../../src'; -import { CapabilityApi, CapabilityApiFixture } from '../../../../src'; import { recipientChannelIdentities, recipientContactId } from '../mocks'; describe('CapabilityApi', () => { @@ -28,22 +24,22 @@ describe('CapabilityApi', () => { describe ('queryCapability', () => { // Given - const lookupCapabilityRequest: Omit, 'recipient'> = { + const lookupCapabilityRequest: Omit, 'recipient'> = { app_id: 'app_id', }; - const requestDataWithContactId: LookupCapabilityRequestData = { + const requestDataWithContactId: Conversation.LookupCapabilityRequestData = { lookupCapabilityRequestBody: { ...lookupCapabilityRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: LookupCapabilityRequestData = { + const requestDataWithChannelIdentity: Conversation.LookupCapabilityRequestData = { lookupCapabilityRequestBody: { ...lookupCapabilityRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: LookupCapabilityResponse = { + const expectedResponse: Conversation.LookupCapabilityResponse = { app_id: 'app_id', }; diff --git a/packages/conversation/tests/rest/v1/contact/contact-api.test.ts b/packages/conversation/tests/rest/v1/contact/contact-api.test.ts index f5d8f799..705c3bb6 100644 --- a/packages/conversation/tests/rest/v1/contact/contact-api.test.ts +++ b/packages/conversation/tests/rest/v1/contact/contact-api.test.ts @@ -1,20 +1,8 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - Contact, - CreateContactRequestData, - DeleteContactRequestData, - GetContactRequestData, - ListContactsRequestData, - MergeContactRequestData, - UpdateContactRequestData, - GetChannelProfileResponse, ContactApi, ContactApiFixture, - GetChannelProfileRequestData, - ContactId, - IdentifiedBy, - GetChannelProfileRequest, - Recipient, + Conversation, } from '../../../../src'; import { recipientChannelIdentities, recipientContactId } from '../mocks'; @@ -37,7 +25,7 @@ describe('ContactApi', () => { describe ('createContact', () => { it('should make a POST request to create a contact manually', async () => { // Given - const requestData: CreateContactRequestData = { + const requestData: Conversation.CreateContactRequestData = { contactCreateRequestBody: { channel_identities: [ { @@ -49,7 +37,7 @@ describe('ContactApi', () => { display_name: 'A contact', }, }; - const expectedResponse: Contact = { + const expectedResponse: Conversation.Contact = { id: 'contact_id', language: 'EN_US', }; @@ -68,7 +56,7 @@ describe('ContactApi', () => { describe ('deleteContact', () => { it('should make a DELETE request to delete a contact as specified by the contact ID', async () => { // Given - const requestData: DeleteContactRequestData = { + const requestData: Conversation.DeleteContactRequestData = { contact_id: 'contact_id', }; const expectedResponse: any = {}; @@ -86,23 +74,23 @@ describe('ContactApi', () => { describe ('getChannelProfile', () => { // Given - const getChannelProfileRequest: Omit, 'recipient'> = { + const getChannelProfileRequest: Omit, 'recipient'> = { app_id: 'app_id', channel: 'MESSENGER', }; - const requestDataWithContactId: GetChannelProfileRequestData = { + const requestDataWithContactId: Conversation.GetChannelProfileRequestData = { getChannelProfileRequestBody: { ...getChannelProfileRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: GetChannelProfileRequestData = { + const requestDataWithChannelIdentity: Conversation.GetChannelProfileRequestData = { getChannelProfileRequestBody: { ...getChannelProfileRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: GetChannelProfileResponse = { + const expectedResponse: Conversation.GetChannelProfileResponse = { profile_name: 'Profile Name', }; @@ -126,10 +114,10 @@ describe('ContactApi', () => { describe ('getContact', () => { it('should make a GET request to retrieve a specific contact as specified by the contact ID', async () => { // Given - const requestData: GetContactRequestData = { + const requestData: Conversation.GetContactRequestData = { contact_id: 'contact_id', }; - const expectedResponse: Contact = { + const expectedResponse: Conversation.Contact = { id: 'contact_id', language: 'EN_US', channel_priority: ['WHATSAPP'], @@ -150,8 +138,8 @@ describe('ContactApi', () => { describe ('listContacts', () => { it('should make a GET request to list all contacts in the project', async () => { // Given - const requestData: ListContactsRequestData = {}; - const mockData: Contact[] = [ + const requestData: Conversation.ListContactsRequestData = {}; + const mockData: Conversation.Contact[] = [ { id: 'contact_id', }, @@ -178,14 +166,14 @@ describe('ContactApi', () => { describe ('mergeContact', () => { it('should make a POST request to merge two contacts', async () => { // Given - const requestData: MergeContactRequestData = { + const requestData: Conversation.MergeContactRequestData = { destination_id: 'contact_id', mergeContactRequestBody: { source_id: 'to_be_removed_contact_id', strategy: 'MERGE', }, }; - const expectedResponse: Contact = { + const expectedResponse: Conversation.Contact = { id: 'contact_id', }; @@ -203,13 +191,13 @@ describe('ContactApi', () => { describe ('updateContact', () => { it('should make a PATCH request to update a contact as specified by the contact ID', async () => { // Given - const requestData: UpdateContactRequestData = { + const requestData: Conversation.UpdateContactRequestData = { contact_id: 'contact_id', updateContactRequestBody: { language: 'EN_GB', }, }; - const expectedResponse: Contact = { + const expectedResponse: Conversation.Contact = { id: 'contact_id', }; diff --git a/packages/conversation/tests/rest/v1/conversation/conversation-api.test.ts b/packages/conversation/tests/rest/v1/conversation/conversation-api.test.ts index 0153b3da..8b0f9e1c 100644 --- a/packages/conversation/tests/rest/v1/conversation/conversation-api.test.ts +++ b/packages/conversation/tests/rest/v1/conversation/conversation-api.test.ts @@ -1,19 +1,8 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { Conversation, - CreateConversationRequestData, ConversationApi, ConversationApiFixture, - DeleteConversationRequestData, - GetConversationRequestData, - InjectMessageRequestData, - ListConversationsRequestData, - StopActiveConversationRequestData, - UpdateConversationRequestData, - ListRecentConversationsRequestData, - ConversationRecentMessage, - InjectEventRequestData, - InjectEventResponse, } from '../../../../src'; describe('ConversationApi', () => { @@ -35,13 +24,13 @@ describe('ConversationApi', () => { describe ('createConversation', () => { it('should make a POST request to create a new empty conversation', async () => { // Given - const requestData: CreateConversationRequestData = { + const requestData: Conversation.CreateConversationRequestData = { createConversationRequestBody: { app_id: 'app_id', contact_id: 'contact_id', }, }; - const expectedResponse: Conversation = { + const expectedResponse: Conversation.Conversation = { id: 'conversation_id', }; @@ -59,7 +48,7 @@ describe('ConversationApi', () => { describe ('deleteConversation', () => { it('should make a DELETE request to delete a conversation and all messages related', async () => { // Given - const requestData: DeleteConversationRequestData = { + const requestData: Conversation.DeleteConversationRequestData = { conversation_id: 'conversation_id', }; const expectedResponse: any = {}; @@ -78,10 +67,10 @@ describe('ConversationApi', () => { describe ('getConversation', () => { it('should make a GET request to retrieve a conversation by id', async () => { // Given - const requestData: GetConversationRequestData = { + const requestData: Conversation.GetConversationRequestData = { conversation_id: 'conversation_id', }; - const expectedResponse: Conversation = { + const expectedResponse: Conversation.Conversation = { id: 'conversation_id', }; @@ -99,7 +88,7 @@ describe('ConversationApi', () => { describe ('injectEvent', () => { it('should make a POST request to inject a conversation event into a specific conversation', async () => { // Given - const requestData: InjectEventRequestData = { + const requestData: Conversation.InjectEventRequestData = { conversation_id: 'conversation_id', injectConversationEventRequestBody: { app_event: { @@ -122,7 +111,7 @@ describe('ConversationApi', () => { processing_mode: 'CONVERSATION', }, }; - const expectedResponse: InjectEventResponse = { + const expectedResponse: Conversation.InjectEventResponse = { event_id: 'event_id', accepted_time: new Date('2019-08-24T14:15:22Z'), }; @@ -141,7 +130,7 @@ describe('ConversationApi', () => { describe ('injectMessage', () => { it('should make a POST request to inject a conversation message in to a specific conversation', async () => { // Given - const requestData: InjectMessageRequestData = { + const requestData: Conversation.InjectMessageRequestData = { conversation_id: 'conversation_id', injectMessageRequestBody: { app_message: { @@ -169,10 +158,10 @@ describe('ConversationApi', () => { describe ('listConversations', () => { it('should make a GET request to ...', async () => { // Given - const requestData: ListConversationsRequestData = { + const requestData: Conversation.ListConversationsRequestData = { only_active: false, }; - const mockData: Conversation[] = [ + const mockData: Conversation.Conversation[] = [ { id: 'conversation_id', active: true, @@ -200,11 +189,11 @@ describe('ConversationApi', () => { describe ('listRecentConversations', () => { it('should make a GET request to list conversations and their most recent message', async () => { // Given - const requestData: ListRecentConversationsRequestData = { + const requestData: Conversation.ListRecentConversationsRequestData = { app_id: 'app_id', order: 'ASC', }; - const mockData: ConversationRecentMessage[] = [ + const mockData: Conversation.ConversationRecentMessage[] = [ { conversation: { active: true, @@ -284,7 +273,7 @@ describe('ConversationApi', () => { describe ('stopActiveConversation', () => { it('should make a POST request to stop the referenced conversation', async () => { // Given - const requestData: StopActiveConversationRequestData = { + const requestData: Conversation.StopActiveConversationRequestData = { conversation_id: 'conversation_id', }; const expectedResponse: any = {}; @@ -303,7 +292,7 @@ describe('ConversationApi', () => { describe ('updateConversation', () => { it('should make a PATCH request to update a conversation', async () => { // Given - const requestData: UpdateConversationRequestData = { + const requestData: Conversation.UpdateConversationRequestData = { conversation_id: 'conversation_id', metadata_update_strategy: 'REPLACE', updateConversationRequestBody: { @@ -315,7 +304,7 @@ describe('ConversationApi', () => { }, }, }; - const expectedResponse: Conversation = { + const expectedResponse: Conversation.Conversation = { id: 'conversation_id', }; diff --git a/packages/conversation/tests/rest/v1/events/events-api.test.ts b/packages/conversation/tests/rest/v1/events/events-api.test.ts index f13f31cb..1426544f 100644 --- a/packages/conversation/tests/rest/v1/events/events-api.test.ts +++ b/packages/conversation/tests/rest/v1/events/events-api.test.ts @@ -1,29 +1,8 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - ContactId, - ConversationEvent, - DeleteEventRequestData, EventsApi, EventsApiFixture, - GetEventRequestData, - IdentifiedBy, - ListEventsRequestData, - Recipient, - SendAgentJoinedEventRequest, - SendAgentJoinedEventRequestData, - SendAgentLeftEventRequest, - SendAgentLeftEventRequestData, - SendCommentReplyEventRequest, - SendCommentReplyEventRequestData, - SendComposingEndEventRequest, - SendComposingEndEventRequestData, - SendComposingEventRequest, - SendComposingEventRequestData, - SendEventRequest, - SendEventRequestData, - SendEventResponse, - SendGenericEventRequest, - SendGenericEventRequestData, + Conversation, } from '../../../../src'; import { recipientChannelIdentities, recipientContactId } from '../mocks'; import { @@ -53,7 +32,7 @@ describe('EventsApi', () => { describe ('deleteEvents', () => { it('should make a DELETE request to delete a specific event by its ID', async () => { // Given - const requestData: DeleteEventRequestData = { + const requestData: Conversation.DeleteEventRequestData = { event_id: 'event_id', }; const expectedResponse: any = {}; @@ -72,10 +51,10 @@ describe('EventsApi', () => { describe ('getEvent', () => { it('should make a GET request to retrieve an event from its ID', async () => { // Given - const requestData: GetEventRequestData = { + const requestData: Conversation.GetEventRequestData = { event_id: 'event_id', }; - const expectedResponse: ConversationEvent = { + const expectedResponse: Conversation.ConversationEvent = { id: 'event_id', channel_identity: { identity: 'identity', @@ -106,11 +85,11 @@ describe('EventsApi', () => { describe ('listEvents', () => { it('should make a GET request to list all events in a project', async () => { // Given - const requestData: ListEventsRequestData = { + const requestData: Conversation.ListEventsRequestData = { contact_id: 'contact_id', conversation_id: 'conversation_id', }; - const mockData: ConversationEvent[] = [ + const mockData: Conversation.ConversationEvent[] = [ { id: 'app_event_id', channel_identity: { @@ -186,25 +165,25 @@ describe('EventsApi', () => { describe ('send', () => { // Given - const sendEventRequest: Omit, 'recipient'> = { + const sendEventRequest: Omit, 'recipient'> = { app_id: 'app_id', event: { ...composingEvent, }, }; - const requestDataWithContactId: SendEventRequestData = { + const requestDataWithContactId: Conversation.SendEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendEventRequestData = { + const requestDataWithChannelIdentity: Conversation.SendEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendEventResponse = { + const expectedResponse: Conversation.SendEventResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), event_id: 'event_id', }; @@ -228,25 +207,25 @@ describe('EventsApi', () => { describe ('sendComposingEvent', () => { // Given - const sendEventRequest: Omit, 'recipient'> = { + const sendEventRequest: Omit, 'recipient'> = { app_id: 'app_id', event: { ...composingEvent, }, }; - const requestDataWithContactId: SendComposingEventRequestData = { + const requestDataWithContactId: Conversation.SendComposingEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendComposingEventRequestData = { + const requestDataWithChannelIdentity: Conversation.SendComposingEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendEventResponse = { + const expectedResponse: Conversation.SendEventResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), event_id: 'event_id', }; @@ -270,25 +249,25 @@ describe('EventsApi', () => { describe ('sendComposingEndEvent', () => { // Given - const sendEventRequest: Omit, 'recipient'> = { + const sendEventRequest: Omit, 'recipient'> = { app_id: 'app_id', event: { ...composingEndEvent, }, }; - const requestDataWithContactId: SendComposingEndEventRequestData = { + const requestDataWithContactId: Conversation.SendComposingEndEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendComposingEndEventRequestData = { + const requestDataWithChannelIdentity: Conversation.SendComposingEndEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendEventResponse = { + const expectedResponse: Conversation.SendEventResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), event_id: 'event_id', }; @@ -312,25 +291,25 @@ describe('EventsApi', () => { describe ('sendCommentReplyEvent', () => { // Given - const sendEventRequest: Omit, 'recipient'> = { + const sendEventRequest: Omit, 'recipient'> = { app_id: 'app_id', event: { ...commentReplyEvent, }, }; - const requestDataWithContactId: SendCommentReplyEventRequestData = { + const requestDataWithContactId: Conversation.SendCommentReplyEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendCommentReplyEventRequestData = { + const requestDataWithChannelIdentity: Conversation.SendCommentReplyEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendEventResponse = { + const expectedResponse: Conversation.SendEventResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), event_id: 'event_id', }; @@ -354,25 +333,25 @@ describe('EventsApi', () => { describe ('sendAgentJoinedEvent', () => { // Given - const sendEventRequest: Omit, 'recipient'> = { + const sendEventRequest: Omit, 'recipient'> = { app_id: 'app_id', event: { ...agentJoinedEvent, }, }; - const requestDataWithContactId: SendAgentJoinedEventRequestData = { + const requestDataWithContactId: Conversation.SendAgentJoinedEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendAgentJoinedEventRequestData = { + const requestDataWithChannelIdentity: Conversation.SendAgentJoinedEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendEventResponse = { + const expectedResponse: Conversation.SendEventResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), event_id: 'event_id', }; @@ -396,25 +375,25 @@ describe('EventsApi', () => { describe ('sendAgentLeftEvent', () => { // Given - const sendEventRequest: Omit, 'recipient'> = { + const sendEventRequest: Omit, 'recipient'> = { app_id: 'app_id', event: { ...agentLeftEvent, }, }; - const requestDataWithContactId: SendAgentLeftEventRequestData = { + const requestDataWithContactId: Conversation.SendAgentLeftEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendAgentLeftEventRequestData = { + const requestDataWithChannelIdentity: Conversation.SendAgentLeftEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendEventResponse = { + const expectedResponse: Conversation.SendEventResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), event_id: 'event_id', }; @@ -438,25 +417,25 @@ describe('EventsApi', () => { describe ('sendGenericEvent', () => { // Given - const sendEventRequest: Omit, 'recipient'> = { + const sendEventRequest: Omit, 'recipient'> = { app_id: 'app_id', event: { ...genericEvent, }, }; - const requestDataWithContactId: SendGenericEventRequestData = { + const requestDataWithContactId: Conversation.SendGenericEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendGenericEventRequestData = { + const requestDataWithChannelIdentity: Conversation.SendGenericEventRequestData = { sendEventRequestBody: { ...sendEventRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendEventResponse = { + const expectedResponse: Conversation.SendEventResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), event_id: 'event_id', }; diff --git a/packages/conversation/tests/rest/v1/messages/messages-api.test.ts b/packages/conversation/tests/rest/v1/messages/messages-api.test.ts index a22d0151..ab5df19d 100644 --- a/packages/conversation/tests/rest/v1/messages/messages-api.test.ts +++ b/packages/conversation/tests/rest/v1/messages/messages-api.test.ts @@ -1,37 +1,8 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - ContactId, - ConversationMessage, - DeleteMessageRequestData, - GetMessageRequestData, - IdentifiedBy, - ListMessagesRequestData, - messageBuilder, MessagesApi, MessagesApiFixture, - Recipient, - SendCardMessageRequest, - SendCardMessageRequestData, - SendCarouselMessageRequest, - SendCarouselMessageRequestData, - SendChoiceMessageRequest, - SendChoiceMessageRequestData, - SendContactInfoMessageRequest, - SendContactInfoMessageRequestData, - SendListMessageRequest, - SendListMessageRequestData, - SendLocationMessageRequest, - SendLocationMessageRequestData, - SendMediaMessageRequest, - SendMediaMessageRequestData, - SendMessageRequest, - SendMessageRequestData, - SendMessageResponse, - SendTemplateMessageRequest, - SendTemplateMessageRequestData, - SendTextMessageRequest, - SendTextMessageRequestData, - UpdateMessageRequestData, + Conversation, } from '../../../../src'; import { recipientChannelIdentities, recipientContactId } from '../mocks'; import { @@ -65,7 +36,7 @@ describe('MessagesApi', () => { describe ('deleteMessage', () => { it('should make a DELETE request to delete a specific message by its ID', async () => { // Given - const requestData: DeleteMessageRequestData = { + const requestData: Conversation.DeleteMessageRequestData = { message_id: 'message_id', }; const expectedResponse: any = {}; @@ -84,10 +55,10 @@ describe('MessagesApi', () => { describe ('getMessage', () => { it('should make a GET request to retrieve a specific message by its ID', async () => { // Given - const requestData: GetMessageRequestData = { + const requestData: Conversation.GetMessageRequestData = { message_id: 'message_id', }; - const expectedResponse: ConversationMessage = { + const expectedResponse: Conversation.ConversationMessage = { accept_time: new Date('2019-08-24T14:15:22Z'), app_message: { card_message: { @@ -128,8 +99,8 @@ describe('MessagesApi', () => { describe ('listMessages', () => { it('should make a GET request to list all the messages sent or received', async () => { // Given - const requestData: ListMessagesRequestData = {}; - const mockData: ConversationMessage[] = [ + const requestData: Conversation.ListMessagesRequestData = {}; + const mockData: Conversation.ConversationMessage[] = [ { accept_time: new Date('2019-08-24T14:15:22Z'), app_message: { @@ -186,25 +157,25 @@ describe('MessagesApi', () => { describe ('sendMessage', () => { // Given - const sendMessageRequest: Omit, 'recipient'> = { + const sendMessageRequest: Omit, 'recipient'> = { app_id: 'app_id', message: { - ...messageBuilder.text(textMessageItem), + ...Conversation.messageBuilder.text(textMessageItem), }, }; - const requestDataWithContactId: SendMessageRequestData = { + const requestDataWithContactId: Conversation.SendMessageRequestData = { sendMessageRequestBody: { ...sendMessageRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendMessageRequestData = { + const requestDataWithChannelIdentity: Conversation.SendMessageRequestData = { sendMessageRequestBody: { ...sendMessageRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendMessageResponse = { + const expectedResponse: Conversation.SendMessageResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), message_id: 'message_id', }; @@ -229,25 +200,25 @@ describe('MessagesApi', () => { describe ('sendCardMessage', () => { // Given - const sendCardMessageRequest: Omit, 'recipient'> = { + const sendCardMessageRequest: Omit, 'recipient'> = { app_id: 'app_id', message: { - ...messageBuilder.card(cardMessageItem), + ...Conversation.messageBuilder.card(cardMessageItem), }, }; - const requestDataWithContactId: SendCardMessageRequestData = { + const requestDataWithContactId: Conversation.SendCardMessageRequestData = { sendMessageRequestBody: { ...sendCardMessageRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendCardMessageRequestData = { + const requestDataWithChannelIdentity: Conversation.SendCardMessageRequestData = { sendMessageRequestBody: { ...sendCardMessageRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendMessageResponse = { + const expectedResponse: Conversation.SendMessageResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), message_id: 'message_id', }; @@ -271,25 +242,26 @@ describe('MessagesApi', () => { }); describe ('sendCarouselMessage', () => { - const sendCarouselMessageRequest: Omit, 'recipient'> = { + // eslint-disable-next-line max-len + const sendCarouselMessageRequest: Omit, 'recipient'> = { app_id: 'app_id', message: { - ...messageBuilder.carousel(carouselMessageItem), + ...Conversation.messageBuilder.carousel(carouselMessageItem), }, }; - const requestDataWithContactId: SendCarouselMessageRequestData = { + const requestDataWithContactId: Conversation.SendCarouselMessageRequestData = { sendMessageRequestBody: { ...sendCarouselMessageRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendCarouselMessageRequestData = { + const requestDataWithChannelIdentity: Conversation.SendCarouselMessageRequestData = { sendMessageRequestBody: { ...sendCarouselMessageRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendMessageResponse = { + const expectedResponse: Conversation.SendMessageResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), message_id: 'message_id', }; @@ -313,25 +285,25 @@ describe('MessagesApi', () => { }); describe ('sendChoiceMessage', () => { - const sendChoiceMessageRequest: Omit, 'recipient'> = { + const sendChoiceMessageRequest: Omit, 'recipient'> = { app_id: 'app_id', message: { - ...messageBuilder.choice(choiceMessageItem), + ...Conversation.messageBuilder.choice(choiceMessageItem), }, }; - const requestDataWithContactId: SendChoiceMessageRequestData = { + const requestDataWithContactId: Conversation.SendChoiceMessageRequestData = { sendMessageRequestBody: { ...sendChoiceMessageRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendChoiceMessageRequestData = { + const requestDataWithChannelIdentity: Conversation.SendChoiceMessageRequestData = { sendMessageRequestBody: { ...sendChoiceMessageRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendMessageResponse = { + const expectedResponse: Conversation.SendMessageResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), message_id: 'message_id', }; @@ -355,25 +327,26 @@ describe('MessagesApi', () => { }); describe ('sendContactInfoMessage', () => { - const sendContactInfoMessageRequest: Omit, 'recipient'> = { + // eslint-disable-next-line max-len + const sendContactInfoMessageRequest: Omit, 'recipient'> = { app_id: 'app_id', message: { - ...messageBuilder.contactInfo(contactInfoMessageItem), + ...Conversation.messageBuilder.contactInfo(contactInfoMessageItem), }, }; - const requestDataWithContactId: SendContactInfoMessageRequestData = { + const requestDataWithContactId: Conversation.SendContactInfoMessageRequestData = { sendMessageRequestBody: { ...sendContactInfoMessageRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendContactInfoMessageRequestData = { + const requestDataWithChannelIdentity: Conversation.SendContactInfoMessageRequestData = { sendMessageRequestBody: { ...sendContactInfoMessageRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendMessageResponse = { + const expectedResponse: Conversation.SendMessageResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), message_id: 'message_id', }; @@ -397,25 +370,25 @@ describe('MessagesApi', () => { }); describe ('sendListMessage', () => { - const sendListMessageRequest: Omit, 'recipient'> = { + const sendListMessageRequest: Omit, 'recipient'> = { app_id: 'app_id', message: { - ...messageBuilder.list(listMessageItem), + ...Conversation.messageBuilder.list(listMessageItem), }, }; - const requestDataWithContactId: SendListMessageRequestData = { + const requestDataWithContactId: Conversation.SendListMessageRequestData = { sendMessageRequestBody: { ...sendListMessageRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendListMessageRequestData = { + const requestDataWithChannelIdentity: Conversation.SendListMessageRequestData = { sendMessageRequestBody: { ...sendListMessageRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendMessageResponse = { + const expectedResponse: Conversation.SendMessageResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), message_id: 'message_id', }; @@ -439,25 +412,26 @@ describe('MessagesApi', () => { }); describe ('sendLocationMessage', () => { - const sendLocationMessageRequest: Omit, 'recipient'> = { + // eslint-disable-next-line max-len + const sendLocationMessageRequest: Omit, 'recipient'> = { app_id: 'app_id', message: { - ...messageBuilder.location(locationMessageItem), + ...Conversation.messageBuilder.location(locationMessageItem), }, }; - const requestDataWithContactId: SendLocationMessageRequestData = { + const requestDataWithContactId: Conversation.SendLocationMessageRequestData = { sendMessageRequestBody: { ...sendLocationMessageRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendLocationMessageRequestData = { + const requestDataWithChannelIdentity: Conversation.SendLocationMessageRequestData = { sendMessageRequestBody: { ...sendLocationMessageRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendMessageResponse = { + const expectedResponse: Conversation.SendMessageResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), message_id: 'message_id', }; @@ -481,25 +455,25 @@ describe('MessagesApi', () => { }); describe ('sendMediaMessage', () => { - const sendMediaMessageRequest: Omit, 'recipient'> = { + const sendMediaMessageRequest: Omit, 'recipient'> = { app_id: 'app_id', message: { - ...messageBuilder.media(mediaMessageItem), + ...Conversation.messageBuilder.media(mediaMessageItem), }, }; - const requestDataWithContactId: SendMediaMessageRequestData = { + const requestDataWithContactId: Conversation.SendMediaMessageRequestData = { sendMessageRequestBody: { ...sendMediaMessageRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendMediaMessageRequestData = { + const requestDataWithChannelIdentity: Conversation.SendMediaMessageRequestData = { sendMessageRequestBody: { ...sendMediaMessageRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendMessageResponse = { + const expectedResponse: Conversation.SendMessageResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), message_id: 'message_id', }; @@ -523,25 +497,26 @@ describe('MessagesApi', () => { }); describe ('sendTemplateMessage', () => { - const sendTemplateMessageRequest: Omit, 'recipient'> = { + // eslint-disable-next-line max-len + const sendTemplateMessageRequest: Omit, 'recipient'> = { app_id: 'app_id', message: { - ...messageBuilder.template(templateMessageItem), + ...Conversation.messageBuilder.template(templateMessageItem), }, }; - const requestDataWithContactId: SendTemplateMessageRequestData = { + const requestDataWithContactId: Conversation.SendTemplateMessageRequestData = { sendMessageRequestBody: { ...sendTemplateMessageRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendTemplateMessageRequestData = { + const requestDataWithChannelIdentity: Conversation.SendTemplateMessageRequestData = { sendMessageRequestBody: { ...sendTemplateMessageRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendMessageResponse = { + const expectedResponse: Conversation.SendMessageResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), message_id: 'message_id', }; @@ -565,25 +540,25 @@ describe('MessagesApi', () => { }); describe ('sendTextMessage', () => { - const sendTextMessageRequest: Omit, 'recipient'> = { + const sendTextMessageRequest: Omit, 'recipient'> = { app_id: 'app_id', message: { - ...messageBuilder.text(textMessageItem), + ...Conversation.messageBuilder.text(textMessageItem), }, }; - const requestDataWithContactId: SendTextMessageRequestData = { + const requestDataWithContactId: Conversation.SendTextMessageRequestData = { sendMessageRequestBody: { ...sendTextMessageRequest, ...recipientContactId, }, }; - const requestDataWithChannelIdentity: SendTextMessageRequestData = { + const requestDataWithChannelIdentity: Conversation.SendTextMessageRequestData = { sendMessageRequestBody: { ...sendTextMessageRequest, ...recipientChannelIdentities, }, }; - const expectedResponse: SendMessageResponse = { + const expectedResponse: Conversation.SendMessageResponse = { accepted_time: new Date('2019-08-24T14:15:22Z'), message_id: 'message_id', }; @@ -609,14 +584,14 @@ describe('MessagesApi', () => { describe ('updateMessageMetadata', () => { it('should make a PATCH request to update a message', async () => { // Given - const requestData: UpdateMessageRequestData = { + const requestData: Conversation.UpdateMessageRequestData = { message_id: 'message_id', messages_source: 'CONVERSATION_SOURCE', updateMessageRequestBody: { metadata: 'new_metadata', }, }; - const expectedResponse: ConversationMessage = { + const expectedResponse: Conversation.ConversationMessage = { app_message: { card_message: { choices: [], diff --git a/packages/conversation/tests/rest/v1/mocks.ts b/packages/conversation/tests/rest/v1/mocks.ts index 9497adfc..f7ffd30f 100644 --- a/packages/conversation/tests/rest/v1/mocks.ts +++ b/packages/conversation/tests/rest/v1/mocks.ts @@ -1,6 +1,6 @@ -import { ChannelRecipientIdentity } from '../../../src'; +import { Conversation } from '../../../src'; -const channelIdentities: ChannelRecipientIdentity[] = [ +const channelIdentities: Conversation.ChannelRecipientIdentity[] = [ { channel: 'SMS', identity: 'phoneNumber', diff --git a/packages/conversation/tests/rest/v1/templates-v1/templates-v1-api.test.ts b/packages/conversation/tests/rest/v1/templates-v1/templates-v1-api.test.ts index 7cf47aa2..c74a1e7e 100644 --- a/packages/conversation/tests/rest/v1/templates-v1/templates-v1-api.test.ts +++ b/packages/conversation/tests/rest/v1/templates-v1/templates-v1-api.test.ts @@ -1,14 +1,9 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - DeleteTemplateRequestData, - GetTemplateRequestData, - ListTemplatesRequestData, - UpdateTemplateRequestData, - V1ListTemplatesResponse, - V1Template, TemplatesV1Api, TemplatesV1ApiFixture, - CreateTemplateRequestData } from '../../../../src'; + Conversation, +} from '../../../../src'; describe('TemplatesV1Api', () => { let templatesV1Api: TemplatesV1Api; @@ -29,7 +24,7 @@ describe('TemplatesV1Api', () => { describe ('createTemplate', () => { it('should make a POST request to create a template V1', async () => { // Given - const requestData: CreateTemplateRequestData = { + const requestData: Conversation.CreateTemplateRequestData = { createTemplateRequestBody: { description: 'Template description', default_translation: 'en-US', @@ -48,7 +43,7 @@ describe('TemplatesV1Api', () => { ], }, }; - const expectedResponse: V1Template = { + const expectedResponse: Conversation.V1Template = { id: 'templateId', description: 'Template description', translations: [ @@ -86,7 +81,7 @@ describe('TemplatesV1Api', () => { describe ('deleteTemplate', () => { it('should make a DELETE request to delete the template associated to the ID', async () => { // Given - const requestData: DeleteTemplateRequestData = { + const requestData: Conversation.DeleteTemplateRequestData = { template_id: 'templateId', }; const expectedResponse: any = {}; @@ -105,10 +100,10 @@ describe('TemplatesV1Api', () => { describe ('getTemplate', () => { it('should make a GET request to get the template associated to the ID', async () => { // Given - const requestData: GetTemplateRequestData = { + const requestData: Conversation.GetTemplateRequestData = { template_id: 'templateId', }; - const expectedResponse: V1Template = { + const expectedResponse: Conversation.V1Template = { id: 'templateId', description: 'Template description', translations: [ @@ -146,8 +141,8 @@ describe('TemplatesV1Api', () => { describe ('listTemplates', () => { it('should make a GET request to list the templates belonging to the project ID', async () => { // Given - const requestData: ListTemplatesRequestData = {}; - const expectedResponse: V1ListTemplatesResponse = { + const requestData: Conversation.ListTemplatesRequestData = {}; + const expectedResponse: Conversation.V1ListTemplatesResponse = { templates: [ { id: 'templateId', @@ -189,7 +184,7 @@ describe('TemplatesV1Api', () => { describe ('updateTemplate', () => { it('should make a PATCH request to update the template associated to the ID', async () => { // Given - const requestData: UpdateTemplateRequestData = { + const requestData: Conversation.UpdateTemplateRequestData = { template_id: 'templateId', updateTemplateRequestBody: { description: 'Updated description', @@ -208,7 +203,7 @@ describe('TemplatesV1Api', () => { ], }, }; - const expectedResponse: V1Template = { + const expectedResponse: Conversation.V1Template = { id: 'templateId', description: 'Updated description', // Note that the translation array is entirely replaced by the one sent in the request diff --git a/packages/conversation/tests/rest/v1/templates-v2/templates-v2-api.test.ts b/packages/conversation/tests/rest/v1/templates-v2/templates-v2-api.test.ts index 05e35820..14ef2412 100644 --- a/packages/conversation/tests/rest/v1/templates-v2/templates-v2-api.test.ts +++ b/packages/conversation/tests/rest/v1/templates-v2/templates-v2-api.test.ts @@ -1,16 +1,8 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - V2CreateTemplateRequestData, - V2DeleteTemplateRequestData, - V2GetTemplateRequestData, - V2ListTemplatesRequestData, - V2ListTemplatesResponse, - V2ListTranslationsRequestData, - V2UpdateTemplateRequestData, - V2ListTranslationsResponse, - V2TemplateResponse, TemplatesV2Api, TemplatesV2ApiFixture, + Conversation, } from '../../../../src'; describe('TemplatesV2Api', () => { @@ -32,7 +24,7 @@ describe('TemplatesV2Api', () => { describe ('v2CreateTemplate', () => { it('should make a POST request to create a template V1', async () => { // Given - const requestData: V2CreateTemplateRequestData = { + const requestData: Conversation.V2CreateTemplateRequestData = { createTemplateRequestBody: { description: 'Template v2 description', default_translation: 'en-US', @@ -52,7 +44,7 @@ describe('TemplatesV2Api', () => { ], }, }; - const expectedResponse: V2TemplateResponse = { + const expectedResponse: Conversation.V2TemplateResponse = { id: 'templateV2Id', description: 'Template v2 description', version: 1, @@ -92,7 +84,7 @@ describe('TemplatesV2Api', () => { describe ('v2DeleteTemplate', () => { it('should make a DELETE request to delete the template associated to the ID', async () => { // Given - const requestData: V2DeleteTemplateRequestData = { + const requestData: Conversation.V2DeleteTemplateRequestData = { template_id: 'templateV2Id', }; const expectedResponse: any = {}; @@ -111,10 +103,10 @@ describe('TemplatesV2Api', () => { describe ('v2GetTemplate', () => { it('should make a GET request to get the template associated to the ID', async () => { // Given - const requestData: V2GetTemplateRequestData = { + const requestData: Conversation.V2GetTemplateRequestData = { template_id: 'templateV2Id', }; - const expectedResponse: V2TemplateResponse = { + const expectedResponse: Conversation.V2TemplateResponse = { id: 'templateV2Id', description: 'Template v2 description', version: 1, @@ -154,8 +146,8 @@ describe('TemplatesV2Api', () => { describe ('v2ListTemplates', () => { it('should make a GET request to list the templates belonging to the project ID', async () => { // Given - const requestData: V2ListTemplatesRequestData = {}; - const expectedResponse: V2ListTemplatesResponse = { + const requestData: Conversation.V2ListTemplatesRequestData = {}; + const expectedResponse: Conversation.V2ListTemplatesResponse = { templates: [ { id: 'templateV2Id', @@ -200,12 +192,12 @@ describe('TemplatesV2Api', () => { // eslint-disable-next-line max-len it('should make a GET request to list the translations belonging to the template associated to the ID', async () => { // Given - const requestData: V2ListTranslationsRequestData = { + const requestData: Conversation.V2ListTranslationsRequestData = { template_id: 'templateV2Id', language_code: 'en-US', translation_version: 'latest', }; - const expectedResponse: V2ListTranslationsResponse = { + const expectedResponse: Conversation.V2ListTranslationsResponse = { translations: [ { language_code: 'en-US', @@ -239,7 +231,7 @@ describe('TemplatesV2Api', () => { describe ('v2UpdateTemplate', () => { it('should make a PUT request to update the template associated to the ID', async () => { // Given - const requestData: V2UpdateTemplateRequestData = { + const requestData: Conversation.V2UpdateTemplateRequestData = { template_id: 'templateV2Id', updateTemplateRequestBody: { version: 1, @@ -293,7 +285,7 @@ describe('TemplatesV2Api', () => { ], }, }; - const expectedResponse: V2TemplateResponse = { + const expectedResponse: Conversation.V2TemplateResponse = { id: 'templateV2Id', description: 'Updated description v2', version: 2, diff --git a/packages/conversation/tests/rest/v1/transcoding/transcoding-api.test.ts b/packages/conversation/tests/rest/v1/transcoding/transcoding-api.test.ts index ca70ecc6..3a339321 100644 --- a/packages/conversation/tests/rest/v1/transcoding/transcoding-api.test.ts +++ b/packages/conversation/tests/rest/v1/transcoding/transcoding-api.test.ts @@ -1,6 +1,9 @@ import { SinchClientParameters } from '@sinch/sdk-client'; -import { TranscodeMessageRequestData, TranscodeMessageResponse } from '../../../../src'; -import { TranscodingApi, TranscodingApiFixture } from '../../../../src'; +import { + TranscodingApi, + TranscodingApiFixture, + Conversation, +} from '../../../../src'; describe('TranscodingApi', () => { let transcodingApi: TranscodingApi; @@ -21,7 +24,7 @@ describe('TranscodingApi', () => { describe ('transcodeMessage', () => { it('should make a POST request to transcode a generic message to a channel-specific one', async () => { // Given - const requestData: TranscodeMessageRequestData = { + const requestData: Conversation.TranscodeMessageRequestData = { transcodeMessageRequestBody: { app_id: 'app_id', app_message: { @@ -35,7 +38,7 @@ describe('TranscodingApi', () => { ], }, }; - const expectedResponse: TranscodeMessageResponse = { + const expectedResponse: Conversation.TranscodeMessageResponse = { transcoded_message: { APPLEBC: 'string', VIBER: 'string', diff --git a/packages/conversation/tests/rest/v1/webhooks/webhooks-api.test.ts b/packages/conversation/tests/rest/v1/webhooks/webhooks-api.test.ts index 06824169..2b23adbb 100644 --- a/packages/conversation/tests/rest/v1/webhooks/webhooks-api.test.ts +++ b/packages/conversation/tests/rest/v1/webhooks/webhooks-api.test.ts @@ -1,12 +1,9 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - CreateWebhookRequestData, - DeleteWebhookRequestData, - GetWebhookRequestData, ListWebhooksRequestData, - ListWebhooksResponse, UpdateWebhookRequestData, + WebhooksApi, + WebhooksApiFixture, + Conversation, } from '../../../../src'; -import { Webhook } from '../../../../src'; -import { WebhooksApi, WebhooksApiFixture } from '../../../../src'; describe('WebhooksApi', () => { let webhooksApi: WebhooksApi; @@ -27,7 +24,7 @@ describe('WebhooksApi', () => { describe ('createWebhook', () => { it('should make a POST request to create a webhook for receiving callbacks on specific triggers', async () => { // Given - const requestData: CreateWebhookRequestData = { + const requestData: Conversation.CreateWebhookRequestData = { webhookCreateRequestBody: { app_id: 'app_id', target: 'target', @@ -36,7 +33,7 @@ describe('WebhooksApi', () => { ], }, }; - const expectedResponse: Webhook = { + const expectedResponse: Conversation.Webhook = { app_id: 'app_id', client_credentials: { client_id: 'client_id', @@ -66,7 +63,7 @@ describe('WebhooksApi', () => { describe ('deleteWebhook', () => { it('should make a DELETE request to delete a webhook as specified by the webhook ID.', async () => { // Given - const requestData: DeleteWebhookRequestData = { + const requestData: Conversation.DeleteWebhookRequestData = { webhook_id: 'webhook_id', }; const expectedResponse: any = {}; @@ -85,10 +82,10 @@ describe('WebhooksApi', () => { describe ('getWebhook', () => { it('should make a GET request to get a webhook as specified by the webhook ID.', async () => { // Given - const requestData: GetWebhookRequestData = { + const requestData: Conversation.GetWebhookRequestData = { webhook_id: 'webhook_id', }; - const expectedResponse: Webhook = { + const expectedResponse: Conversation.Webhook = { app_id: 'app_id', client_credentials: { client_id: 'client_id', @@ -118,10 +115,10 @@ describe('WebhooksApi', () => { describe ('listWebhooks', () => { it('should make a GET request to list all webhooks for a given app as specified by the App ID.', async () => { // Given - const requestData: ListWebhooksRequestData = { + const requestData: Conversation.ListWebhooksRequestData = { app_id: 'app_id', }; - const expectedResponse: ListWebhooksResponse = { + const expectedResponse: Conversation.ListWebhooksResponse = { webhooks: [ { app_id: 'app_id', @@ -155,7 +152,7 @@ describe('WebhooksApi', () => { describe ('updateWebhook', () => { it('should make a PATCH request to update an existing webhook as specified by the webhook ID.', async () => { // Given - const requestData: UpdateWebhookRequestData = { + const requestData: Conversation.UpdateWebhookRequestData = { webhook_id: 'webhook_id', webhookUpdateRequestBody: { app_id: 'app_id', @@ -165,7 +162,7 @@ describe('WebhooksApi', () => { ], }, }; - const expectedResponse: Webhook = { + const expectedResponse: Conversation.Webhook = { app_id: 'app_id', client_credentials: { client_id: 'client_id', diff --git a/packages/numbers/README.md b/packages/numbers/README.md index b987d8f6..a48f2244 100644 --- a/packages/numbers/README.md +++ b/packages/numbers/README.md @@ -38,8 +38,7 @@ If you are using this SDK as part of the Sinch SDK (`@sinch/sdk-core`) you can a ```typescript import { - AvailableNumber, - GetAvailableNumberRequestData, + Numbers, NumbersService, SinchClient, UnifiedCredentials, @@ -56,12 +55,12 @@ const sinch = new SinchClient(credentials); const numbersService: NumbersService = sinch.numbers; // Build the request data -const requestData: GetAvailableNumberRequestData = { +const requestData: Numbers.GetAvailableNumberRequestData = { phoneNumber: '+17813334444', }; // Use the 'numbers' service registered on the Sinch client -const availabilityResult: AvailableNumber +const availabilityResult: Numbers.AvailableNumber = await numbersService.availableNumber.checkAvailability(requestData); ``` @@ -73,9 +72,8 @@ The SDK can be used standalone if you need to use only the Numbers APIs. import { UnifiedCredentials, } from '@sinch/sdk-client'; -import { - AvailableNumber, - GetAvailableNumberRequestData, +import { + Numbers, NumbersService, } from '@sinch/numbers'; @@ -89,12 +87,12 @@ const credentials: UnifiedCredentials = { const numbersService = new NumbersService(credentials); // Build the request data -const requestData: GetAvailableNumberRequestData = { +const requestData: Numbers.GetAvailableNumberRequestData = { phoneNumber: '+17813334444', }; // Use the standalone declaration of the 'numbers' service -const availabilityResult: AvailableNumber +const availabilityResult: Numbers.AvailableNumber = await numbersService.availableNumber.checkAvailability(requestData); ``` @@ -104,7 +102,7 @@ All the methods that interact with the Sinch APIs use Promises. You can use `awa ```typescript // Method 1: Wait for the Promise to complete (you need to be in an 'async' method) -let availabilityResult: AvailableNumber; +let availabilityResult: Numbers.AvailableNumber; try { availabilityResult = await numbersService.availableNumber.checkAvailability(requestData); console.log(`Phone number: ${availabilityResult.phoneNumber} - Type: ${availabilityResult.type}`); diff --git a/packages/numbers/src/index.ts b/packages/numbers/src/index.ts index 20936a85..fd2206ff 100644 --- a/packages/numbers/src/index.ts +++ b/packages/numbers/src/index.ts @@ -1,3 +1,3 @@ -export * from './models'; +export * as Numbers from './models'; export * from './rest'; export * from '@sinch/sdk-client'; diff --git a/packages/numbers/src/models/v1/index.ts b/packages/numbers/src/models/v1/index.ts index ebad4adf..47fa96c3 100644 --- a/packages/numbers/src/models/v1/index.ts +++ b/packages/numbers/src/models/v1/index.ts @@ -32,3 +32,4 @@ export * from './search-pattern'; export * from './sms-error-code'; export * from './voice-configuration'; export * from './enums'; +export * from './requests'; diff --git a/packages/numbers/src/models/v1/requests/active-number/active-number-request-data.ts b/packages/numbers/src/models/v1/requests/active-number/active-number-request-data.ts new file mode 100644 index 00000000..1df6ef22 --- /dev/null +++ b/packages/numbers/src/models/v1/requests/active-number/active-number-request-data.ts @@ -0,0 +1,36 @@ +import { CapabilitiesEnum, NumberTypeEnum, SearchPatternEnum } from '../../enums'; +import { ActiveNumberRequest } from '../../active-number-request'; + +export interface GetActiveNumberRequestData { + /** Output only. The phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format with leading `+`. */ + phoneNumber: string; +} + +export interface ListActiveNumbersRequestData { + /** Region code to filter by. ISO 3166-1 alpha-2 country code of the phone number. Example: `US`, `GB` or `SE`. */ + regionCode: string; + /** Number type to filter by. Options include, `MOBILE`, `LOCAL` or `TOLL_FREE`. */ + type: NumberTypeEnum; + /** Sequence of digits to search for. If you prefer or need certain digits in sequential order, you can enter the sequence of numbers here. For example, `2020`. */ + 'numberPattern.pattern'?: string; + /** Search pattern to apply. The options are, `START`, `CONTAIN`, and `END`. */ + 'numberPattern.searchPattern'?: SearchPatternEnum; + /** Number capabilities to filter by, `SMS` or `VOICE`. */ + capability?: CapabilitiesEnum; + /** The maximum number of items to return. */ + pageSize?: number; + /** The next page token value returned from a previous List request, if any. */ + pageToken?: string; + /** Supported fields for ordering by `phoneNumber` or `displayName`. */ + orderBy?: string; +} +export interface ReleaseNumberRequestData { + /** Output only. The phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format with leading `+`. */ + phoneNumber: string; +} +export interface UpdateActiveNumberRequestData { + /** Output only. The phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format with leading `+`. */ + phoneNumber: string; + /** The number body to be updated. */ + updateActiveNumberRequestBody?: ActiveNumberRequest; +} diff --git a/packages/numbers/src/models/v1/requests/available-number/available-number-request-data.ts b/packages/numbers/src/models/v1/requests/available-number/available-number-request-data.ts new file mode 100644 index 00000000..ff98fd5d --- /dev/null +++ b/packages/numbers/src/models/v1/requests/available-number/available-number-request-data.ts @@ -0,0 +1,32 @@ +import { CapabilitiesEnum, NumberTypeEnum, SearchPatternEnum } from '../../enums'; +import { RentAnyNumberRequest } from '../../rent-any-number-request'; +import { RentNumberRequest } from '../../rent-number-request'; + +export interface GetAvailableNumberRequestData { + /** Output only. The phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format with leading `+`. */ + phoneNumber: string; +} +export interface ListAvailableNumbersRequestData { + /** Region code to filter by. ISO 3166-1 alpha-2 country code of the phone number. Example: `US`, `GB` or `SE`. */ + regionCode: string; + /** Number type to filter by. Options include, `MOBILE`, `LOCAL` or `TOLL_FREE`. */ + type: NumberTypeEnum; + /** Sequence of digits to search for. If you prefer or need certain digits in sequential order, you can enter the sequence of numbers here. For example, `2020`. */ + 'numberPattern.pattern'?: string; + /** Search pattern to apply. The options are, `START`, `CONTAIN`, and `END`. */ + 'numberPattern.searchPattern'?: SearchPatternEnum; + /** Number capabilities to filter by SMS and/or VOICE. When searching, indicate the `capabilities` of the number as `SMS` and/or `VOICE`. To search for a number capable of both, list both `SMS` and `VOICE`. */ + capabilities?: Array; + /** Optional. The maximum number of items to return. */ + size?: number; +} +export interface RentAnyNumberRequestData { + /** The request to search and rent a number that matches the criteria. */ + rentAnyNumberRequestBody: RentAnyNumberRequest; +} +export interface RentNumberRequestData { + /** Output only. The phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format with leading `+`. */ + phoneNumber: string; + /** The request to rent a number. */ + rentNumberRequestBody: RentNumberRequest; +} diff --git a/packages/numbers/src/models/v1/requests/available-regions/available-regions-request-data.ts b/packages/numbers/src/models/v1/requests/available-regions/available-regions-request-data.ts new file mode 100644 index 00000000..757d1b16 --- /dev/null +++ b/packages/numbers/src/models/v1/requests/available-regions/available-regions-request-data.ts @@ -0,0 +1,11 @@ +export type RegionNumberTypeEnum = 'NUMBER_TYPE_UNSPECIFIED' | 'MOBILE' | 'LOCAL' | 'TOLL_FREE'; + +export interface ListAvailableRegionsRequestData { + /** Only returns regions for which numbers are provided with the given types v1: `MOBILE`, `LOCAL` or `TOLL_FREE`. However, you can indicate `NUMBER_TYPE_UNSPECIFIED: null` when searching. + * - NUMBER_TYPE_UNSPECIFIED: Null value + * - MOBILE: Numbers that belong to a specific range. + * - LOCAL: Numbers that are assigned to a specific geographic region. + * - TOLL_FREE: Number that are free of charge for the calling party but billed for all arriving calls. + */ + types?: Array; +} diff --git a/packages/numbers/src/models/v1/requests/callbacks/callbacks-request-data.ts b/packages/numbers/src/models/v1/requests/callbacks/callbacks-request-data.ts new file mode 100644 index 00000000..ea22e897 --- /dev/null +++ b/packages/numbers/src/models/v1/requests/callbacks/callbacks-request-data.ts @@ -0,0 +1,7 @@ +import { CallbackConfigurationUpdate } from '../../callback-configuration-update'; + +export interface GetCallbackConfigurationRequestData {} +export interface UpdateCallbackConfigurationRequestData { + /** The callback configuration details to be updated. */ + updateCallbackConfigurationRequestBody?: CallbackConfigurationUpdate; +} diff --git a/packages/numbers/src/models/v1/requests/index.ts b/packages/numbers/src/models/v1/requests/index.ts new file mode 100644 index 00000000..f0f910d9 --- /dev/null +++ b/packages/numbers/src/models/v1/requests/index.ts @@ -0,0 +1,4 @@ +export * from './active-number/active-number-request-data'; +export * from './available-number/available-number-request-data'; +export * from './available-regions/available-regions-request-data'; +export * from './callbacks/callbacks-request-data'; diff --git a/packages/numbers/src/rest/v1/active-number/active-number-api.jest.fixture.ts b/packages/numbers/src/rest/v1/active-number/active-number-api.jest.fixture.ts index e375f213..82ea6b59 100644 --- a/packages/numbers/src/rest/v1/active-number/active-number-api.jest.fixture.ts +++ b/packages/numbers/src/rest/v1/active-number/active-number-api.jest.fixture.ts @@ -1,11 +1,11 @@ -import { ActiveNumber } from '../../../models'; import { - ActiveNumberApi, + ActiveNumber, GetActiveNumberRequestData, ListActiveNumbersRequestData, ReleaseNumberRequestData, UpdateActiveNumberRequestData, -} from './active-number-api'; +} from '../../../models'; +import { ActiveNumberApi } from './active-number-api'; import { ApiListPromise } from '@sinch/sdk-client'; export class ActiveNumberApiFixture implements Partial> { diff --git a/packages/numbers/src/rest/v1/active-number/active-number-api.ts b/packages/numbers/src/rest/v1/active-number/active-number-api.ts index 52250042..86ba650d 100644 --- a/packages/numbers/src/rest/v1/active-number/active-number-api.ts +++ b/packages/numbers/src/rest/v1/active-number/active-number-api.ts @@ -1,9 +1,9 @@ import { ActiveNumber, - ActiveNumberRequest, - CapabilitiesEnum, - NumberTypeEnum, - SearchPatternEnum, + GetActiveNumberRequestData, + ListActiveNumbersRequestData, + ReleaseNumberRequestData, + UpdateActiveNumberRequestData, } from '../../../models'; import { ApiListPromise, @@ -16,40 +16,6 @@ import { } from '@sinch/sdk-client'; import { NumbersDomainApi } from '../numbers-domain-api'; -export interface GetActiveNumberRequestData { - /** Output only. The phone number in E.164 format with leading `+`. */ - phoneNumber: string; -} - -export interface ListActiveNumbersRequestData { - /** Region code to filter by. ISO 3166-1 alpha-2 country code of the phone number. Example: `US`, `GB` or `SE`. */ - regionCode: string; - /** Number type to filter by. Options include, `MOBILE`, `LOCAL` or `TOLL_FREE`. */ - type: NumberTypeEnum; - /** Sequence of digits to search for. If you prefer or need certain digits in sequential order, you can enter the sequence of numbers here. For example, `2020`. */ - 'numberPattern.pattern'?: string; - /** Search pattern to apply. The options are, `START`, `CONTAIN`, and `END`. */ - 'numberPattern.searchPattern'?: SearchPatternEnum; - /** Number capabilities to filter by, `SMS` or `VOICE`. */ - capability?: CapabilitiesEnum; - /** The maximum number of items to return. */ - pageSize?: number; - /** The next page token value returned from a previous List request, if any. */ - pageToken?: string; - /** Supported fields for ordering by `phoneNumber` or `displayName`. */ - orderBy?: string; -} -export interface ReleaseNumberRequestData { - /** Output only. The phone number in E.164 format with leading `+`. */ - phoneNumber: string; -} -export interface UpdateActiveNumberRequestData { - /** Output only. The phone number in E.164 format with leading `+`. */ - phoneNumber: string; - /** The number body to be updated. */ - activeNumberRequestBody?: ActiveNumberRequest; -} - export class ActiveNumberApi extends NumbersDomainApi { /** @@ -190,8 +156,8 @@ export class ActiveNumberApi extends NumbersDomainApi { /** * Update active number - * Update a virtual phone number. For example: you can configure SMS/Voice services or set a friendly name. To update the name that displays, modify the `displayName` parameter. - * You'll use `smsConfiguration` to update your SMS configuration and `voiceConfiguration` to update the voice configuration. + * Update a virtual phone number. For example: you can configure SMS/Voice services or set a friendly name. To update the name that displays, modify the `displayName` parameter. + * You'll use `smsConfiguration` to update your SMS configuration and `voiceConfiguration` to update the voice configuration. * @param {UpdateActiveNumberRequestData} data - The data to provide to the API call. */ public async update(data: UpdateActiveNumberRequestData): Promise { @@ -206,8 +172,8 @@ export class ActiveNumberApi extends NumbersDomainApi { 'Accept': 'application/json', }; - const body: RequestBody = data['activeNumberRequestBody'] - ? JSON.stringify(data['activeNumberRequestBody']) + const body: RequestBody = data['updateActiveNumberRequestBody'] + ? JSON.stringify(data['updateActiveNumberRequestBody']) : '{}'; const basePathUrl = `${this.client.apiClientOptions.hostname}/v1/projects/${this.client.apiClientOptions.projectId}/activeNumbers/${data['phoneNumber']}`; diff --git a/packages/numbers/src/rest/v1/available-number/available-number-api.jest.fixture.ts b/packages/numbers/src/rest/v1/available-number/available-number-api.jest.fixture.ts index 020d86c8..fafd00b8 100644 --- a/packages/numbers/src/rest/v1/available-number/available-number-api.jest.fixture.ts +++ b/packages/numbers/src/rest/v1/available-number/available-number-api.jest.fixture.ts @@ -1,11 +1,13 @@ -import { ActiveNumber, AvailableNumber, AvailableNumbersResponse } from '../../../models'; import { - AvailableNumberApi, + ActiveNumber, + AvailableNumber, + AvailableNumbersResponse, GetAvailableNumberRequestData, ListAvailableNumbersRequestData, RentAnyNumberRequestData, RentNumberRequestData, -} from './available-number-api'; +} from '../../../models'; +import { AvailableNumberApi } from './available-number-api'; export class AvailableNumberApiFixture implements Partial> { diff --git a/packages/numbers/src/rest/v1/available-number/available-number-api.ts b/packages/numbers/src/rest/v1/available-number/available-number-api.ts index 81955d45..c6188707 100644 --- a/packages/numbers/src/rest/v1/available-number/available-number-api.ts +++ b/packages/numbers/src/rest/v1/available-number/available-number-api.ts @@ -2,11 +2,10 @@ import { ActiveNumber, AvailableNumber, AvailableNumbersResponse, - CapabilitiesEnum, - NumberTypeEnum, - RentAnyNumberRequest, - RentNumberRequest, - SearchPatternEnum, + GetAvailableNumberRequestData, + ListAvailableNumbersRequestData, + RentAnyNumberRequestData, + RentNumberRequestData, } from '../../../models'; import { RequestBody, @@ -14,35 +13,6 @@ import { } from '@sinch/sdk-client'; import { NumbersDomainApi } from '../numbers-domain-api'; -export interface GetAvailableNumberRequestData { - /** Output only. The phone number in E.164 format with leading `+`. */ - phoneNumber: string; -} -export interface ListAvailableNumbersRequestData { - /** Region code to filter by. ISO 3166-1 alpha-2 country code of the phone number. Example: `US`, `GB` or `SE`. */ - regionCode: string; - /** Number type to filter by. Options include, `MOBILE`, `LOCAL` or `TOLL_FREE`. */ - type: NumberTypeEnum; - /** Sequence of digits to search for. If you prefer or need certain digits in sequential order, you can enter the sequence of numbers here. For example, `2020`. */ - 'numberPattern.pattern'?: string; - /** Search pattern to apply. The options are, `START`, `CONTAIN`, and `END`. */ - 'numberPattern.searchPattern'?: SearchPatternEnum; - /** Number capabilities to filter by SMS and/or VOICE. When searching, indicate the `capabilities` of the number as `SMS` and/or `VOICE`. To search for a number capable of both, list both `SMS` and `VOICE`. */ - capabilities?: Array; - /** Optional. The maximum number of items to return. */ - size?: number; -} -export interface RentAnyNumberRequestData { - /** The request to search and rent a number that matches the criteria. */ - rentAnyNumberRequestBody: RentAnyNumberRequest; -} -export interface RentNumberRequestData { - /** Output only. The phone number in E.164 format with leading `+`. */ - phoneNumber: string; - /** The request to rent a number. */ - rentNumberRequestBody: RentNumberRequest; -} - export class AvailableNumberApi extends NumbersDomainApi { /** diff --git a/packages/numbers/src/rest/v1/available-regions/available-regions-api.jest.fixture.ts b/packages/numbers/src/rest/v1/available-regions/available-regions-api.jest.fixture.ts index cb0c825e..81d4779a 100644 --- a/packages/numbers/src/rest/v1/available-regions/available-regions-api.jest.fixture.ts +++ b/packages/numbers/src/rest/v1/available-regions/available-regions-api.jest.fixture.ts @@ -1,5 +1,5 @@ -import { ListAvailableRegionsResponse } from '../../../models'; -import { AvailableRegionsApi, ListAvailableRegionsRequestData } from './available-regions-api'; +import { ListAvailableRegionsRequestData, ListAvailableRegionsResponse } from '../../../models'; +import { AvailableRegionsApi } from './available-regions-api'; export class AvailableRegionsApiFixture implements Partial> { diff --git a/packages/numbers/src/rest/v1/available-regions/available-regions-api.ts b/packages/numbers/src/rest/v1/available-regions/available-regions-api.ts index 0e6fa676..64b0508b 100644 --- a/packages/numbers/src/rest/v1/available-regions/available-regions-api.ts +++ b/packages/numbers/src/rest/v1/available-regions/available-regions-api.ts @@ -1,22 +1,10 @@ -import { ListAvailableRegionsResponse } from '../../../models'; +import { ListAvailableRegionsRequestData, ListAvailableRegionsResponse } from '../../../models'; import { RequestBody, SinchClientParameters, } from '@sinch/sdk-client'; import { NumbersDomainApi } from '../numbers-domain-api'; -export type RegionNumberTypeEnum = 'NUMBER_TYPE_UNSPECIFIED' | 'MOBILE' | 'LOCAL' | 'TOLL_FREE'; - -export interface ListAvailableRegionsRequestData { - /** Only returns regions for which numbers are provided with the given types v1: `MOBILE`, `LOCAL` or `TOLL_FREE`. However, you can indicate `NUMBER_TYPE_UNSPECIFIED: null` when searching. - * - NUMBER_TYPE_UNSPECIFIED: Null value - * - MOBILE: Numbers that belong to a specific range. - * - LOCAL: Numbers that are assigned to a specific geographic region. - * - TOLL_FREE: Number that are free of charge for the calling party but billed for all arriving calls. - */ - types?: Array; -} - export class AvailableRegionsApi extends NumbersDomainApi { /** diff --git a/packages/numbers/src/rest/v1/callbacks/callbacks-api.jest.fixture.ts b/packages/numbers/src/rest/v1/callbacks/callbacks-api.jest.fixture.ts index 71a77d1d..e0c52f30 100644 --- a/packages/numbers/src/rest/v1/callbacks/callbacks-api.jest.fixture.ts +++ b/packages/numbers/src/rest/v1/callbacks/callbacks-api.jest.fixture.ts @@ -1,9 +1,9 @@ -import { CallbackConfiguration } from '../../../models'; import { - CallbacksApi, + CallbackConfiguration, GetCallbackConfigurationRequestData, UpdateCallbackConfigurationRequestData, -} from './callbacks-api'; +} from '../../../models'; +import { CallbacksApi } from './callbacks-api'; export class CallbackConfigurationApiFixture implements Partial> { diff --git a/packages/numbers/src/rest/v1/callbacks/callbacks-api.ts b/packages/numbers/src/rest/v1/callbacks/callbacks-api.ts index 0159122e..43c727bc 100644 --- a/packages/numbers/src/rest/v1/callbacks/callbacks-api.ts +++ b/packages/numbers/src/rest/v1/callbacks/callbacks-api.ts @@ -1,16 +1,14 @@ -import { CallbackConfiguration, CallbackConfigurationUpdate } from '../../../models'; +import { + CallbackConfiguration, + GetCallbackConfigurationRequestData, + UpdateCallbackConfigurationRequestData, +} from '../../../models'; import { RequestBody, SinchClientParameters, } from '@sinch/sdk-client'; import { NumbersDomainApi } from '../numbers-domain-api'; -export interface GetCallbackConfigurationRequestData {} -export interface UpdateCallbackConfigurationRequestData { - /** The callback configuration details to be updated. */ - callbackConfigurationUpdateRequestBody?: CallbackConfigurationUpdate; -} - export class CallbacksApi extends NumbersDomainApi { /** @@ -76,8 +74,8 @@ export class CallbacksApi extends NumbersDomainApi { 'Accept': 'application/json', }; - const body: RequestBody = data['callbackConfigurationUpdateRequestBody'] - ? JSON.stringify(data['callbackConfigurationUpdateRequestBody']) + const body: RequestBody = data['updateCallbackConfigurationRequestBody'] + ? JSON.stringify(data['updateCallbackConfigurationRequestBody']) : '{}'; const basePathUrl = `${this.client.apiClientOptions.hostname}/v1/projects/${this.client.apiClientOptions.projectId}/callbackConfiguration`; diff --git a/packages/numbers/tests/rest/v1/active-number/active-number-api.test.ts b/packages/numbers/tests/rest/v1/active-number/active-number-api.test.ts index 96b17633..889245b8 100644 --- a/packages/numbers/tests/rest/v1/active-number/active-number-api.test.ts +++ b/packages/numbers/tests/rest/v1/active-number/active-number-api.test.ts @@ -1,12 +1,8 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - ActiveNumber, ActiveNumberApi, ActiveNumberApiFixture, - GetActiveNumberRequestData, - ListActiveNumbersRequestData, - ReleaseNumberRequestData, - UpdateActiveNumberRequestData, + Numbers, } from '../../../../src'; describe('ActiveNumberApi', () => { @@ -27,10 +23,10 @@ describe('ActiveNumberApi', () => { describe ('getActiveNumber', () => { it('should make a GET request to ...', async () => { // Given - const requestData: GetActiveNumberRequestData = { + const requestData: Numbers.GetActiveNumberRequestData = { phoneNumber: '+17813334444', }; - const expectedResponse: ActiveNumber = { + const expectedResponse: Numbers.ActiveNumber = { phoneNumber: '+17813334444', projectId: 'projectIdFromDashboard', displayName: '', @@ -74,11 +70,11 @@ describe('ActiveNumberApi', () => { describe ('listActiveNumbers', () => { it('should make a GET request to list all active numbers for a project', async () => { // Given - const requestData: ListActiveNumbersRequestData = { + const requestData: Numbers.ListActiveNumbersRequestData = { type: 'LOCAL', regionCode: 'US', }; - const mockData: ActiveNumber[] = [ + const mockData: Numbers.ActiveNumber[] = [ { phoneNumber: '+17813334444', projectId: 'projectIdFromDashboard', @@ -131,10 +127,10 @@ describe('ActiveNumberApi', () => { describe ('releaseNumber', () => { it('should make a POST request to cancel the subscription for a specific phone number', async () => { // Given - const requestData: ReleaseNumberRequestData = { + const requestData: Numbers.ReleaseNumberRequestData = { phoneNumber: '+17813334444', }; - const expectedResponse: ActiveNumber = { + const expectedResponse: Numbers.ActiveNumber = { phoneNumber: '+17813334444', projectId: 'projectIdFromDashboard', displayName: '', @@ -178,16 +174,16 @@ describe('ActiveNumberApi', () => { describe ('updateActiveNumber', () => { it('should make a PATCH request to update an active phone number configuration', async () => { // Given - const requestData: UpdateActiveNumberRequestData = { + const requestData: Numbers.UpdateActiveNumberRequestData = { phoneNumber: '+17813334444', - activeNumberRequestBody: { + updateActiveNumberRequestBody: { displayName: 'Updated display name', smsConfiguration: { servicePlanId: 'newServicePlanId', }, }, }; - const expectedResponse: ActiveNumber = { + const expectedResponse: Numbers.ActiveNumber = { phoneNumber: '+17813334444', projectId: 'projectIdFromDashboard', displayName: 'Updated display name', diff --git a/packages/numbers/tests/rest/v1/available-number/available-number-api.test.ts b/packages/numbers/tests/rest/v1/available-number/available-number-api.test.ts index 4c560d1d..e954c06d 100644 --- a/packages/numbers/tests/rest/v1/available-number/available-number-api.test.ts +++ b/packages/numbers/tests/rest/v1/available-number/available-number-api.test.ts @@ -1,14 +1,8 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - ActiveNumber, - AvailableNumber, AvailableNumberApi, AvailableNumberApiFixture, - AvailableNumbersResponse, - GetAvailableNumberRequestData, - ListAvailableNumbersRequestData, - RentAnyNumberRequestData, - RentNumberRequestData, + Numbers, } from '../../../../src'; describe('AvailableNumberApi', () => { @@ -29,10 +23,10 @@ describe('AvailableNumberApi', () => { describe ('getAvailableNumber', () => { it('should make a GET request to check if a phone number is available for use', async () => { // Given - const requestData: GetAvailableNumberRequestData = { + const requestData: Numbers.GetAvailableNumberRequestData = { phoneNumber: '+17813334444', }; - const expectedResponse: AvailableNumber = { + const expectedResponse: Numbers.AvailableNumber = { phoneNumber: '+17813334444', regionCode: 'US', type: 'LOCAL', @@ -66,14 +60,14 @@ describe('AvailableNumberApi', () => { describe ('listAvailableNumbers', () => { it('should make a GET request to list the phone numbers that are available for you to activate', async () => { // Given - const requestData: ListAvailableNumbersRequestData = { + const requestData: Numbers.ListAvailableNumbersRequestData = { regionCode: 'US', type: 'LOCAL', 'numberPattern.pattern': '%2B1781333', 'numberPattern.searchPattern': 'START', capabilities: ['SMS', 'VOICE'], }; - const expectedResponse: AvailableNumbersResponse = { + const expectedResponse: Numbers.AvailableNumbersResponse = { availableNumbers: [ { phoneNumber: '+17813334444', @@ -111,7 +105,7 @@ describe('AvailableNumberApi', () => { describe ('rentAnyNumber', () => { it('should make a POST request to rent any number that match the criteria', async () => { // Given - const requestData: RentAnyNumberRequestData = { + const requestData: Numbers.RentAnyNumberRequestData = { rentAnyNumberRequestBody: { regionCode: 'US', type: 'LOCAL', @@ -122,7 +116,7 @@ describe('AvailableNumberApi', () => { capabilities: ['SMS', 'VOICE'], }, }; - const expectedResponse: ActiveNumber = { + const expectedResponse: Numbers.ActiveNumber = { phoneNumber: '+17813334444', projectId: 'projectIdFromDashboard', displayName: '', @@ -172,7 +166,7 @@ describe('AvailableNumberApi', () => { describe ('rentNumber', () => { it('should make a POST request to rent a number', async () => { // Given - const requestData: RentNumberRequestData = { + const requestData: Numbers.RentNumberRequestData = { phoneNumber: '+17813334444', rentNumberRequestBody: { smsConfiguration: { @@ -180,7 +174,7 @@ describe('AvailableNumberApi', () => { }, }, }; - const expectedResponse: ActiveNumber = { + const expectedResponse: Numbers.ActiveNumber = { phoneNumber: '+17813334444', projectId: 'projectIdFromDashboard', displayName: '', diff --git a/packages/numbers/tests/rest/v1/available-regions/available-regions-api.test.ts b/packages/numbers/tests/rest/v1/available-regions/available-regions-api.test.ts index accbcab0..7b24a2b5 100644 --- a/packages/numbers/tests/rest/v1/available-regions/available-regions-api.test.ts +++ b/packages/numbers/tests/rest/v1/available-regions/available-regions-api.test.ts @@ -2,8 +2,7 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { AvailableRegionsApi, AvailableRegionsApiFixture, - ListAvailableRegionsRequestData, - ListAvailableRegionsResponse, + Numbers, } from '../../../../src'; describe('AvailableRegionsApi', () => { @@ -24,10 +23,10 @@ describe('AvailableRegionsApi', () => { describe ('listAvailableRegions', () => { it('should make a GET request to list all regions for numbers type provided for the project ID', async () => { // Given - const requestData: ListAvailableRegionsRequestData = { + const requestData: Numbers.ListAvailableRegionsRequestData = { types: ['LOCAL'], }; - const expectedResponse: ListAvailableRegionsResponse = { + const expectedResponse: Numbers.ListAvailableRegionsResponse = { availableRegions: [ { regionCode: 'AR', diff --git a/packages/numbers/tests/rest/v1/callbacks/callbacks-api.test.ts b/packages/numbers/tests/rest/v1/callbacks/callbacks-api.test.ts index 9d5fa184..d77ef4a0 100644 --- a/packages/numbers/tests/rest/v1/callbacks/callbacks-api.test.ts +++ b/packages/numbers/tests/rest/v1/callbacks/callbacks-api.test.ts @@ -1,9 +1,8 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - CallbackConfiguration, CallbacksApi, CallbackConfigurationApiFixture, - GetCallbackConfigurationRequestData, UpdateCallbackConfigurationRequestData, + Numbers, } from '../../../../src'; describe('CallbackConfigurationApi', () => { @@ -24,8 +23,8 @@ describe('CallbackConfigurationApi', () => { describe ('getCallbackConfiguration', () => { it('should make a GET request to retrieve the callbacks configuration for the specified project', async () => { // Given - const requestData: GetCallbackConfigurationRequestData = {}; - const expectedResponse: CallbackConfiguration = { + const requestData: Numbers.GetCallbackConfigurationRequestData = {}; + const expectedResponse: Numbers.CallbackConfiguration = { projectId: 'projectIdFromDashboard', hmacSecret: 'hmacSecret', }; @@ -44,12 +43,12 @@ describe('CallbackConfigurationApi', () => { describe ('updateCallbackConfiguration', () => { it('should make a PATCH request to update the callbacks configuration for the specified project', async () => { // Given - const requestData: UpdateCallbackConfigurationRequestData = { - callbackConfigurationUpdateRequestBody: { + const requestData: Numbers.UpdateCallbackConfigurationRequestData = { + updateCallbackConfigurationRequestBody: { hmacSecret: 'newHmacSecret', }, }; - const expectedResponse: CallbackConfiguration = { + const expectedResponse: Numbers.CallbackConfiguration = { projectId: 'projectIdFromDashboard', hmacSecret: 'newHmacSecret', }; diff --git a/packages/sms/README.md b/packages/sms/README.md index 4c363d82..e1920e62 100644 --- a/packages/sms/README.md +++ b/packages/sms/README.md @@ -43,20 +43,19 @@ If you are using this SDK as part of the Sinch SDK (`@sinch/sdk-core`) you can a ```typescript import { - SendSMSRequestData, - SendSMSResponse, + Sms, SmsService, SinchClient, ServicePlanIdCredentials, UnifiedCredentials, - Region, + SmsRegion, } from '@sinch/sdk-core'; const credentialsWithProjectId: UnifiedCredentials = { projectId: 'PROJECT_ID', keyId: 'KEY_ID', keySecret: 'KEY_SECRET', - region: Region.UNITED_STATES, // Optional, default is 'us'. Only other possibility is 'eu' + smsRegion: SmsRegion.UNITED_STATES, // Optional, default is 'us'. Only other possibility is 'eu' }; // Access the 'sms' service registered on the Sinch Client const sinchClientCreatedWithProjectId = new SinchClient(credentialsWithProjectId); @@ -65,25 +64,25 @@ const smsServiceWithProjectId: SmsService = sinchClientCreatedWithProjectId.sms; const credentialsWithServicePlanId: ServicePlanIdCredentials = { servicePlanId: 'SERVICE_PLAN_ID', apiToken: 'API_TOKEN', - region: Region.UNITED_STATES, // Optional, default is 'us'. Other possibilities are 'eu', 'br', 'au' and 'ca' + smsRegion: SmsRegion.UNITED_STATES, // Optional, default is 'us'. Other possibilities are 'eu', 'br', 'au' and 'ca' }; // Access the 'sms' service registered on the Sinch Client const sinchClientCreatedWithServicePlanId = new SinchClient(credentialsWithServicePlanId); const smsServiceWithServicePlanId: SmsService = sinchClientCreatedWithServicePlanId.sms; // Build the request data -const requestData: SendSMSRequestData = { +const requestData: Sms.SendSMSRequestData = { sendSMSRequestBody: { to: [ '+12223334444', - '+12223335555' + '+12223335555', ], from: '+12228889999', parameters: { name: { '+12223334444': 'John', default: 'there', - } + }, }, body: 'Hi ${name}', type: 'mt_text', @@ -92,12 +91,12 @@ const requestData: SendSMSRequestData = { // Use the 'sms' service registered on the Sinch client // The request will be authenticated with OAuth2 and sent to https://zt.us.sms.api.sinch.com -const availabilityResult_1: SendSMSResponse +const availabilityResult_1: Sms.SendSMSResponse = await smsServiceWithProjectId.batches.send(requestData); // Use the 'sms' service registered on the Sinch client // The request will be authenticated with the API Token and sent to https://us.sms.api.sinch.com -const availabilityResult_2: SendSMSResponse +const availabilityResult_2: Sms.SendSMSResponse = await smsServiceWithServicePlanId.batches.send(requestData); ``` @@ -107,13 +106,12 @@ The SDK can be used standalone if you need to use only the SMS APIs. As for a us ```typescript import { - Region, + SmsRegion, ServicePlanIdCredentials, UnifiedCredentials, } from '@sinch/sdk-client'; import { - SendSMSRequestData, - SendSMSResponse, + Sms, SmsService, } from '@sinch/sms'; @@ -121,7 +119,7 @@ const credentialsWithProjectId: UnifiedCredentials = { projectId: 'PROJECT_ID', keyId: 'KEY_ID', keySecret: 'KEY_SECRET', - region: Region.UNITED_STATES, // Optional, default is 'us'. Only other possibility is 'eu' + smsRegion: SmsRegion.UNITED_STATES, // Optional, default is 'us'. Only other possibility is 'eu' }; // Declare the 'sms' service in a standalone way const smsServiceWithProjectId = new SmsService(credentialsWithProjectId); @@ -129,23 +127,23 @@ const smsServiceWithProjectId = new SmsService(credentialsWithProjectId); const credentialsWithServicePlanId: ServicePlanIdCredentials = { servicePlanId: 'SERVICE_PLAN_ID', apiToken: 'API_TOKEN', - region: Region.UNITED_STATES, // Optional, default is 'us'. Other possibilities are 'eu', 'br', 'au' and 'ca' + smsRegion: SmsRegion.UNITED_STATES, // Optional, default is 'us'. Other possibilities are 'eu', 'br', 'au' and 'ca' }; // Declare the 'sms' service in a standalone way const smsServiceWithServicePlanId = new SmsService(credentialsWithServicePlanId); // Build the request data -const requestData: SendSMSRequestData = { +const requestData: Sms.SendSMSRequestData = { // some request parameters }; // Use the standalone declaration of the 'sms' service // The request will be authenticated with OAuth2 and sent to https://zt.us.sms.api.sinch.com -const response_1: SendSMSResponse = await smsServiceWithProjectId.batches.send(requestData); +const response_1: Sms.SendSMSResponse = await smsServiceWithProjectId.batches.send(requestData); // Use the standalone declaration of the 'sms' service // The request will be authenticated with the API Token and sent to https://us.sms.api.sinch.com -const response_2: SendSMSResponse = await smsServiceWithServicePlanId.batches.send(requestData); +const response_2: Sms.SendSMSResponse = await smsServiceWithServicePlanId.batches.send(requestData); ``` ## Promises @@ -154,7 +152,7 @@ All the methods that interact with the Sinch APIs use Promises. You can use `awa ```typescript // Method 1: Wait for the Promise to complete (you need to be in an 'async' method) -let batchResponse: SendSMSResponse; +let batchResponse: Sms.SendSMSResponse; try { batchResponse = await smsService.batches.send(requestData); console.log(`The SMS has been sent successfully: batch id = ${batchResponse.id}`); diff --git a/packages/sms/src/index.ts b/packages/sms/src/index.ts index 20936a85..885bafe6 100644 --- a/packages/sms/src/index.ts +++ b/packages/sms/src/index.ts @@ -1,3 +1,3 @@ -export * from './models'; +export * as Sms from './models'; export * from './rest'; export * from '@sinch/sdk-client'; diff --git a/packages/sms/src/models/v1/index.ts b/packages/sms/src/models/v1/index.ts index 07152d63..b8c19abc 100644 --- a/packages/sms/src/models/v1/index.ts +++ b/packages/sms/src/models/v1/index.ts @@ -42,3 +42,4 @@ export * from './update-group-request-auto-update'; export * from './update-group-request-auto-update-add'; export * from './update-group-request-auto-update-remove'; export * from './enums'; +export * from './requests'; diff --git a/packages/sms/src/models/v1/requests/batches/batches-request-data.ts b/packages/sms/src/models/v1/requests/batches/batches-request-data.ts new file mode 100644 index 00000000..f1ed10c4 --- /dev/null +++ b/packages/sms/src/models/v1/requests/batches/batches-request-data.ts @@ -0,0 +1,72 @@ +import { DeliveryFeedbackRequest } from '../../delivery-feedback-request'; +import { DryRunRequest, ReplaceBatchMessageRequest } from '../../dry-run-request'; +import { SendSMSRequest } from '../../send-sms-request'; +import { TextRequest } from '../../text-request'; +import { BinaryRequest } from '../../binary-request'; +import { MediaRequest } from '../../media-request'; +import { UpdateBatchMessageRequest } from '../../update-batch-message-request'; + +export interface CancelBatchMessageRequestData { + /** The batch ID you received from sending a message. */ + 'batch_id': string; +} +export interface DeliveryFeedbackRequestData { + /** The batch ID you received from sending a message. */ + 'batch_id': string; + /** A list of phone numbers (MSISDNs) that successfully received the message. */ + 'deliveryFeedbackRequestBody': DeliveryFeedbackRequest; +} +export interface DryRunRequestData { + /** Whether to include per recipient details in the response */ + 'per_recipient'?: boolean; + /** Max number of recipients to include per recipient details for in the response */ + 'number_of_recipients'?: number; + /** */ + 'dryRunRequestBody'?: DryRunRequest; +} +export interface GetBatchMessageRequestData { + /** The batch ID you received from sending a message. */ + 'batch_id': string; +} +export interface ListBatchesRequestData { + /** The page number starting from 0. */ + 'page'?: number; + /** Determines the size of a page. */ + 'page_size'?: number; + /** Only list messages sent from this sender number. Multiple originating numbers can be comma separated. Must be phone numbers or short code. */ + 'from'?: string; + /** Only list messages received at or after this date/time. Formatted as [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. Default: Now-24 */ + 'start_date'?: Date; + /** Only list messages received before this date/time. Formatted as [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. */ + 'end_date'?: Date; + /** Client reference to include */ + 'client_reference'?: string; +} +export interface ReplaceBatchMessageRequestData { + /** The batch ID you received from sending a message. */ + 'batch_id': string; + /** */ + 'replaceBatchMessageRequestBody'?: ReplaceBatchMessageRequest; +} +export interface SendSMSRequestData { + /** Default schema is Text if type is not specified. */ + 'sendSMSRequestBody'?: SendSMSRequest; +} +export interface SendTextSMSRequestData { + /** TextMessage request body */ + 'sendSMSRequestBody'?: TextRequest; +} +export interface SendBinarySMSRequestData { + /** BinaryMessage request body */ + 'sendSMSRequestBody'?: BinaryRequest; +} +export interface SendMediaSMSRequestData { + /** MediaMessage request body */ + 'sendSMSRequestBody'?: MediaRequest; +} +export interface UpdateBatchMessageRequestData { + /** The batch ID you received from sending a message. */ + 'batch_id': string; + /** */ + 'updateBatchMessageRequestBody'?: UpdateBatchMessageRequest; +} diff --git a/packages/sms/src/models/v1/requests/delivery-reports/delivery-reports-request-data.ts b/packages/sms/src/models/v1/requests/delivery-reports/delivery-reports-request-data.ts new file mode 100644 index 00000000..c658abef --- /dev/null +++ b/packages/sms/src/models/v1/requests/delivery-reports/delivery-reports-request-data.ts @@ -0,0 +1,34 @@ +import { DeliveryReportStatusEnum } from '../../enums'; + +export interface GetDeliveryReportByBatchIdRequestData { + /** The batch ID you received from sending a message. */ + 'batch_id': string; + /** The type of delivery report. - A `summary` will count the number of messages sent per status. - A `full` report give that of a `summary` report but in addition, lists phone numbers. */ + 'type'?: 'summary' | 'full'; + /** Comma separated list of delivery_report_statuses to include */ + 'status'?: DeliveryReportStatusEnum[]; + /** Comma separated list of delivery_receipt_error_codes to include */ + 'code'?: string; +} +export interface GetDeliveryReportByPhoneNumberRequestData { + /** The batch ID you received from sending a message. */ + 'batch_id': string; + /** Phone number for which you to want to search. */ + 'recipient_msisdn': string; +} +export interface ListDeliveryReportsRequestData { + /** The page number starting from 0. */ + 'page'?: number; + /** Determines the size of a page. */ + 'page_size'?: number; + /** Only list messages received at or after this date/time. Default: 24h ago */ + 'start_date'?: Date; + /** Only list messages received before this date/time. */ + 'end_date'?: Date; + /** Comma separated list of delivery report statuses to include. */ + 'status'?: DeliveryReportStatusEnum[]; + /** Comma separated list of delivery receipt error codes to include. */ + 'code'?: string; + /** Client reference to include */ + 'client_reference'?: string; +} diff --git a/packages/sms/src/models/v1/requests/groups/groups-request-data.ts b/packages/sms/src/models/v1/requests/groups/groups-request-data.ts new file mode 100644 index 00000000..9c6f40d3 --- /dev/null +++ b/packages/sms/src/models/v1/requests/groups/groups-request-data.ts @@ -0,0 +1,38 @@ +import { CreateGroupRequest } from '../../create-group-request'; +import { ReplaceGroupRequest } from '../../replace-group-request'; +import { UpdateGroupRequest } from '../../update-group-request'; + +export interface CreateGroupRequestData { + /** */ + 'createGroupRequestBody'?: CreateGroupRequest; +} +export interface DeleteGroupRequestData { + /** ID of a group that you are interested in getting. */ + 'group_id': string; +} +export interface ListMembersRequestData { + /** ID of a group that you are interested in getting. */ + 'group_id': string; +} +export interface ListGroupsRequestData { + /** The page number starting from 0. */ + 'page'?: number; + /** Determines the size of a page. */ + 'page_size'?: number; +} +export interface ReplaceGroupRequestData { + /** ID of a group that you are interested in getting. */ + 'group_id': string; + /** */ + 'replaceGroupRequestBody'?: ReplaceGroupRequest; +} +export interface GetGroupRequestData { + /** ID of a group that you are interested in getting. */ + 'group_id': string; +} +export interface UpdateGroupRequestData { + /** ID of a group that you are interested in getting. */ + 'group_id': string; + /** */ + 'updateGroupRequestBody'?: UpdateGroupRequest; +} diff --git a/packages/sms/src/models/v1/requests/inbounds/inbounds-request-data.ts b/packages/sms/src/models/v1/requests/inbounds/inbounds-request-data.ts new file mode 100644 index 00000000..5d83edc2 --- /dev/null +++ b/packages/sms/src/models/v1/requests/inbounds/inbounds-request-data.ts @@ -0,0 +1,18 @@ +export interface ListInboundMessagesRequestData { + /** The page number starting from 0. */ + 'page'?: number; + /** Determines the size of a page */ + 'page_size'?: number; + /** Only list messages sent to this destination. Multiple phone numbers formatted as either E.164 or short codes can be comma separated. */ + 'to'?: string; + /** Only list messages received at or after this date/time. Formatted as [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. Default: Now-24 */ + 'start_date'?: Date; + /** Only list messages received before this date/time. Formatted as [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. */ + 'end_date'?: Date; + /** Using a client reference in inbound messages requires additional setup on your account. Contact your [account manager](https://dashboard.sinch.com/settings/account-details) to enable this feature. Only list inbound messages that are in response to messages with a previously provided client reference. */ + 'client_reference'?: string; +} +export interface GetInboundMessageRequestData { + /** The inbound ID found when listing inbound messages. */ + 'inbound_id': string; +} diff --git a/packages/sms/src/models/v1/requests/index.ts b/packages/sms/src/models/v1/requests/index.ts new file mode 100644 index 00000000..9dcf864e --- /dev/null +++ b/packages/sms/src/models/v1/requests/index.ts @@ -0,0 +1,4 @@ +export * from './batches/batches-request-data'; +export * from './delivery-reports/delivery-reports-request-data'; +export * from './groups/groups-request-data'; +export * from './inbounds/inbounds-request-data'; diff --git a/packages/sms/src/rest/v1/batches/batches-api.jest.fixture.ts b/packages/sms/src/rest/v1/batches/batches-api.jest.fixture.ts index 85cdcdd0..36fc56cb 100644 --- a/packages/sms/src/rest/v1/batches/batches-api.jest.fixture.ts +++ b/packages/sms/src/rest/v1/batches/batches-api.jest.fixture.ts @@ -1,18 +1,22 @@ +import { BatchesApi } from './batches-api'; import { - BatchesApi, + BinaryResponse, CancelBatchMessageRequestData, DeliveryFeedbackRequestData, DryRunRequestData, + DryRunResponse, GetBatchMessageRequestData, ListBatchesRequestData, + MediaResponse, ReplaceBatchMessageRequestData, SendBinarySMSRequestData, SendMediaSMSRequestData, SendSMSRequestData, + SendSMSResponse, SendTextSMSRequestData, + TextResponse, UpdateBatchMessageRequestData, -} from './batches-api'; -import { BinaryResponse, DryRunResponse, MediaResponse, SendSMSResponse, TextResponse } from '../../../models'; +} from '../../../models'; import { ApiListPromise } from '@sinch/sdk-client'; export class BatchesApiFixture implements Partial> { diff --git a/packages/sms/src/rest/v1/batches/batches-api.ts b/packages/sms/src/rest/v1/batches/batches-api.ts index 566aad76..6e21f723 100644 --- a/packages/sms/src/rest/v1/batches/batches-api.ts +++ b/packages/sms/src/rest/v1/batches/batches-api.ts @@ -1,19 +1,19 @@ import { CancelBatchMessageResponse, - DeliveryFeedbackRequest, DryRunResponse, - DryRunRequest, ReplaceBatchMessageResponse, - ReplaceBatchMessageRequest, SendSMSResponse, - SendSMSRequest, - UpdateBatchMessageRequest, - TextRequest, - BinaryRequest, - MediaRequest, BinaryResponse, TextResponse, MediaResponse, + CancelBatchMessageRequestData, + DeliveryFeedbackRequestData, + DryRunRequestData, + GetBatchMessageRequestData, + ListBatchesRequestData, + ReplaceBatchMessageRequestData, + SendSMSRequestData, + SendTextSMSRequestData, SendBinarySMSRequestData, SendMediaSMSRequestData, UpdateBatchMessageRequestData, } from '../../../models'; import { RequestBody, @@ -26,68 +26,6 @@ import { } from '@sinch/sdk-client'; import { SmsDomainApi } from '../sms-domain-api'; -export interface CancelBatchMessageRequestData { - /** The batch ID you received from sending a message. */ - 'batch_id': string; -} -export interface DeliveryFeedbackRequestData { - /** The batch ID you received from sending a message. */ - 'batch_id': string; - /** A list of phone numbers (MSISDNs) that successfully received the message. */ - 'deliveryFeedbackRequestBody': DeliveryFeedbackRequest; -} -export interface DryRunRequestData { - /** Whether to include per recipient details in the response */ - 'per_recipient'?: boolean; - /** Max number of recipients to include per recipient details for in the response */ - 'number_of_recipients'?: number; - /** */ - 'dryRunRequestBody'?: DryRunRequest; -} -export interface GetBatchMessageRequestData { - /** The batch ID you received from sending a message. */ - 'batch_id': string; -} -export interface ListBatchesRequestData { - /** The page number starting from 0. */ - 'page'?: number; - /** Determines the size of a page. */ - 'page_size'?: number; - /** Only list messages sent from this sender number. Multiple originating numbers can be comma separated. Must be phone numbers or short code. */ - 'from'?: string; - /** Only list messages received at or after this date/time. Formatted as [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. Default: Now-24 */ - 'start_date'?: Date; - /** Only list messages received before this date/time. Formatted as [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. */ - 'end_date'?: Date; - /** Client reference to include */ - 'client_reference'?: string; -} -export interface ReplaceBatchMessageRequestData { - /** The batch ID you received from sending a message. */ - 'batch_id': string; - /** */ - 'replaceBatchMessageRequestBody'?: ReplaceBatchMessageRequest; -} -export interface SendSMSRequestData { - /** Default schema is Text if type is not specified. */ - 'sendSMSRequestBody'?: SendSMSRequest; -} -export interface SendTextSMSRequestData { - 'sendSMSRequestBody'?: TextRequest; -} -export interface SendBinarySMSRequestData { - 'sendSMSRequestBody'?: BinaryRequest; -} -export interface SendMediaSMSRequestData { - 'sendSMSRequestBody'?: MediaRequest; -} -export interface UpdateBatchMessageRequestData { - /** The batch ID you received from sending a message. */ - 'batch_id': string; - /** */ - 'updateBatchMessageRequestBody'?: UpdateBatchMessageRequest; -} - export class BatchesApi extends SmsDomainApi { /** diff --git a/packages/sms/src/rest/v1/delivery-reports/delivery-reports-api.jest.fixture.ts b/packages/sms/src/rest/v1/delivery-reports/delivery-reports-api.jest.fixture.ts index 365bc547..9f85f779 100644 --- a/packages/sms/src/rest/v1/delivery-reports/delivery-reports-api.jest.fixture.ts +++ b/packages/sms/src/rest/v1/delivery-reports/delivery-reports-api.jest.fixture.ts @@ -1,5 +1,11 @@ -import { DeliveryReportsApi, GetDeliveryReportByBatchIdRequestData, GetDeliveryReportByPhoneNumberRequestData, ListDeliveryReportsRequestData } from './delivery-reports-api'; -import { DeliveryReport, RecipientDeliveryReport } from '../../../models'; +import { DeliveryReportsApi } from './delivery-reports-api'; +import { + DeliveryReport, + GetDeliveryReportByBatchIdRequestData, + GetDeliveryReportByPhoneNumberRequestData, + ListDeliveryReportsRequestData, + RecipientDeliveryReport, +} from '../../../models'; import { ApiListPromise } from '@sinch/sdk-client'; export class DeliveryReportsApiFixture implements Partial> { diff --git a/packages/sms/src/rest/v1/delivery-reports/delivery-reports-api.ts b/packages/sms/src/rest/v1/delivery-reports/delivery-reports-api.ts index ae1a5ff2..948d1762 100644 --- a/packages/sms/src/rest/v1/delivery-reports/delivery-reports-api.ts +++ b/packages/sms/src/rest/v1/delivery-reports/delivery-reports-api.ts @@ -1,6 +1,8 @@ import { DeliveryReport, - DeliveryReportStatusEnum, + GetDeliveryReportByBatchIdRequestData, + GetDeliveryReportByPhoneNumberRequestData, + ListDeliveryReportsRequestData, RecipientDeliveryReport, } from '../../../models'; import { @@ -14,39 +16,6 @@ import { } from '@sinch/sdk-client'; import { SmsDomainApi } from '../sms-domain-api'; -export interface GetDeliveryReportByBatchIdRequestData { - /** The batch ID you received from sending a message. */ - 'batch_id': string; - /** The type of delivery report. - A `summary` will count the number of messages sent per status. - A `full` report give that of a `summary` report but in addition, lists phone numbers. */ - 'type'?: 'summary' | 'full'; - /** Comma separated list of delivery_report_statuses to include */ - 'status'?: DeliveryReportStatusEnum[]; - /** Comma separated list of delivery_receipt_error_codes to include */ - 'code'?: string; -} -export interface GetDeliveryReportByPhoneNumberRequestData { - /** The batch ID you received from sending a message. */ - 'batch_id': string; - /** Phone number for which you to want to search. */ - 'recipient_msisdn': string; -} -export interface ListDeliveryReportsRequestData { - /** The page number starting from 0. */ - 'page'?: number; - /** Determines the size of a page. */ - 'page_size'?: number; - /** Only list messages received at or after this date/time. Default: 24h ago */ - 'start_date'?: Date; - /** Only list messages received before this date/time. */ - 'end_date'?: Date; - /** Comma separated list of delivery report statuses to include. */ - 'status'?: DeliveryReportStatusEnum[]; - /** Comma separated list of delivery receipt error codes to include. */ - 'code'?: string; - /** Client reference to include */ - 'client_reference'?: string; -} - export class DeliveryReportsApi extends SmsDomainApi { /** diff --git a/packages/sms/src/rest/v1/groups/groups-api.jest.fixture.ts b/packages/sms/src/rest/v1/groups/groups-api.jest.fixture.ts index 40371099..6c1884ff 100644 --- a/packages/sms/src/rest/v1/groups/groups-api.jest.fixture.ts +++ b/packages/sms/src/rest/v1/groups/groups-api.jest.fixture.ts @@ -1,5 +1,15 @@ -import { GroupsApi, CreateGroupRequestData, DeleteGroupRequestData, ListMembersRequestData, ListGroupsRequestData, ReplaceGroupRequestData, GetGroupRequestData, UpdateGroupRequestData } from './groups-api'; -import { CreateGroupResponse, GroupResponse } from '../../../models'; +import { GroupsApi } from './groups-api'; +import { + CreateGroupResponse, + GroupResponse, + CreateGroupRequestData, + DeleteGroupRequestData, + ListMembersRequestData, + ListGroupsRequestData, + ReplaceGroupRequestData, + GetGroupRequestData, + UpdateGroupRequestData, +} from '../../../models'; import { ApiListPromise } from '@sinch/sdk-client'; export class GroupsApiFixture implements Partial> { diff --git a/packages/sms/src/rest/v1/groups/groups-api.ts b/packages/sms/src/rest/v1/groups/groups-api.ts index ffe7c154..c077867c 100644 --- a/packages/sms/src/rest/v1/groups/groups-api.ts +++ b/packages/sms/src/rest/v1/groups/groups-api.ts @@ -1,10 +1,8 @@ import { - CreateGroupResponse, - CreateGroupRequest, - ReplaceGroupRequest, - UpdateGroupRequest, - GroupResponse, - ReplaceGroupResponse, + CreateGroupRequestData, + CreateGroupResponse, DeleteGroupRequestData, GetGroupRequestData, + GroupResponse, ListGroupsRequestData, ListMembersRequestData, ReplaceGroupRequestData, + ReplaceGroupResponse, UpdateGroupRequestData, UpdateGroupResponse, } from '../../../models'; import { @@ -18,41 +16,6 @@ import { } from '@sinch/sdk-client'; import { SmsDomainApi } from '../sms-domain-api'; -export interface CreateGroupRequestData { - /** */ - 'createGroupRequestBody'?: CreateGroupRequest; -} -export interface DeleteGroupRequestData { - /** ID of a group that you are interested in getting. */ - 'group_id': string; -} -export interface ListMembersRequestData { - /** ID of a group that you are interested in getting. */ - 'group_id': string; -} -export interface ListGroupsRequestData { - /** The page number starting from 0. */ - 'page'?: number; - /** Determines the size of a page. */ - 'page_size'?: number; -} -export interface ReplaceGroupRequestData { - /** ID of a group that you are interested in getting. */ - 'group_id': string; - /** */ - 'replaceGroupRequestBody'?: ReplaceGroupRequest; -} -export interface GetGroupRequestData { - /** ID of a group that you are interested in getting. */ - 'group_id': string; -} -export interface UpdateGroupRequestData { - /** ID of a group that you are interested in getting. */ - 'group_id': string; - /** */ - 'updateGroupRequestBody'?: UpdateGroupRequest; -} - export class GroupsApi extends SmsDomainApi { /** diff --git a/packages/sms/src/rest/v1/inbounds/inbounds-api.jest.fixture.ts b/packages/sms/src/rest/v1/inbounds/inbounds-api.jest.fixture.ts index 80579eae..02e45ee5 100644 --- a/packages/sms/src/rest/v1/inbounds/inbounds-api.jest.fixture.ts +++ b/packages/sms/src/rest/v1/inbounds/inbounds-api.jest.fixture.ts @@ -1,5 +1,5 @@ -import { InboundsApi, ListInboundMessagesRequestData, GetInboundMessageRequestData } from './inbounds-api'; -import { InboundMessageResponse } from '../../../models'; +import { InboundsApi } from './inbounds-api'; +import { InboundMessageResponse, ListInboundMessagesRequestData, GetInboundMessageRequestData } from '../../../models'; import { ApiListPromise } from '@sinch/sdk-client'; export class InboundsApiFixture implements Partial> { diff --git a/packages/sms/src/rest/v1/inbounds/inbounds-api.ts b/packages/sms/src/rest/v1/inbounds/inbounds-api.ts index 71748170..cfc83de8 100644 --- a/packages/sms/src/rest/v1/inbounds/inbounds-api.ts +++ b/packages/sms/src/rest/v1/inbounds/inbounds-api.ts @@ -1,5 +1,7 @@ import { + GetInboundMessageRequestData, InboundMessageResponse, + ListInboundMessagesRequestData, } from '../../../models'; import { RequestBody, @@ -12,25 +14,6 @@ import { } from '@sinch/sdk-client'; import { SmsDomainApi } from '../sms-domain-api'; -export interface ListInboundMessagesRequestData { - /** The page number starting from 0. */ - 'page'?: number; - /** Determines the size of a page */ - 'page_size'?: number; - /** Only list messages sent to this destination. Multiple phone numbers formatted as either E.164 or short codes can be comma separated. */ - 'to'?: string; - /** Only list messages received at or after this date/time. Formatted as [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. Default: Now-24 */ - 'start_date'?: Date; - /** Only list messages received before this date/time. Formatted as [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. */ - 'end_date'?: Date; - /** Using a client reference in inbound messages requires additional setup on your account. Contact your account manager to enable this feature. Only list inbound messages that are in response to messages with a previously provided client reference. */ - 'client_reference'?: string; -} -export interface GetInboundMessageRequestData { - /** The inbound ID found when listing inbound messages. */ - 'inbound_id': string; -} - export class InboundsApi extends SmsDomainApi { /** diff --git a/packages/sms/tests/rest/v1/batches/batches-api.test.ts b/packages/sms/tests/rest/v1/batches/batches-api.test.ts index 37eb82c5..6f1f94a2 100644 --- a/packages/sms/tests/rest/v1/batches/batches-api.test.ts +++ b/packages/sms/tests/rest/v1/batches/batches-api.test.ts @@ -1,25 +1,8 @@ import { SinchClientParameters, textToHex } from '@sinch/sdk-client'; import { - ApiUpdateTextMtMessage, BatchesApi, BatchesApiFixture, - BinaryRequest, - CancelBatchMessageRequestData, - DeliveryFeedbackRequestData, - DryRunResponse, - GetBatchMessageRequestData, - ListBatchesRequestData, - ReplaceBatchMessageRequestData, - DryRunRequestData, - SendSMSRequestData, - SendSMSResponse, - UpdateBatchMessageRequestData, - SendTextSMSRequestData, - TextResponse, - SendMediaSMSRequestData, - MediaResponse, - SendBinarySMSRequestData, - BinaryResponse, + Sms, } from '../../../../src'; describe('BatchesApi', () => { @@ -39,10 +22,10 @@ describe('BatchesApi', () => { describe ('cancelBatchMessage', () => { it('should make a DELETE request to cancel a batch', async () => { // Given - const requestData: CancelBatchMessageRequestData = { + const requestData: Sms.CancelBatchMessageRequestData = { batch_id: '01HF4WG1TAVS351YYD7Q84K8HA', }; - const expectedResponse: SendSMSResponse = { + const expectedResponse: Sms.SendSMSResponse = { id: '01HF4WG1TAVS351YYD7Q84K8HA', to: [ '33444555666', @@ -73,7 +56,7 @@ describe('BatchesApi', () => { describe ('deliveryFeedback', () => { it('should make a POST request to send a delivery feedback of a message', async () => { // Given - const requestData: DeliveryFeedbackRequestData = { + const requestData: Sms.DeliveryFeedbackRequestData = { batch_id: '01HF4WG1TAVS351YYD7Q84K8HA', deliveryFeedbackRequestBody: { recipients: [ @@ -97,7 +80,7 @@ describe('BatchesApi', () => { describe ('run', () => { it('should make a POST request to perform a dry run of a batch', async () => { // Given - const requestData: DryRunRequestData = { + const requestData: Sms.DryRunRequestData = { dryRunRequestBody: { from: '+17818510001', to: [ @@ -108,7 +91,7 @@ describe('BatchesApi', () => { type: 'mt_text', }, }; - const expectedResponse: DryRunResponse = { + const expectedResponse: Sms.DryRunResponse = { number_of_messages: 1, number_of_recipients: 1, }; @@ -127,10 +110,10 @@ describe('BatchesApi', () => { describe ('getBatchMessage', () => { it('should make a GET request to retrieve a batch by its ID', async () => { // Given - const requestData: GetBatchMessageRequestData = { + const requestData: Sms.GetBatchMessageRequestData = { batch_id: '01HF4WG1TAVS351YYD7Q84K8HA', }; - const expectedResponse: SendSMSResponse = { + const expectedResponse: Sms.SendSMSResponse = { id: '01HF4WG1TAVS351YYD7Q84K8HA', to: [ '33444555666', @@ -161,8 +144,8 @@ describe('BatchesApi', () => { describe ('listBatches', () => { it('should make a GET request to list the existing batches', async () => { // Given - const requestData: ListBatchesRequestData = {}; - const mockData: SendSMSResponse[] = [ + const requestData: Sms.ListBatchesRequestData = {}; + const mockData: Sms.SendSMSResponse[] = [ { id: '01HF28S9AAGRKWP2CY92BJB569', to: [ @@ -208,7 +191,7 @@ describe('BatchesApi', () => { describe ('replaceBatch', () => { it('should make a PUT request to replace the parameters of a batch', async () => { // Given - const requestData: ReplaceBatchMessageRequestData = { + const requestData: Sms.ReplaceBatchMessageRequestData = { batch_id: '01HF4WG1TAVS351YYD7Q84K8HA', replaceBatchMessageRequestBody: { from: '+17818510001', @@ -220,9 +203,9 @@ describe('BatchesApi', () => { delivery_report: 'none', type: 'mt_binary', client_reference: 'Sinch Node.js SDK', - } as BinaryRequest, + } as Sms.BinaryRequest, }; - const expectedResponse: SendSMSResponse = { + const expectedResponse: Sms.SendSMSResponse = { id: '01HF4WG1TAVS351YYD7Q84K8HA', to: [ '33444555666', @@ -264,7 +247,7 @@ describe('BatchesApi', () => { it('should make a POST request to send a message', async () => { // Given - const requestData: SendSMSRequestData = { + const requestData: Sms.SendSMSRequestData = { sendSMSRequestBody: { type: 'mt_text', to: [ @@ -276,7 +259,7 @@ describe('BatchesApi', () => { send_at: new Date('2023-11-20T12:34:56.789Z'), }, }; - const expectedResponse: SendSMSResponse = { + const expectedResponse: Sms.SendSMSResponse = { id: '01HF4WG1TAVS351YYD7Q84K8HA', type: 'mt_text', to: [ @@ -300,7 +283,7 @@ describe('BatchesApi', () => { it('should make a POST request to send a text message', async () => { // Given - const requestData: SendTextSMSRequestData = { + const requestData: Sms.SendTextSMSRequestData = { sendSMSRequestBody: { type: 'mt_text', to: [ @@ -313,7 +296,7 @@ describe('BatchesApi', () => { }, }; - const expectedResponse: TextResponse = { + const expectedResponse: Sms.TextResponse = { id: '01HF4WG1TAVS351YYD7Q84K8HA', type: 'mt_text', to: [ @@ -337,7 +320,7 @@ describe('BatchesApi', () => { it('should make a POST request to send a binary message', async () => { // Given - const requestData: SendBinarySMSRequestData = { + const requestData: Sms.SendBinarySMSRequestData = { sendSMSRequestBody: { type: 'mt_binary', to: [ @@ -351,7 +334,7 @@ describe('BatchesApi', () => { }, }; - const expectedResponse: BinaryResponse = { + const expectedResponse: Sms.BinaryResponse = { id: '01HF4WG1TAVS351YYD7Q84K8HA', type: 'mt_binary', to: [ @@ -376,7 +359,7 @@ describe('BatchesApi', () => { it('should make a POST request to send a media message', async () => { // Given - const requestData: SendMediaSMSRequestData = { + const requestData: Sms.SendMediaSMSRequestData = { sendSMSRequestBody: { type: 'mt_media', to: [ @@ -392,7 +375,7 @@ describe('BatchesApi', () => { }, }; - const expectedResponse: MediaResponse= { + const expectedResponse: Sms.MediaResponse= { id: '01HF4WG1TAVS351YYD7Q84K8HA', type: 'mt_media', to: [ @@ -421,7 +404,7 @@ describe('BatchesApi', () => { describe ('updateBatchMessage', () => { it('should make a POST request to update all specified parameters of a batch', async () => { // Given - const requestData: UpdateBatchMessageRequestData = { + const requestData: Sms.UpdateBatchMessageRequestData = { batch_id: '01HF4WG1TAVS351YYD7Q84K8HA', updateBatchMessageRequestBody: { from: '+17818510001', @@ -434,9 +417,9 @@ describe('BatchesApi', () => { body: 'Hi ${name}! This is an updated message', delivery_report: 'none', type: 'mt_text', - } as ApiUpdateTextMtMessage, + } as Sms.ApiUpdateTextMtMessage, }; - const expectedResponse: SendSMSResponse = { + const expectedResponse: Sms.SendSMSResponse = { id: '01HF4WG1TAVS351YYD7Q84K8HA', to: [ '33444555666', diff --git a/packages/sms/tests/rest/v1/callbacks/callbacks-webhook.test.ts b/packages/sms/tests/rest/v1/callbacks/callbacks-webhook.test.ts index e234dbce..f9d2b43a 100644 --- a/packages/sms/tests/rest/v1/callbacks/callbacks-webhook.test.ts +++ b/packages/sms/tests/rest/v1/callbacks/callbacks-webhook.test.ts @@ -1,4 +1,4 @@ -import { MOBinary, MOText, RecipientDeliveryReport, SmsCallbackWebhooks } from '../../../../src'; +import { Sms, SmsCallbackWebhooks } from '../../../../src'; describe('SMS Callback Webhook', () => { let callbackWebhooks: SmsCallbackWebhooks; @@ -20,7 +20,7 @@ describe('SMS Callback Webhook', () => { }; const parsedResultFunction = () => callbackWebhooks.parseEvent(payload); expect(parsedResultFunction).not.toThrow(); - const parsedResult: MOText = parsedResultFunction() as MOText; + const parsedResult: Sms.MOText = parsedResultFunction() as Sms.MOText; expect(parsedResult.sent_at).toStrictEqual(DATE_AS_DATE); expect(parsedResult.received_at).toStrictEqual(DATE_AS_DATE); }); @@ -35,7 +35,7 @@ describe('SMS Callback Webhook', () => { }; const parsedResultFunction = () => callbackWebhooks.parseEvent(payload); expect(parsedResultFunction).not.toThrow(); - const parsedResult: MOBinary = parsedResultFunction() as MOBinary; + const parsedResult: Sms.MOBinary = parsedResultFunction() as Sms.MOBinary; expect(parsedResult.sent_at).toStrictEqual(DATE_AS_DATE); expect(parsedResult.received_at).toStrictEqual(DATE_AS_DATE); }); @@ -92,7 +92,7 @@ describe('SMS Callback Webhook', () => { }; const parsedResultFunction = () => callbackWebhooks.parseEvent(payload); expect(parsedResultFunction).not.toThrow(); - const parsedResult: RecipientDeliveryReport = parsedResultFunction() as RecipientDeliveryReport; + const parsedResult: Sms.RecipientDeliveryReport = parsedResultFunction() as Sms.RecipientDeliveryReport; expect(parsedResult.at).toStrictEqual(DATE_AS_DATE); expect(parsedResult.operator_status_at).toStrictEqual(DATE_AS_DATE); }); @@ -109,7 +109,7 @@ describe('SMS Callback Webhook', () => { }; const parsedResultFunction = () => callbackWebhooks.parseEvent(payload); expect(parsedResultFunction).not.toThrow(); - const parsedResult: RecipientDeliveryReport = parsedResultFunction() as RecipientDeliveryReport; + const parsedResult: Sms.RecipientDeliveryReport = parsedResultFunction() as Sms.RecipientDeliveryReport; expect(parsedResult.at).toStrictEqual(DATE_AS_DATE); expect(parsedResult.operator_status_at).toStrictEqual(DATE_AS_DATE); }); diff --git a/packages/sms/tests/rest/v1/delivery-reports/delivery-reports-api.test.ts b/packages/sms/tests/rest/v1/delivery-reports/delivery-reports-api.test.ts index 84fe0c0d..6a6c7f27 100644 --- a/packages/sms/tests/rest/v1/delivery-reports/delivery-reports-api.test.ts +++ b/packages/sms/tests/rest/v1/delivery-reports/delivery-reports-api.test.ts @@ -1,12 +1,8 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - DeliveryReport, DeliveryReportsApi, DeliveryReportsApiFixture, - GetDeliveryReportByBatchIdRequestData, - GetDeliveryReportByPhoneNumberRequestData, - ListDeliveryReportsRequestData, - RecipientDeliveryReport, + Sms, } from '../../../../src'; describe('DeliveryReportsApi', () => { @@ -26,10 +22,10 @@ describe('DeliveryReportsApi', () => { describe ('getDeliveryReportByBatchId', () => { it('should make a GET request to retrieve a delivery report by its ID', async () => { // Given - const requestData: GetDeliveryReportByBatchIdRequestData = { + const requestData: Sms.GetDeliveryReportByBatchIdRequestData = { batch_id: '01HF28S9AAGRKWP2CY92BJB569', }; - const expectedResponse: DeliveryReport = { + const expectedResponse: Sms.DeliveryReport = { batch_id: '01HF28S9AAGRKWP2CY92BJB569', statuses: [ { @@ -60,11 +56,11 @@ describe('DeliveryReportsApi', () => { it('should make a GET request to retrieve a delivery report by its ID ' + 'and filter for a specific phone number', async () => { // Given - const requestData: GetDeliveryReportByPhoneNumberRequestData = { + const requestData: Sms.GetDeliveryReportByPhoneNumberRequestData = { batch_id: '01HF28S9AAGRKWP2CY92BJB569', recipient_msisdn: '+33444555666', }; - const expectedResponse: RecipientDeliveryReport = { + const expectedResponse: Sms.RecipientDeliveryReport = { batch_id: '01HF28S9AAGRKWP2CY92BJB569', code: 60, at: new Date('2023-11-12T17:20:00Z'), @@ -87,8 +83,8 @@ describe('DeliveryReportsApi', () => { describe ('getDeliveryReports', () => { it('should make a GET request to list the delivery reports', async () => { // Given - const requestData: ListDeliveryReportsRequestData = {}; - const mockData: RecipientDeliveryReport[] = [ + const requestData: Sms.ListDeliveryReportsRequestData = {}; + const mockData: Sms.RecipientDeliveryReport[] = [ { batch_id: '01HF28S9AAGRKWP2CY92BJB569', code: 60, diff --git a/packages/sms/tests/rest/v1/groups/groups-api.test.ts b/packages/sms/tests/rest/v1/groups/groups-api.test.ts index 59e0197b..97685e34 100644 --- a/packages/sms/tests/rest/v1/groups/groups-api.test.ts +++ b/packages/sms/tests/rest/v1/groups/groups-api.test.ts @@ -1,11 +1,8 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - CreateGroupRequestData, - CreateGroupResponse, - DeleteGroupRequestData, ListMembersRequestData, GroupsApi, - GroupsApiFixture, ListGroupsRequestData, ReplaceGroupRequestData, GetGroupRequestData, - UpdateGroupRequestData, GroupResponse, + GroupsApiFixture, + Sms, } from '../../../../src'; describe('GroupsApi', () => { @@ -25,7 +22,7 @@ describe('GroupsApi', () => { describe ('createGroup', () => { it('should make a POST request to create a group', async () => { // Given - const requestData: CreateGroupRequestData = { + const requestData: Sms.CreateGroupRequestData = { createGroupRequestBody: { name: 'My group', members: [ @@ -34,7 +31,7 @@ describe('GroupsApi', () => { ], }, }; - const expectedResponse: CreateGroupResponse = { + const expectedResponse: Sms.CreateGroupResponse = { id: '01HF6EFE21REWJC3B3JWG4FYZ7', name: 'My group', size: 2, @@ -56,7 +53,7 @@ describe('GroupsApi', () => { describe ('deleteGroup', () => { it('should make a DELETE request to delete a group', async () => { // Given - const requestData: DeleteGroupRequestData = { + const requestData: Sms.DeleteGroupRequestData = { group_id: '01HF6EFE21REWJC3B3JWG4FYZ7', }; const expectedResponse: void = undefined; @@ -75,7 +72,7 @@ describe('GroupsApi', () => { describe ('getMembers', () => { it('should make a GET request to list the members of a group', async () => { // Given - const requestData: ListMembersRequestData = { + const requestData: Sms.ListMembersRequestData = { group_id: '01HF6EFE21REWJC3B3JWG4FYZ7', }; const expectedResponse: string[] = [ @@ -97,9 +94,9 @@ describe('GroupsApi', () => { describe ('listGroups', () => { it('should make a GET request to list the existing groups', async () => { // Given - const requestData: ListGroupsRequestData = {}; + const requestData: Sms.ListGroupsRequestData = {}; - const mockData: GroupResponse[] =[ + const mockData: Sms.GroupResponse[] =[ { id: '01HF6EFE21REWJC3B3JWG4FYZ7', name: 'My group', @@ -131,7 +128,7 @@ describe('GroupsApi', () => { describe ('replaceGroup', () => { it('should make a PUT request to replace the members of a group', async () => { // Given - const requestData: ReplaceGroupRequestData = { + const requestData: Sms.ReplaceGroupRequestData = { group_id: '01HF6EFE21REWJC3B3JWG4FYZ7', replaceGroupRequestBody: { name: 'My new group name', @@ -140,7 +137,7 @@ describe('GroupsApi', () => { ], }, }; - const expectedResponse: GroupResponse = { + const expectedResponse: Sms.GroupResponse = { id: '01HF6EFE21REWJC3B3JWG4FYZ7', name: 'My new group name', size: 1, @@ -162,10 +159,10 @@ describe('GroupsApi', () => { describe ('retrieveGroup', () => { it('should make a GET request to retrieve a group by its ID', async () => { // Given - const requestData: GetGroupRequestData = { + const requestData: Sms.GetGroupRequestData = { group_id: '01HF6EFE21REWJC3B3JWG4FYZ7', }; - const expectedResponse: GroupResponse = { + const expectedResponse: Sms.GroupResponse = { id: '01HF6EFE21REWJC3B3JWG4FYZ7', name: 'My new group name', size: 1, @@ -187,7 +184,7 @@ describe('GroupsApi', () => { describe ('updateGroup', () => { it('should make a POST request to update the members of a group', async () => { // Given - const requestData: UpdateGroupRequestData = { + const requestData: Sms.UpdateGroupRequestData = { group_id: '01HF6EFE21REWJC3B3JWG4FYZ7', updateGroupRequestBody: { add: [ @@ -196,7 +193,7 @@ describe('GroupsApi', () => { ], }, }; - const expectedResponse: GroupResponse = { + const expectedResponse: Sms.GroupResponse = { id: '01HF6EFE21REWJC3B3JWG4FYZ7', name: 'My new group name', size: 3, diff --git a/packages/sms/tests/rest/v1/inbounds/inbounds-api.test.ts b/packages/sms/tests/rest/v1/inbounds/inbounds-api.test.ts index 2d07706f..2091f783 100644 --- a/packages/sms/tests/rest/v1/inbounds/inbounds-api.test.ts +++ b/packages/sms/tests/rest/v1/inbounds/inbounds-api.test.ts @@ -1,10 +1,8 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - InboundMessageResponse, InboundsApi, InboundsApiFixture, - ListInboundMessagesRequestData, - GetInboundMessageRequestData, + Sms, } from '../../../../src'; describe('InboundsApi', () => { @@ -24,8 +22,8 @@ describe('InboundsApi', () => { describe ('listInboundMessages', () => { it('should make a GET request to list the inbound messages', async () => { // Given - const requestData: ListInboundMessagesRequestData = {}; - const mockData: InboundMessageResponse[] = [ + const requestData: Sms.ListInboundMessagesRequestData = {}; + const mockData: Sms.InboundMessageResponse[] = [ { id: '01HEWZK16ENY7SZF7A2YBYGZDP', from: '17818510001', @@ -58,10 +56,10 @@ describe('InboundsApi', () => { describe ('retrieveInboundMessage', () => { it('should make a GET request to retrieve an inbound message by its ID', async () => { // Given - const requestData: GetInboundMessageRequestData = { + const requestData: Sms.GetInboundMessageRequestData = { inbound_id: '01HEWZK16ENY7SZF7A2YBYGZDP', }; - const expectedResponse: InboundMessageResponse = { + const expectedResponse: Sms.InboundMessageResponse = { id: '01HEWZK16ENY7SZF7A2YBYGZDP', from: '17818510001', to: '33444555666', diff --git a/packages/verification/README.md b/packages/verification/README.md index f602cdfa..fade18cc 100644 --- a/packages/verification/README.md +++ b/packages/verification/README.md @@ -37,8 +37,7 @@ If you are using this SDK as part of the Sinch SDK (`@sinch/sdk-core`) you can a ```typescript import { - InitiateVerificationResponse, - StartVerificationRequestData, + Verification, SinchClient, ApplicationCredentials, VerificationService, @@ -54,7 +53,7 @@ const sinch = new SinchClient(credentials); const verificationService: VerificationService = sinch.verification; // Build the request data -const requestData: StartVerificationRequestData = { +const requestData: Verification.StartVerificationRequestData = { initiateVerificationRequestBody: { identity: { type: 'number', @@ -65,7 +64,7 @@ const requestData: StartVerificationRequestData = { }; // Use the 'verification' service registered on the Sinch client -const verificationInitResponse: InitiateVerificationResponse +const verificationInitResponse: Verification.InitiateVerificationResponse = await verificationService.verifications.start(requestData); ``` @@ -77,9 +76,8 @@ The SDK can be used standalone if you need to use only the Verification APIs. import { ApplicationCredentials } from '@sinch/sdk-client'; -import { - InitiateVerificationResponse, - StartVerificationRequestData, +import { + Verification, VerificationService, } from '@sinch/verification'; @@ -92,7 +90,7 @@ const credentials: ApplicationCredentials = { const verificationService = new VerificationService(credentials); // Build the request data -const requestData: StartVerificationRequestData = { +const requestData: Verification.StartVerificationRequestData = { initiateVerificationRequestBody: { identity: { type: 'number', @@ -103,7 +101,7 @@ const requestData: StartVerificationRequestData = { }; // Use the standalone declaration of the 'verification' service -const verificationInitResponse: InitiateVerificationResponse +const verificationInitResponse: Verification.InitiateVerificationResponse = await verificationService.verifications.start(requestData); ``` @@ -113,7 +111,7 @@ All the methods that interact with the Sinch APIs use Promises. You can use `awa ```typescript // Method 1: Wait for the Promise to complete (you need to be in an 'async' method) -let verificationInitResponse: InitiateVerificationResponse; +let verificationInitResponse: Verification.InitiateVerificationResponse; try { verificationInitResponse = await verificationService.verifications.start(requestData); console.log(`Verification ID = ${verificationInitResponse.id}`); diff --git a/packages/verification/src/index.ts b/packages/verification/src/index.ts index bd163908..c232b498 100644 --- a/packages/verification/src/index.ts +++ b/packages/verification/src/index.ts @@ -1,2 +1,3 @@ -export * from './models'; +export * as Verification from './models'; export * from './rest'; +export * from '@sinch/sdk-client'; diff --git a/packages/verification/src/models/v1/helper.ts b/packages/verification/src/models/v1/helper.ts index 4eefceb1..780ea68d 100644 --- a/packages/verification/src/models/v1/helper.ts +++ b/packages/verification/src/models/v1/helper.ts @@ -1,6 +1,7 @@ import { ReportCalloutVerificationByIdentityRequestData, - ReportCalloutVerificationByIdRequestData, ReportFlashCallVerificationByIdentityRequestData, + ReportCalloutVerificationByIdRequestData, + ReportFlashCallVerificationByIdentityRequestData, ReportFlashCallVerificationByIdRequestData, ReportSmsVerificationByIdentityRequestData, ReportSmsVerificationByIdRequestData, @@ -8,10 +9,10 @@ import { StartFlashCallVerificationRequestData, StartSeamlessVerificationRequestData, StartSmsVerificationRequestData, -} from '../../rest'; +} from './requests'; -export const verificationsHelper = { - buildStartSmsVerificationRequest: ( +export const startVerificationHelper = { + buildSmsRequest: ( phoneNumber: string, reference?: string, ): StartSmsVerificationRequestData => { @@ -25,7 +26,7 @@ export const verificationsHelper = { }, }; }, - buildStartCalloutVerificationRequest: ( + buildCalloutRequest: ( phoneNumber: string, reference?: string, ): StartCalloutVerificationRequestData => { @@ -39,7 +40,7 @@ export const verificationsHelper = { }, }; }, - buildStartFlashCallVerificationRequest: ( + buildFlashCallRequest: ( phoneNumber: string, reference?: string, dialTimeout?: number, @@ -59,7 +60,7 @@ export const verificationsHelper = { }, }; }, - buildStartSeamlessVerificationRequest: ( + buildSeamlessRequest: ( phoneNumber: string, reference?: string, ): StartSeamlessVerificationRequestData => { @@ -73,7 +74,9 @@ export const verificationsHelper = { }, }; }, - buildReportSmsVerificationByIdRequest: ( +}; +export const reportVerificationByIdHelper = { + buildSmsRequest: ( id: string, code: string, cli?: string, @@ -88,7 +91,7 @@ export const verificationsHelper = { }, }; }, - buildReportCalloutVerificationByIdRequest: ( + buildCalloutRequest: ( id: string, code: string, ): ReportCalloutVerificationByIdRequestData => { @@ -101,7 +104,7 @@ export const verificationsHelper = { }, }; }, - buildReportFlashCallVerificationByIdRequest: ( + buildFlashCallRequest: ( id: string, cli: string, ): ReportFlashCallVerificationByIdRequestData => { @@ -114,7 +117,9 @@ export const verificationsHelper = { }, }; }, - buildReportSmsVerificationByIdentityRequest: ( +}; +export const reportVerificationByIdentityHelper = { + buildSmsRequest: ( identity: string, code: string, cli?: string, @@ -129,7 +134,7 @@ export const verificationsHelper = { }, }; }, - buildReportCalloutVerificationByIdentityRequest: ( + buildCalloutRequest: ( identity: string, code: string, ): ReportCalloutVerificationByIdentityRequestData => { @@ -142,7 +147,7 @@ export const verificationsHelper = { }, }; }, - buildReportFlashCallVerificationByIdentityRequest: ( + buildFlashCallRequest: ( identity: string, cli: string, ): ReportFlashCallVerificationByIdentityRequestData => { diff --git a/packages/verification/src/models/v1/index.ts b/packages/verification/src/models/v1/index.ts index 49186dd3..b22615ea 100644 --- a/packages/verification/src/models/v1/index.ts +++ b/packages/verification/src/models/v1/index.ts @@ -24,3 +24,4 @@ export * from './verification-result-event-response'; export * from './verification-error'; export * from './enums'; export * from './helper'; +export * from './requests'; diff --git a/packages/verification/src/models/v1/requests/index.ts b/packages/verification/src/models/v1/requests/index.ts new file mode 100644 index 00000000..ce556798 --- /dev/null +++ b/packages/verification/src/models/v1/requests/index.ts @@ -0,0 +1,2 @@ +export * from './verification-status/verification-status-request-data'; +export * from './verifications/verifications-request-data'; diff --git a/packages/verification/src/models/v1/requests/verification-status/verification-status-request-data.ts b/packages/verification/src/models/v1/requests/verification-status/verification-status-request-data.ts new file mode 100644 index 00000000..69c09aed --- /dev/null +++ b/packages/verification/src/models/v1/requests/verification-status/verification-status-request-data.ts @@ -0,0 +1,14 @@ +export interface VerificationStatusByIdRequestData { + /** The ID of the verification. */ + 'id': string; +} +export interface VerificationStatusByIdentityRequestData { + /** For type `number` use a [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537)-compatible phone number. */ + 'endpoint': string; + /** The method of the verification. */ + 'method': 'sms' | 'callout' | 'flashCall'; +} +export interface VerificationStatusByReferenceRequestData { + /** The custom reference of the verification. */ + 'reference': string; +} diff --git a/packages/verification/src/models/v1/requests/verifications/verifications-request-data.ts b/packages/verification/src/models/v1/requests/verifications/verifications-request-data.ts new file mode 100644 index 00000000..2c8e064a --- /dev/null +++ b/packages/verification/src/models/v1/requests/verifications/verifications-request-data.ts @@ -0,0 +1,71 @@ +import { + CalloutVerificationReportRequest, + FlashCallVerificationReportRequest, + SmsVerificationReportRequest, +} from '../../verification-report-request'; +import { + StartSeamlessVerification, + StartVerificationWithCallout, + StartVerificationWithFlashCall, + StartVerificationWithSms, +} from '../../start-verification-request'; + +interface ReportVerificationByIdRequestDataBase { + /** The ID of the verification. */ + 'id': string; +} + +export interface ReportSmsVerificationByIdRequestData extends ReportVerificationByIdRequestDataBase { + /** Request body to report a verification started with an SMS by its ID */ + 'reportSmsVerificationByIdRequestBody': SmsVerificationReportRequest; +} + +export interface ReportFlashCallVerificationByIdRequestData extends ReportVerificationByIdRequestDataBase { + /** Request body to report a verification started with a flashCall by its ID */ + 'reportFlashCallVerificationByIdRequestBody': FlashCallVerificationReportRequest; +} + +export interface ReportCalloutVerificationByIdRequestData extends ReportVerificationByIdRequestDataBase { + /** Request body to report a verification started with a callout by its ID */ + 'reportCalloutVerificationByIdRequestBody': CalloutVerificationReportRequest; +} + +interface ReportVerificationByIdentityRequestDataBase { + /** For type `number` use a [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537)-compatible phone number. */ + 'endpoint': string; +} + +export interface ReportSmsVerificationByIdentityRequestData extends ReportVerificationByIdentityRequestDataBase { + /** Request body to report a verification started with an SMS by its identity */ + 'reportSmsVerificationByIdentityRequestBody': SmsVerificationReportRequest; +} + +export interface ReportFlashCallVerificationByIdentityRequestData extends ReportVerificationByIdentityRequestDataBase { + /** Request body to report a verification started with a flashCall by its identity */ + 'reportFlashCallVerificationByIdentityRequestBody': FlashCallVerificationReportRequest; +} + +export interface ReportCalloutVerificationByIdentityRequestData extends ReportVerificationByIdentityRequestDataBase { + /** Request body to report a verification started with a callout by its identity */ + 'reportCalloutVerificationByIdentityRequestBody': CalloutVerificationReportRequest; +} + +export interface StartSmsVerificationRequestData { + /** Request body to start a verification with an SMS */ + 'startVerificationWithSmsRequestBody': StartVerificationWithSms; +} + +export interface StartFlashCallVerificationRequestData { + /** Request body to start a verification with a flashCall */ + 'startVerificationWithFlashCallRequestBody': StartVerificationWithFlashCall; +} + +export interface StartCalloutVerificationRequestData { + /** Request body to start a verification with a callout */ + 'startVerificationWithCalloutRequestBody': StartVerificationWithCallout; +} + +export interface StartSeamlessVerificationRequestData { + /** Request body to start a seamless verification */ + 'startSeamlessVerificationRequestBody': StartSeamlessVerification; +} diff --git a/packages/verification/src/rest/v1/verification-status/verification-status-api.jest.fixture.ts b/packages/verification/src/rest/v1/verification-status/verification-status-api.jest.fixture.ts index 1dfdb4a9..2c9e7d65 100644 --- a/packages/verification/src/rest/v1/verification-status/verification-status-api.jest.fixture.ts +++ b/packages/verification/src/rest/v1/verification-status/verification-status-api.jest.fixture.ts @@ -1,5 +1,10 @@ -import { VerificationStatusApi, VerificationStatusByIdRequestData, VerificationStatusByIdentityRequestData, VerificationStatusByReferenceRequestData } from './verification-status-api'; -import { VerificationReportResponse } from '../../../models'; +import { VerificationStatusApi } from './verification-status-api'; +import { + VerificationReportResponse, + VerificationStatusByIdRequestData, + VerificationStatusByIdentityRequestData, + VerificationStatusByReferenceRequestData, +} from '../../../models'; export class VerificationStatusApiFixture implements Partial> { diff --git a/packages/verification/src/rest/v1/verification-status/verification-status-api.ts b/packages/verification/src/rest/v1/verification-status/verification-status-api.ts index 49c02d81..ee6d5624 100644 --- a/packages/verification/src/rest/v1/verification-status/verification-status-api.ts +++ b/packages/verification/src/rest/v1/verification-status/verification-status-api.ts @@ -2,24 +2,14 @@ import { RequestBody, SinchClientParameters, } from '@sinch/sdk-client'; -import { VerificationReportResponse } from '../../../models'; +import { + VerificationReportResponse, + VerificationStatusByIdentityRequestData, + VerificationStatusByIdRequestData, + VerificationStatusByReferenceRequestData, +} from '../../../models'; import { VerificationDomainApi } from '../verification-domain-api'; -export interface VerificationStatusByIdRequestData { - /** The ID of the verification. */ - 'id': string; -} -export interface VerificationStatusByIdentityRequestData { - /** For type `number` use a [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537)-compatible phone number. */ - 'endpoint': string; - /** The method of the verification. */ - 'method': 'sms' | 'callout' | 'flashCall'; -} -export interface VerificationStatusByReferenceRequestData { - /** The custom reference of the verification. */ - 'reference': string; -} - export class VerificationStatusApi extends VerificationDomainApi { /** diff --git a/packages/verification/src/rest/v1/verifications/verifications-api.jest.fixture.ts b/packages/verification/src/rest/v1/verifications/verifications-api.jest.fixture.ts index f365b744..7a2c0ec8 100644 --- a/packages/verification/src/rest/v1/verifications/verifications-api.jest.fixture.ts +++ b/packages/verification/src/rest/v1/verifications/verifications-api.jest.fixture.ts @@ -1,11 +1,12 @@ +import { VerificationsApi } from './verifications-api'; import { - StartCalloutVerificationResponse, CalloutVerificationReportResponse, + StartCalloutVerificationResponse, + CalloutVerificationReportResponse, StartSeamlessVerificationResponse, - StartFlashCallVerificationResponse, FlashCallVerificationReportResponse, - StartSmsVerificationResponse, SMSVerificationReportResponse, -} from '../../../models'; -import { - VerificationsApi, + StartFlashCallVerificationResponse, + FlashCallVerificationReportResponse, + StartSmsVerificationResponse, + SMSVerificationReportResponse, StartSmsVerificationRequestData, StartFlashCallVerificationRequestData, StartCalloutVerificationRequestData, @@ -14,8 +15,9 @@ import { ReportCalloutVerificationByIdRequestData, ReportFlashCallVerificationByIdRequestData, ReportSmsVerificationByIdentityRequestData, - ReportFlashCallVerificationByIdentityRequestData, ReportCalloutVerificationByIdentityRequestData, -} from './verifications-api'; + ReportFlashCallVerificationByIdentityRequestData, + ReportCalloutVerificationByIdentityRequestData, +} from '../../../models'; export class VerificationsApiFixture implements Partial> { diff --git a/packages/verification/src/rest/v1/verifications/verifications-api.ts b/packages/verification/src/rest/v1/verifications/verifications-api.ts index be43e998..a94e3543 100644 --- a/packages/verification/src/rest/v1/verifications/verifications-api.ts +++ b/packages/verification/src/rest/v1/verifications/verifications-api.ts @@ -1,12 +1,21 @@ import { - StartCalloutVerificationResponse, CalloutVerificationReportRequest, CalloutVerificationReportResponse, + StartCalloutVerificationResponse, + CalloutVerificationReportResponse, StartSeamlessVerificationResponse, - StartFlashCallVerificationResponse, FlashCallVerificationReportRequest, FlashCallVerificationReportResponse, - StartSmsVerificationResponse, SmsVerificationReportRequest, SMSVerificationReportResponse, - StartSeamlessVerification, - StartVerificationWithCallout, - StartVerificationWithFlashCall, - StartVerificationWithSms, + StartFlashCallVerificationResponse, + FlashCallVerificationReportResponse, + StartSmsVerificationResponse, + SMSVerificationReportResponse, + ReportSmsVerificationByIdRequestData, + ReportFlashCallVerificationByIdRequestData, + ReportCalloutVerificationByIdRequestData, + ReportSmsVerificationByIdentityRequestData, + ReportFlashCallVerificationByIdentityRequestData, + ReportCalloutVerificationByIdentityRequestData, + StartSmsVerificationRequestData, + StartFlashCallVerificationRequestData, + StartCalloutVerificationRequestData, + StartSeamlessVerificationRequestData, } from '../../../models'; import { RequestBody, @@ -14,66 +23,6 @@ import { } from '@sinch/sdk-client'; import { VerificationDomainApi } from '../verification-domain-api'; -interface ReportVerificationByIdRequestDataBase { - /** The ID of the verification. */ - 'id': string; -} - -export interface ReportSmsVerificationByIdRequestData extends ReportVerificationByIdRequestDataBase { - /** Request body to report a verification started with an SMS by its ID */ - 'reportSmsVerificationByIdRequestBody': SmsVerificationReportRequest; -} - -export interface ReportFlashCallVerificationByIdRequestData extends ReportVerificationByIdRequestDataBase { - /** Request body to report a verification started with a flashCall by its ID */ - 'reportFlashCallVerificationByIdRequestBody': FlashCallVerificationReportRequest; -} - -export interface ReportCalloutVerificationByIdRequestData extends ReportVerificationByIdRequestDataBase { - /** Request body to report a verification started with a callout by its ID */ - 'reportCalloutVerificationByIdRequestBody': CalloutVerificationReportRequest; -} - -interface ReportVerificationByIdentityRequestDataBase { - /** For type `number` use a [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537)-compatible phone number. */ - 'endpoint': string; -} - -export interface ReportSmsVerificationByIdentityRequestData extends ReportVerificationByIdentityRequestDataBase { - /** Request body to report a verification started with an SMS by its identity */ - 'reportSmsVerificationByIdentityRequestBody': SmsVerificationReportRequest; -} - -export interface ReportFlashCallVerificationByIdentityRequestData extends ReportVerificationByIdentityRequestDataBase { - /** Request body to report a verification started with a flashCall by its identity */ - 'reportFlashCallVerificationByIdentityRequestBody': FlashCallVerificationReportRequest; -} - -export interface ReportCalloutVerificationByIdentityRequestData extends ReportVerificationByIdentityRequestDataBase { - /** Request body to report a verification started with a callout by its identity */ - 'reportCalloutVerificationByIdentityRequestBody': CalloutVerificationReportRequest; -} - -export interface StartSmsVerificationRequestData { - /** Request body to start a verification with an SMS */ - 'startVerificationWithSmsRequestBody': StartVerificationWithSms; -} - -export interface StartFlashCallVerificationRequestData { - /** Request body to start a verification with a flashCall */ - 'startVerificationWithFlashCallRequestBody': StartVerificationWithFlashCall; -} - -export interface StartCalloutVerificationRequestData { - /** Request body to start a verification with a callout */ - 'startVerificationWithCalloutRequestBody': StartVerificationWithCallout; -} - -export interface StartSeamlessVerificationRequestData { - /** Request body to start a seamless verification */ - 'startSeamlessVerificationRequestBody': StartSeamlessVerification; -} - export class VerificationsApi extends VerificationDomainApi { /** diff --git a/packages/verification/tests/models/v1/helper.test.ts b/packages/verification/tests/models/v1/helper.test.ts index cd051ebe..d3f07987 100644 --- a/packages/verification/tests/models/v1/helper.test.ts +++ b/packages/verification/tests/models/v1/helper.test.ts @@ -1,16 +1,5 @@ import { - ReportCalloutVerificationByIdentityRequestData, - ReportCalloutVerificationByIdRequestData, ReportFlashCallVerificationByIdentityRequestData, - ReportFlashCallVerificationByIdRequestData, - ReportSmsVerificationByIdentityRequestData, - ReportSmsVerificationByIdRequestData, - StartCalloutVerificationRequestData, - StartFlashCallVerificationRequestData, - StartSeamlessVerificationRequestData, - StartSmsVerificationRequestData, - StartVerificationBase, - StartVerificationWithFlashCall, - verificationsHelper, + Verification, } from '../../../src'; const PHONE_NUMBER = '+46700000000'; @@ -20,14 +9,14 @@ const VERIFICATION_ID = 'a_verification_id'; const VERIFICATION_CODE = '0000'; const VERIFICATION_CLI = '+46000000000'; -const identity: StartVerificationBase = { +const identity: Verification.StartVerificationBase = { identity: { type: 'number', endpoint: PHONE_NUMBER, }, }; -const identityWithReference: StartVerificationBase = { +const identityWithReference: Verification.StartVerificationBase = { identity: { type: 'number', endpoint: PHONE_NUMBER, @@ -35,7 +24,7 @@ const identityWithReference: StartVerificationBase = { reference: REFERENCE, }; -const identityWithFlashCall: StartVerificationWithFlashCall = { +const identityWithFlashCall: Verification.StartVerificationWithFlashCall = { identity: { type: 'number', endpoint: PHONE_NUMBER, @@ -47,66 +36,66 @@ const identityWithFlashCall: StartVerificationWithFlashCall = { describe('Verification models helper', () => { - describe('Verifications helper', () => { + describe('Start verification helper', () => { it('should build a startSms request', () => { - const buildRequest = verificationsHelper.buildStartSmsVerificationRequest(PHONE_NUMBER); - const startRequest: StartSmsVerificationRequestData = { + const buildRequest = Verification.startVerificationHelper.buildSmsRequest(PHONE_NUMBER); + const startRequest: Verification.StartSmsVerificationRequestData = { startVerificationWithSmsRequestBody: identity, }; expect(buildRequest).toEqual(startRequest); }); it('should build a startSms request with a reference', () => { - const buildRequest = verificationsHelper.buildStartSmsVerificationRequest(PHONE_NUMBER, REFERENCE); - const startRequest: StartSmsVerificationRequestData = { + const buildRequest = Verification.startVerificationHelper.buildSmsRequest(PHONE_NUMBER, REFERENCE); + const startRequest: Verification.StartSmsVerificationRequestData = { startVerificationWithSmsRequestBody: identityWithReference, }; expect(buildRequest).toEqual(startRequest); }); it('should build a startCallout request', () => { - const buildRequest = verificationsHelper.buildStartCalloutVerificationRequest(PHONE_NUMBER); - const startRequest: StartCalloutVerificationRequestData = { + const buildRequest = Verification.startVerificationHelper.buildCalloutRequest(PHONE_NUMBER); + const startRequest: Verification.StartCalloutVerificationRequestData = { startVerificationWithCalloutRequestBody: identity, }; expect(buildRequest).toEqual(startRequest); }); it('should build a startCallout request with a reference', () => { - const buildRequest = verificationsHelper.buildStartCalloutVerificationRequest(PHONE_NUMBER, REFERENCE); - const startRequest: StartCalloutVerificationRequestData = { + const buildRequest = Verification.startVerificationHelper.buildCalloutRequest(PHONE_NUMBER, REFERENCE); + const startRequest: Verification.StartCalloutVerificationRequestData = { startVerificationWithCalloutRequestBody: identityWithReference, }; expect(buildRequest).toEqual(startRequest); }); it('should build a startSeamless request', () => { - const buildRequest = verificationsHelper.buildStartSeamlessVerificationRequest(PHONE_NUMBER); - const startRequest: StartSeamlessVerificationRequestData = { + const buildRequest = Verification.startVerificationHelper.buildSeamlessRequest(PHONE_NUMBER); + const startRequest: Verification.StartSeamlessVerificationRequestData = { startSeamlessVerificationRequestBody: identity, }; expect(buildRequest).toEqual(startRequest); }); it('should build a startSeamless request with a reference', () => { - const buildRequest = verificationsHelper.buildStartSeamlessVerificationRequest(PHONE_NUMBER, REFERENCE); - const startRequest: StartSeamlessVerificationRequestData = { + const buildRequest = Verification.startVerificationHelper.buildSeamlessRequest(PHONE_NUMBER, REFERENCE); + const startRequest: Verification.StartSeamlessVerificationRequestData = { startSeamlessVerificationRequestBody: identityWithReference, }; expect(buildRequest).toEqual(startRequest); }); it('should build a startFlashCall request', () => { - const buildRequest = verificationsHelper.buildStartFlashCallVerificationRequest(PHONE_NUMBER); - const startRequest: StartFlashCallVerificationRequestData = { + const buildRequest = Verification.startVerificationHelper.buildFlashCallRequest(PHONE_NUMBER); + const startRequest: Verification.StartFlashCallVerificationRequestData = { startVerificationWithFlashCallRequestBody: identity, }; expect(buildRequest).toEqual(startRequest); }); it('should build a startFlashCall request with a reference', () => { - const buildRequest = verificationsHelper.buildStartFlashCallVerificationRequest(PHONE_NUMBER, REFERENCE); - const startRequest: StartFlashCallVerificationRequestData = { + const buildRequest = Verification.startVerificationHelper.buildFlashCallRequest(PHONE_NUMBER, REFERENCE); + const startRequest: Verification.StartFlashCallVerificationRequestData = { startVerificationWithFlashCallRequestBody: identityWithReference, }; expect(buildRequest).toEqual(startRequest); @@ -114,17 +103,21 @@ describe('Verification models helper', () => { it('should build a startFlashCall request with a flashCall option', () => { const buildRequest - = verificationsHelper.buildStartFlashCallVerificationRequest(PHONE_NUMBER, undefined, DIAL_TIMEOUT); - const startRequest: StartFlashCallVerificationRequestData = { + = Verification.startVerificationHelper.buildFlashCallRequest(PHONE_NUMBER, undefined, DIAL_TIMEOUT); + const startRequest: Verification.StartFlashCallVerificationRequestData = { startVerificationWithFlashCallRequestBody: identityWithFlashCall, }; expect(buildRequest).toEqual(startRequest); }); + }); + + describe('Report verification by Id helper', () => { + it('should build a reportSmsVerification by Id', () => { - const builtRequest = verificationsHelper.buildReportSmsVerificationByIdRequest( + const builtRequest = Verification.reportVerificationByIdHelper.buildSmsRequest( VERIFICATION_ID, VERIFICATION_CODE); - const reportRequest: ReportSmsVerificationByIdRequestData = { + const reportRequest: Verification.ReportSmsVerificationByIdRequestData = { id: VERIFICATION_ID, reportSmsVerificationByIdRequestBody: { sms: { code: VERIFICATION_CODE }, @@ -134,9 +127,9 @@ describe('Verification models helper', () => { }); it('should build a reportSmsVerification by Id with code and CLI', () => { - const builtRequest = verificationsHelper.buildReportSmsVerificationByIdRequest( + const builtRequest = Verification.reportVerificationByIdHelper.buildSmsRequest( VERIFICATION_ID, VERIFICATION_CODE, VERIFICATION_CLI); - const reportRequest: ReportSmsVerificationByIdRequestData = { + const reportRequest: Verification.ReportSmsVerificationByIdRequestData = { id: VERIFICATION_ID, reportSmsVerificationByIdRequestBody: { sms: { code: VERIFICATION_CODE, cli: VERIFICATION_CLI }, @@ -146,9 +139,9 @@ describe('Verification models helper', () => { }); it('should build a reportCalloutVerification by Id', () => { - const builtRequest = verificationsHelper.buildReportCalloutVerificationByIdRequest( + const builtRequest = Verification.reportVerificationByIdHelper.buildCalloutRequest( VERIFICATION_ID, VERIFICATION_CODE); - const reportRequest: ReportCalloutVerificationByIdRequestData = { + const reportRequest: Verification.ReportCalloutVerificationByIdRequestData = { id: VERIFICATION_ID, reportCalloutVerificationByIdRequestBody: { callout: { code: VERIFICATION_CODE }, @@ -158,9 +151,9 @@ describe('Verification models helper', () => { }); it('should build a reportFlashCallVerification by Id', () => { - const builtRequest = verificationsHelper.buildReportFlashCallVerificationByIdRequest( + const builtRequest = Verification.reportVerificationByIdHelper.buildFlashCallRequest( VERIFICATION_ID, VERIFICATION_CLI); - const reportRequest: ReportFlashCallVerificationByIdRequestData = { + const reportRequest: Verification.ReportFlashCallVerificationByIdRequestData = { id: VERIFICATION_ID, reportFlashCallVerificationByIdRequestBody: { flashCall: { cli: VERIFICATION_CLI }, @@ -168,11 +161,13 @@ describe('Verification models helper', () => { }; expect(builtRequest).toEqual(reportRequest); }); + }); + describe('Report verification by Identity helper', () => { it('should build a reportSmsVerification by Identity', () => { - const builtRequest = verificationsHelper.buildReportSmsVerificationByIdentityRequest( + const builtRequest = Verification.reportVerificationByIdentityHelper.buildSmsRequest( PHONE_NUMBER, VERIFICATION_CODE); - const reportRequest: ReportSmsVerificationByIdentityRequestData = { + const reportRequest: Verification.ReportSmsVerificationByIdentityRequestData = { endpoint: PHONE_NUMBER, reportSmsVerificationByIdentityRequestBody: { sms: { code: VERIFICATION_CODE }, @@ -182,9 +177,9 @@ describe('Verification models helper', () => { }); it('should build a reportSmsVerification by Identity with code and CLI', () => { - const builtRequest = verificationsHelper.buildReportSmsVerificationByIdentityRequest( + const builtRequest = Verification.reportVerificationByIdentityHelper.buildSmsRequest( PHONE_NUMBER, VERIFICATION_CODE, VERIFICATION_CLI); - const reportRequest: ReportSmsVerificationByIdentityRequestData = { + const reportRequest: Verification.ReportSmsVerificationByIdentityRequestData = { endpoint: PHONE_NUMBER, reportSmsVerificationByIdentityRequestBody: { sms: { code: VERIFICATION_CODE, cli: VERIFICATION_CLI }, @@ -194,9 +189,9 @@ describe('Verification models helper', () => { }); it('should build a reportCalloutVerification by Identity', () => { - const builtRequest = verificationsHelper.buildReportCalloutVerificationByIdentityRequest( + const builtRequest = Verification.reportVerificationByIdentityHelper.buildCalloutRequest( PHONE_NUMBER, VERIFICATION_CODE); - const reportRequest: ReportCalloutVerificationByIdentityRequestData = { + const reportRequest: Verification.ReportCalloutVerificationByIdentityRequestData = { endpoint: PHONE_NUMBER, reportCalloutVerificationByIdentityRequestBody: { callout: { code: VERIFICATION_CODE }, @@ -206,9 +201,9 @@ describe('Verification models helper', () => { }); it('should build a reportFlashCallVerification by Identity', () => { - const builtRequest = verificationsHelper.buildReportFlashCallVerificationByIdentityRequest( + const builtRequest = Verification.reportVerificationByIdentityHelper.buildFlashCallRequest( PHONE_NUMBER, VERIFICATION_CLI); - const reportRequest: ReportFlashCallVerificationByIdentityRequestData = { + const reportRequest: Verification.ReportFlashCallVerificationByIdentityRequestData = { endpoint: PHONE_NUMBER, reportFlashCallVerificationByIdentityRequestBody: { flashCall: { cli: VERIFICATION_CLI }, diff --git a/packages/verification/tests/rest/v1/verification-status/verification-status-api.test.ts b/packages/verification/tests/rest/v1/verification-status/verification-status-api.test.ts index 03806aaf..d8593da8 100644 --- a/packages/verification/tests/rest/v1/verification-status/verification-status-api.test.ts +++ b/packages/verification/tests/rest/v1/verification-status/verification-status-api.test.ts @@ -1,9 +1,8 @@ import { ApiClientOptions, SigningRequest } from '@sinch/sdk-client'; import { - VerificationReportResponse, + Verification, VerificationStatusApi, - VerificationStatusApiFixture, VerificationStatusByIdentityRequestData, - VerificationStatusByIdRequestData, VerificationStatusByReferenceRequestData, + VerificationStatusApiFixture, } from '../../../../src'; describe('VerificationStatusApi', () => { @@ -23,10 +22,10 @@ describe('VerificationStatusApi', () => { describe ('verificationStatusById', () => { it('should make a GET request to query the verification result by sending the verification ID', async () => { // Given - const requestData: VerificationStatusByIdRequestData = { + const requestData: Verification.VerificationStatusByIdRequestData = { id: '', }; - const expectedResponse: VerificationReportResponse = { + const expectedResponse: Verification.VerificationReportResponse = { id: '018bec3e-6913-d36c-5102-ebda3fd6d30f', method: 'sms', status: 'SUCCESSFUL', @@ -58,11 +57,11 @@ describe('VerificationStatusApi', () => { describe ('verificationStatusByIdentity', () => { it('should make a GET request to query the verification result by sending the verification Identity', async () => { // Given - const requestData: VerificationStatusByIdentityRequestData = { + const requestData: Verification.VerificationStatusByIdentityRequestData = { endpoint: '+33444555666', method: 'callout', }; - const expectedResponse: VerificationReportResponse = { + const expectedResponse: Verification.VerificationReportResponse = { id: '018bec2b-d123-b7b3-833e-4b177e3420df', method: 'callout', status: 'FAIL', @@ -84,10 +83,10 @@ describe('VerificationStatusApi', () => { describe ('verificationStatusByReference', () => { it('should make a GET request to query the verification result by sending the verification reference', async () => { // Given - const requestData: VerificationStatusByReferenceRequestData = { + const requestData: Verification.VerificationStatusByReferenceRequestData = { reference: 'reference', }; - const expectedResponse: VerificationReportResponse = { + const expectedResponse: Verification.VerificationReportResponse = { id: '018beea3-a942-0094-4a3a-d6b2f2c65057', reference: 'reference', method: 'flashcall', diff --git a/packages/verification/tests/rest/v1/verifications/verifications-api.test.ts b/packages/verification/tests/rest/v1/verifications/verifications-api.test.ts index cde10d52..1f8ba997 100644 --- a/packages/verification/tests/rest/v1/verifications/verifications-api.test.ts +++ b/packages/verification/tests/rest/v1/verifications/verifications-api.test.ts @@ -1,19 +1,11 @@ import { ApiClientOptions, SigningRequest } from '@sinch/sdk-client'; import { - StartCalloutVerificationResponse, - CalloutVerificationReportResponse, - StartSeamlessVerificationResponse, - StartFlashCallVerificationResponse, - FlashCallVerificationReportResponse, - LinksObject, - StartSmsVerificationResponse, - SMSVerificationReportResponse, + Verification, VerificationsApi, VerificationsApiFixture, - verificationsHelper, } from '../../../../src'; -const _links: LinksObject[] = [ +const _links: Verification.LinksObject[] = [ { rel: 'status', href: 'https://dc-euc1-std.verification.api.sinch.com/verification/v1/verifications/id/some_verification_id', @@ -43,8 +35,8 @@ describe('VerificationsApi', () => { describe ('startVerification', () => { it('should make a POST request to start a verification with an SMS', async () => { // Given - const requestData = verificationsHelper.buildStartSmsVerificationRequest('+46700000000'); - const expectedResponse: StartSmsVerificationResponse = { + const requestData = Verification.startVerificationHelper.buildSmsRequest('+46700000000'); + const expectedResponse: Verification.StartSmsVerificationResponse = { id: 'some_verification_id', method: 'sms', sms: { @@ -66,8 +58,8 @@ describe('VerificationsApi', () => { it('should make a POST request to start a verification with a FlashCall', async () => { // Given - const requestData = verificationsHelper.buildStartFlashCallVerificationRequest('+46700000000', undefined, 30); - const expectedResponse: StartFlashCallVerificationResponse = { + const requestData = Verification.startVerificationHelper.buildFlashCallRequest('+46700000000', undefined, 30); + const expectedResponse: Verification.StartFlashCallVerificationResponse = { id: 'some_verification_id', method: 'flashCall', flashCall: { @@ -91,8 +83,8 @@ describe('VerificationsApi', () => { it('should make a POST request to start a verification with a Callout', async () => { // Given - const requestData = verificationsHelper.buildStartCalloutVerificationRequest('+46700000000'); - const expectedResponse: StartCalloutVerificationResponse = { + const requestData = Verification.startVerificationHelper.buildCalloutRequest('+46700000000'); + const expectedResponse: Verification.StartCalloutVerificationResponse = { id: 'some_verification_id', method: 'callout', _links, @@ -110,8 +102,8 @@ describe('VerificationsApi', () => { it('should make a POST request to start a data verification (seamless)', async () => { // Given - const requestData = verificationsHelper.buildStartSeamlessVerificationRequest('+46700000000'); - const expectedResponse: StartSeamlessVerificationResponse = { + const requestData = Verification.startVerificationHelper.buildSeamlessRequest('+46700000000'); + const expectedResponse: Verification.StartSeamlessVerificationResponse = { id: 'some_verification_id', method: 'seamless', seamless: { @@ -135,10 +127,10 @@ describe('VerificationsApi', () => { it('should make a PUT request to report the verification code (OTP) received by SMS to verify it,' + 'using the verification ID of the verification request', async () => { // Given - const requestData = verificationsHelper.buildReportSmsVerificationByIdRequest( + const requestData = Verification.reportVerificationByIdHelper.buildSmsRequest( 'some_verification_id', '0000'); - const expectedResponse: SMSVerificationReportResponse = { + const expectedResponse: Verification.SMSVerificationReportResponse = { id: 'some_verification_id', method: 'sms', status: 'SUCCESSFUL', @@ -157,10 +149,10 @@ describe('VerificationsApi', () => { it('should make a PUT request to report the CLI received by FlashCall to verify it,' + 'using the verification ID of the verification request', async () => { // Given - const requestData = verificationsHelper.buildReportFlashCallVerificationByIdRequest( + const requestData = Verification.reportVerificationByIdHelper.buildFlashCallRequest( 'some_verification_id', '+46000000000'); - const expectedResponse: FlashCallVerificationReportResponse = { + const expectedResponse: Verification.FlashCallVerificationReportResponse = { id: 'some_verification_id', method: 'flashcall', status: 'SUCCESSFUL', @@ -190,10 +182,10 @@ describe('VerificationsApi', () => { it('should make a PUT request to report the verification code (OTP) received by a phone call to verify it,' + 'using the verification ID of the verification request', async () => { // Given - const requestData = verificationsHelper.buildReportCalloutVerificationByIdRequest( + const requestData = Verification.reportVerificationByIdHelper.buildCalloutRequest( 'some_verification_id', '0000'); - const expectedResponse: CalloutVerificationReportResponse = { + const expectedResponse: Verification.CalloutVerificationReportResponse = { id: 'some_verification_id', method: 'callout', status: 'SUCCESSFUL', @@ -215,10 +207,10 @@ describe('VerificationsApi', () => { it('should make a PUT request to report the verification code (OTP) received by SMS to verify it,' + 'using the identity of the user', async () => { // Given - const requestData = verificationsHelper.buildReportSmsVerificationByIdentityRequest( + const requestData = Verification.reportVerificationByIdentityHelper.buildSmsRequest( '+33444555666', '0000'); - const expectedResponse: SMSVerificationReportResponse = { + const expectedResponse: Verification.SMSVerificationReportResponse = { id: '018beea3-a942-0094-4a3a-d6b2f2c65057', method: 'sms', status: 'FAIL', @@ -245,11 +237,11 @@ describe('VerificationsApi', () => { it('should make a PUT request to report the CLI received by FlashCall to verify it,' + 'using the identity of the user', async () => { // Given - const requestData = verificationsHelper.buildReportFlashCallVerificationByIdentityRequest( + const requestData = Verification.reportVerificationByIdentityHelper.buildFlashCallRequest( '+33444555666', '+46000000000', ); - const expectedResponse: FlashCallVerificationReportResponse = { + const expectedResponse: Verification.FlashCallVerificationReportResponse = { id: '018beea3-a942-0094-4a3a-d6b2f2c65057', method: 'flashcall', status: 'FAIL', @@ -281,10 +273,10 @@ describe('VerificationsApi', () => { it('should make a PUT request to report the verification code (OTP) received by a phone call to verify it,' + 'using the identity of the user', async () => { // Given - const requestData = verificationsHelper.buildReportCalloutVerificationByIdentityRequest( + const requestData = Verification.reportVerificationByIdentityHelper.buildCalloutRequest( '+33444555666', '0000'); - const expectedResponse: CalloutVerificationReportResponse = { + const expectedResponse: Verification.CalloutVerificationReportResponse = { id: '018beea3-a942-0094-4a3a-d6b2f2c65057', method: 'callout', status: 'FAIL', diff --git a/packages/voice/README.md b/packages/voice/README.md index 9d8a75a6..ba30d338 100644 --- a/packages/voice/README.md +++ b/packages/voice/README.md @@ -38,11 +38,10 @@ If you are using this SDK as part of the Sinch SDK (`@sinch/sdk-core`) you can a ```typescript import { - TtsCalloutRequestData, - GetCalloutResponseObj, SinchClient, ApplicationCredentials, VoiceService, + Voice, } from '@sinch/sdk-core'; const credentials: ApplicationCredentials = { @@ -55,7 +54,7 @@ const sinch = new SinchClient(credentials); const voiceService: VoiceService = sinch.voice; // Build the request data -const requestData: TtsCalloutRequestData = { +const requestData: Voice.TtsCalloutRequestData = { ttsCalloutRequestBody: { method: 'ttsCallout', ttsCallout: { @@ -71,7 +70,7 @@ const requestData: TtsCalloutRequestData = { }; // Use the 'voice' service registered on the Sinch client -const calloutResponse: GetCalloutResponseObj +const calloutResponse: Voice.GetCalloutResponseObj = await voiceService.callouts.tts(requestData); ``` @@ -84,8 +83,7 @@ import { ApplicationCredentials } from '@sinch/sdk-client'; import { - TtsCalloutRequestData, - GetCalloutResponseObj, + Voice, VoiceService, } from '@sinch/voice'; @@ -98,7 +96,7 @@ const credentials: ApplicationCredentials = { const voiceService = new VoiceService(credentials); // Build the request data -const requestData: TtsCalloutRequestData = { +const requestData: Voice.TtsCalloutRequestData = { ttsCalloutRequestBody: { method: 'ttsCallout', ttsCallout: { @@ -114,7 +112,7 @@ const requestData: TtsCalloutRequestData = { }; // Use the standalone declaration of the 'voice' service -const calloutResponse: GetCalloutResponseObj +const calloutResponse: Voice.GetCalloutResponseObj = await voiceService.callouts.tts(requestData); ``` @@ -124,7 +122,7 @@ All the methods that interact with the Sinch APIs use Promises. You can use `awa ```typescript // Method 1: Wait for the Promise to complete (you need to be in an 'async' method) -let calloutResponse: GetCalloutResponseObj; +let calloutResponse: Voice.GetCalloutResponseObj; try { calloutResponse = await voiceService.callouts.tts(requestData); console.log(`callId = ${calloutResponse.callId}`); diff --git a/packages/voice/src/index.ts b/packages/voice/src/index.ts index bd163908..65e733fc 100644 --- a/packages/voice/src/index.ts +++ b/packages/voice/src/index.ts @@ -1,2 +1,3 @@ -export * from './models'; +export * as Voice from './models'; export * from './rest'; +export * from '@sinch/sdk-client'; diff --git a/packages/voice/src/models/v1/index.ts b/packages/voice/src/models/v1/index.ts index 2b33a55b..bbc8cac5 100644 --- a/packages/voice/src/models/v1/index.ts +++ b/packages/voice/src/models/v1/index.ts @@ -22,6 +22,7 @@ export * from './update-callbacks'; export * from './assign-numbers'; export * from './enums'; export * from './helper'; +export * from './requests'; // Callbacks export * from './mod-callbacks'; // SVAML diff --git a/packages/voice/src/models/v1/requests/applications/applications-request-data.ts b/packages/voice/src/models/v1/requests/applications/applications-request-data.ts new file mode 100644 index 00000000..b7baf674 --- /dev/null +++ b/packages/voice/src/models/v1/requests/applications/applications-request-data.ts @@ -0,0 +1,28 @@ +import { UnassignNumbers } from '../../unassign-numbers'; +import { UpdateCallbacks } from '../../update-callbacks'; +import { AssignNumbers } from '../../assign-numbers'; + +export interface QueryNumberRequestData { + /** The phone number you want to query. */ + 'number': string; +} +export interface GetCallbackURLsRequestData { + /** The unique identifying key of the application. */ + 'applicationkey': string; +} +export interface GetNumbersRequestData { +} +export interface UnassignNumberRequestData { + /** */ + 'unassignNumbersRequestBody'?: UnassignNumbers; +} +export interface UpdateCallbackURLsRequestData { + /** The unique identifying key of the application. */ + 'applicationkey': string; + /** */ + 'updateCallbacksRequestBody'?: UpdateCallbacks; +} +export interface AssignNumbersRequestData { + /** */ + 'assignNumbersRequestBody'?: AssignNumbers; +} diff --git a/packages/voice/src/models/v1/requests/callouts/callouts-request-data.ts b/packages/voice/src/models/v1/requests/callouts/callouts-request-data.ts new file mode 100644 index 00000000..30a64199 --- /dev/null +++ b/packages/voice/src/models/v1/requests/callouts/callouts-request-data.ts @@ -0,0 +1,30 @@ +import { TtsCalloutRequest } from '../../tts-callout-request'; +import { ConferenceCalloutRequest } from '../../conference-callout-request'; +import { CustomCalloutRequest } from '../../custom-callout-request'; + +export interface TtsCalloutRequestData { + 'ttsCalloutRequestBody': { + /** Type of callout. */ + method: 'ttsCallout', + /** @see TtsCalloutRequest */ + ttsCallout: TtsCalloutRequest + } +} + +export interface ConferenceCalloutRequestData { + 'conferenceCalloutRequestBody': { + /** Type of callout. */ + method: 'conferenceCallout', + /** @see ConferenceCalloutRequest */ + conferenceCallout: ConferenceCalloutRequest + } +} + +export interface CustomCalloutRequestData { + 'customCalloutRequestBody': { + /** Type of callout. */ + method: 'customCallout', + /** @see CustomCalloutRequest */ + customCallout: CustomCalloutRequest + } +} diff --git a/packages/voice/src/models/v1/requests/calls/calls-request-data.ts b/packages/voice/src/models/v1/requests/calls/calls-request-data.ts new file mode 100644 index 00000000..aa5ab965 --- /dev/null +++ b/packages/voice/src/models/v1/requests/calls/calls-request-data.ts @@ -0,0 +1,20 @@ +import { SVAMLRequestBody } from '../../svaml-request-body'; + +export interface GetCallResultRequestData { + /** The unique identifier of the call. This value is generated by the system. */ + 'callId': string; +} +export interface ManageWithCallLegRequestData { + /** The unique identifier of the call. This value is generated by the system. */ + 'callId': string; + /** Specifies which part of the call will be managed. This option is used only by the `PlayFiles` and `Say` instructions to indicate which channel the sound will be played on. Valid options are `caller`, `callee` or `both`. If not specified, the default value is `caller`.
The `callLeg` identifier is ignored for calls that are part of a conference and calls initiated using the Callout API. */ + 'callLeg': 'caller' | 'callee' | 'both'; + /** */ + 'manageWithCallLegRequestBody'?: SVAMLRequestBody; +} +export interface UpdateCallRequestData { + /** The unique identifier of the call. This value is generated by the system. */ + 'callId': string; + /** */ + 'updateCallRequestBody'?: SVAMLRequestBody; +} diff --git a/packages/voice/src/models/v1/requests/conferences/conferences-request-data.ts b/packages/voice/src/models/v1/requests/conferences/conferences-request-data.ts new file mode 100644 index 00000000..2cae430c --- /dev/null +++ b/packages/voice/src/models/v1/requests/conferences/conferences-request-data.ts @@ -0,0 +1,24 @@ +import { ManageConferenceParticipantRequest } from '../../manage-conference-participant-request'; + +export interface GetConferenceInfoRequestData { + /** The unique identifier of the conference. The user sets this value. */ + 'conferenceId': string; +} +export interface KickAllRequestData { + /** The unique identifier of the conference. The user sets this value. */ + 'conferenceId': string; +} +export interface KickParticipantRequestData { + /** The unique identifier of the call. This value is generated by the system. */ + 'callId': string; + /** The unique identifier of the conference. The user sets this value. */ + 'conferenceId': string; +} +export interface ManageParticipantRequestData { + /** The unique identifier of the call. This value is generated by the system. */ + 'callId': string; + /** The unique identifier of the conference. The user sets this value. */ + 'conferenceId': string; + /** */ + 'manageParticipantRequestBody'?: ManageConferenceParticipantRequest; +} diff --git a/packages/voice/src/models/v1/requests/index.ts b/packages/voice/src/models/v1/requests/index.ts new file mode 100644 index 00000000..5bc8714c --- /dev/null +++ b/packages/voice/src/models/v1/requests/index.ts @@ -0,0 +1,4 @@ +export * from './applications/applications-request-data'; +export * from './callouts/callouts-request-data'; +export * from './calls/calls-request-data'; +export * from './conferences/conferences-request-data'; diff --git a/packages/voice/src/rest/v1/applications/applications-api.jest.fixture.ts b/packages/voice/src/rest/v1/applications/applications-api.jest.fixture.ts index af982f32..f22ffa54 100644 --- a/packages/voice/src/rest/v1/applications/applications-api.jest.fixture.ts +++ b/packages/voice/src/rest/v1/applications/applications-api.jest.fixture.ts @@ -1,5 +1,15 @@ -import { GetCallbacks, ListNumbersResponse, QueryNumberResponse } from '../../../models'; -import { ApplicationsApi, QueryNumberRequestData, GetCallbackURLsRequestData, GetNumbersRequestData, UnassignNumberRequestData, UpdateCallbackURLsRequestData, AssignNumbersRequestData } from './applications-api'; +import { ApplicationsApi } from './applications-api'; +import { + GetCallbacks, + ListNumbersResponse, + QueryNumberResponse, + QueryNumberRequestData, + GetCallbackURLsRequestData, + GetNumbersRequestData, + UnassignNumberRequestData, + UpdateCallbackURLsRequestData, + AssignNumbersRequestData, +} from '../../../models'; export class ApplicationsApiFixture implements Partial> { diff --git a/packages/voice/src/rest/v1/applications/applications-api.ts b/packages/voice/src/rest/v1/applications/applications-api.ts index 1eb7cea6..f6c7cfda 100644 --- a/packages/voice/src/rest/v1/applications/applications-api.ts +++ b/packages/voice/src/rest/v1/applications/applications-api.ts @@ -1,10 +1,13 @@ import { + AssignNumbersRequestData, GetCallbacks, + GetCallbackURLsRequestData, + GetNumbersRequestData, ListNumbersResponse, + QueryNumberRequestData, QueryNumberResponse, - UnassignNumbers, - UpdateCallbacks, - AssignNumbers, + UnassignNumberRequestData, + UpdateCallbackURLsRequestData, } from '../../../models'; import { RequestBody, @@ -12,31 +15,6 @@ import { } from '@sinch/sdk-client'; import { VoiceDomainApi } from '../voice-domain-api'; -export interface QueryNumberRequestData { - /** The phone number you want to query. */ - 'number': string; -} -export interface GetCallbackURLsRequestData { - /** The unique identifying key of the application. */ - 'applicationkey': string; -} -export interface GetNumbersRequestData { -} -export interface UnassignNumberRequestData { - /** */ - 'unassignNumbersRequestBody'?: UnassignNumbers; -} -export interface UpdateCallbackURLsRequestData { - /** The unique identifying key of the application. */ - 'applicationkey': string; - /** */ - 'updateCallbacksRequestBody'?: UpdateCallbacks; -} -export interface AssignNumbersRequestData { - /** */ - 'assignNumbersRequestBody'?: AssignNumbers; -} - export class ApplicationsApi extends VoiceDomainApi { /** diff --git a/packages/voice/src/rest/v1/callouts/callouts-api.jest.fixture.ts b/packages/voice/src/rest/v1/callouts/callouts-api.jest.fixture.ts index 40990290..8e58a929 100644 --- a/packages/voice/src/rest/v1/callouts/callouts-api.jest.fixture.ts +++ b/packages/voice/src/rest/v1/callouts/callouts-api.jest.fixture.ts @@ -1,10 +1,10 @@ -import { CalloutResponse } from '../../../models'; +import { CalloutsApi } from './callouts-api'; import { - CalloutsApi, + CalloutResponse, ConferenceCalloutRequestData, CustomCalloutRequestData, TtsCalloutRequestData, -} from './callouts-api'; +} from '../../../models'; export class CalloutsApiFixture implements Partial> { diff --git a/packages/voice/src/rest/v1/callouts/callouts-api.ts b/packages/voice/src/rest/v1/callouts/callouts-api.ts index 747e1ad8..831e062f 100644 --- a/packages/voice/src/rest/v1/callouts/callouts-api.ts +++ b/packages/voice/src/rest/v1/callouts/callouts-api.ts @@ -1,8 +1,8 @@ import { - ConferenceCalloutRequest, - CustomCalloutRequest, CalloutResponse, - TtsCalloutRequest, + ConferenceCalloutRequestData, + CustomCalloutRequestData, + TtsCalloutRequestData, } from '../../../models'; import { RequestBody, @@ -10,33 +10,6 @@ import { } from '@sinch/sdk-client'; import { VoiceDomainApi } from '../voice-domain-api'; -export interface TtsCalloutRequestData { - 'ttsCalloutRequestBody': { - /** Type of callout. */ - method: 'ttsCallout', - /** @see TtsCalloutRequest */ - ttsCallout: TtsCalloutRequest - } -} - -export interface ConferenceCalloutRequestData { - 'conferenceCalloutRequestBody': { - /** Type of callout. */ - method: 'conferenceCallout', - /** @see ConferenceCalloutRequest */ - conferenceCallout: ConferenceCalloutRequest - } -} - -export interface CustomCalloutRequestData { - 'customCalloutRequestBody': { - /** Type of callout. */ - method: 'customCallout', - /** @see CustomCalloutRequest */ - customCallout: CustomCalloutRequest - } -} - export class CalloutsApi extends VoiceDomainApi { /** diff --git a/packages/voice/src/rest/v1/calls/calls-api.jest.fixture.ts b/packages/voice/src/rest/v1/calls/calls-api.jest.fixture.ts index b508365b..683ceb5a 100644 --- a/packages/voice/src/rest/v1/calls/calls-api.jest.fixture.ts +++ b/packages/voice/src/rest/v1/calls/calls-api.jest.fixture.ts @@ -1,5 +1,10 @@ -import { GetCallInformation } from '../../../models'; -import { CallsApi, GetCallResultRequestData, ManageWithCallLegRequestData, UpdateCallRequestData } from './calls-api'; +import { CallsApi } from './calls-api'; +import { + GetCallInformation, + GetCallResultRequestData, + ManageWithCallLegRequestData, + UpdateCallRequestData, +} from '../../../models'; export class CallsApiFixture implements Partial> { @@ -16,4 +21,3 @@ export class CallsApiFixture implements Partial> { */ public update: jest.Mock, [UpdateCallRequestData]> = jest.fn(); } - diff --git a/packages/voice/src/rest/v1/calls/calls-api.ts b/packages/voice/src/rest/v1/calls/calls-api.ts index c00e5e1a..031220b0 100644 --- a/packages/voice/src/rest/v1/calls/calls-api.ts +++ b/packages/voice/src/rest/v1/calls/calls-api.ts @@ -1,6 +1,8 @@ import { GetCallInformation, - SVAMLRequestBody, + GetCallResultRequestData, + ManageWithCallLegRequestData, + UpdateCallRequestData, } from '../../../models'; import { RequestBody, @@ -8,25 +10,6 @@ import { } from '@sinch/sdk-client'; import { VoiceDomainApi } from '../voice-domain-api'; -export interface GetCallResultRequestData { - /** The unique identifier of the call. This value is generated by the system. */ - 'callId': string; -} -export interface ManageWithCallLegRequestData { - /** The unique identifier of the call. This value is generated by the system. */ - 'callId': string; - /** Specifies which part of the call will be managed. This option is used only by the `PlayFiles` and `Say` instructions to indicate which channel the sound will be played on. Valid options are `caller`, `callee` or `both`. If not specified, the default value is `caller`.
The `callLeg` identifier is ignored for calls that are part of a conference and calls initiated using the Callout API. */ - 'callLeg': 'caller' | 'callee' | 'both'; - /** */ - 'manageWithCallLegRequestBody'?: SVAMLRequestBody; -} -export interface UpdateCallRequestData { - /** The unique identifier of the call. This value is generated by the system. */ - 'callId': string; - /** */ - 'updateCallRequestBody'?: SVAMLRequestBody; -} - export class CallsApi extends VoiceDomainApi { /** diff --git a/packages/voice/src/rest/v1/conferences/conferences-api.jest.fixture.ts b/packages/voice/src/rest/v1/conferences/conferences-api.jest.fixture.ts index 8c9eded3..9d5836e9 100644 --- a/packages/voice/src/rest/v1/conferences/conferences-api.jest.fixture.ts +++ b/packages/voice/src/rest/v1/conferences/conferences-api.jest.fixture.ts @@ -1,15 +1,13 @@ +import { ConferencesApi } from './conferences-api'; import { CalloutResponse, + ConferenceCalloutRequestData, GetConferenceInfoResponse, -} from '../../../models'; -import { - ConferencesApi, GetConferenceInfoRequestData, KickAllRequestData, KickParticipantRequestData, ManageParticipantRequestData, -} from './conferences-api'; -import { ConferenceCalloutRequestData } from '../callouts'; +} from '../../../models'; export class ConferencesApiFixture implements Partial> { diff --git a/packages/voice/src/rest/v1/conferences/conferences-api.ts b/packages/voice/src/rest/v1/conferences/conferences-api.ts index 09290220..199ece69 100644 --- a/packages/voice/src/rest/v1/conferences/conferences-api.ts +++ b/packages/voice/src/rest/v1/conferences/conferences-api.ts @@ -1,37 +1,18 @@ import { CalloutResponse, + ConferenceCalloutRequestData, + GetConferenceInfoRequestData, GetConferenceInfoResponse, - ManageConferenceParticipantRequest, + KickAllRequestData, + KickParticipantRequestData, + ManageParticipantRequestData, } from '../../../models/'; import { RequestBody, SinchClientParameters, } from '@sinch/sdk-client'; import { VoiceDomainApi } from '../voice-domain-api'; -import { CalloutsApi, ConferenceCalloutRequestData } from '../callouts'; - -export interface GetConferenceInfoRequestData { - /** The unique identifier of the conference. The user sets this value. */ - 'conferenceId': string; -} -export interface KickAllRequestData { - /** The unique identifier of the conference. The user sets this value. */ - 'conferenceId': string; -} -export interface KickParticipantRequestData { - /** The unique identifier of the call. This value is generated by the system. */ - 'callId': string; - /** The unique identifier of the conference. The user sets this value. */ - 'conferenceId': string; -} -export interface ManageParticipantRequestData { - /** The unique identifier of the call. This value is generated by the system. */ - 'callId': string; - /** The unique identifier of the conference. The user sets this value. */ - 'conferenceId': string; - /** */ - 'manageParticipantRequestBody'?: ManageConferenceParticipantRequest; -} +import { CalloutsApi } from '../callouts'; export class ConferencesApi extends VoiceDomainApi { diff --git a/packages/voice/tests/models/v1/helper.test.ts b/packages/voice/tests/models/v1/helper.test.ts index 12cb09c1..5bd0d04c 100644 --- a/packages/voice/tests/models/v1/helper.test.ts +++ b/packages/voice/tests/models/v1/helper.test.ts @@ -1,53 +1,9 @@ -import { - aceActionHelper, - aceInstructionHelper, - AceResponse, - AceSvamletBuilder, - CallHeader, - ConnectConfProps, - ConnectMxpProps, - ConnectPstnProps, - ConnectSipProps, - customCalloutHelper, - iceActionHelper, - iceInstructionHelper, - IceResponse, - IceSvamletBuilder, - ParkProps, - pieActionHelper, - pieInstructionHelper, - PieResponse, - PieSvamletBuilder, - PlayFilesProps, - RunMenuProps, - SayProps, - SendDtmfProps, - SetCookieProps, - StartRecordingOptions, - StartRecordingProps, - SvamlActionConnectConf, - SvamlActionConnectMxp, - SvamlActionConnectPstn, - SvamlActionConnectSip, - SvamlActionContinue, - SvamlActionHangup, - svamlActionHelper, - SvamlActionPark, - SvamlActionRunMenu, - SvamlInstructionAnswer, - svamlInstructionHelper, - SvamlInstructionPlayFiles, - SvamlInstructionSay, - SvamlInstructionSendDtmf, - SvamlInstructionSetCookie, - SvamlInstructionStartRecording, - SvamlInstructionStopRecording, -} from '../../../src'; +import { Voice } from '../../../src'; const CONFERENCE_ID = 'conferenceId'; const NUMBER = '+461234567890'; const CLI = '+460987654321'; -const CALL_HEADERS: CallHeader[] = [ +const CALL_HEADERS: Voice.CallHeader[] = [ { key: 'foo', value: 'bar', @@ -58,7 +14,7 @@ const CALL_HEADERS: CallHeader[] = [ }, ]; -const RECORDING_OPTIONS: StartRecordingOptions = { +const RECORDING_OPTIONS: Voice.StartRecordingOptions = { destinationUrl: 'azure://my-account/test-container/my-recording.mp3', credentials: 'dummyAzureCredentials', format: 'mp3', @@ -73,7 +29,7 @@ describe('Voice models helpers', () => { describe('SVAML Actions helper', () => { it('should build a connectConf action', () => { - const connectConfProps: ConnectConfProps = { + const connectConfProps: Voice.ConnectConfProps = { conferenceId:CONFERENCE_ID, conferenceDtmfOptions: { mode: 'detect', @@ -82,32 +38,32 @@ describe('Voice models helpers', () => { }, moh: 'music1', }; - const expectedResult: SvamlActionConnectConf = { + const expectedResult: Voice.SvamlActionConnectConf = { ...connectConfProps, name: 'connectConf', }; - const builtAction = svamlActionHelper.buildConnectConf(connectConfProps); + const builtAction = Voice.svamlActionHelper.buildConnectConf(connectConfProps); expect(builtAction).toEqual(expectedResult); }); it('should build a connectMxp action', () => { - const connectMxpProps: ConnectMxpProps = { + const connectMxpProps: Voice.ConnectMxpProps = { destination: { type: 'username', endpoint: 'johndoe', }, callHeaders: CALL_HEADERS, }; - const expectedResult: SvamlActionConnectMxp = { + const expectedResult: Voice.SvamlActionConnectMxp = { ...connectMxpProps, name: 'connectMxp', }; - const builtAction = svamlActionHelper.buildConnectMxp(connectMxpProps); + const builtAction = Voice.svamlActionHelper.buildConnectMxp(connectMxpProps); expect(builtAction).toEqual(expectedResult); }); it('should build a connectPstn action', () => { - const connectPstnProps: ConnectPstnProps = { + const connectPstnProps: Voice.ConnectPstnProps = { number: NUMBER, locale: 'en-US', maxDuration: 3000, @@ -120,16 +76,16 @@ describe('Voice models helpers', () => { enabled: true, }, }; - const expectedResult: SvamlActionConnectPstn = { + const expectedResult: Voice.SvamlActionConnectPstn = { ...connectPstnProps, name: 'connectPstn', }; - const builtAction = svamlActionHelper.buildConnectPstn(connectPstnProps); + const builtAction = Voice.svamlActionHelper.buildConnectPstn(connectPstnProps); expect(builtAction).toEqual(expectedResult); }); it('should build a connectSip action', () => { - const connectSipProps: ConnectSipProps = { + const connectSipProps: Voice.ConnectSipProps = { destination: { type: 'Sip', endpoint: '46708000000@sip.foo.com', @@ -141,47 +97,47 @@ describe('Voice models helpers', () => { callHeaders: CALL_HEADERS, moh: 'music2', }; - const expectedResult: SvamlActionConnectSip = { + const expectedResult: Voice.SvamlActionConnectSip = { ...connectSipProps, name: 'connectSip', }; - const builtAction = svamlActionHelper.buildConnectSip(connectSipProps); + const builtAction = Voice.svamlActionHelper.buildConnectSip(connectSipProps); expect(builtAction).toEqual(expectedResult); }); it('should build a continue action', () => { - const expectedResult: SvamlActionContinue = { + const expectedResult: Voice.SvamlActionContinue = { name: 'continue', }; - const builtAction = svamlActionHelper.buildContinue(); + const builtAction = Voice.svamlActionHelper.buildContinue(); expect(builtAction).toEqual(expectedResult); }); it('should build a hangup action', () => { - const expectedResult: SvamlActionHangup = { + const expectedResult: Voice.SvamlActionHangup = { name: 'hangup', }; - const builtAction = svamlActionHelper.buildHangup(); + const builtAction = Voice.svamlActionHelper.buildHangup(); expect(builtAction).toEqual(expectedResult); }); it('should build a park action', () => { - const parkProps: ParkProps = { + const parkProps: Voice.ParkProps = { locale: 'en-US', introPrompt: '#tts[Welcome]', holdPrompt: '#tts[Thank you for your patience, your call is very important to us.]', maxDuration: 180, }; - const expectedResult: SvamlActionPark = { + const expectedResult: Voice.SvamlActionPark = { ...parkProps, name: 'park', }; - const builtAction = svamlActionHelper.buildPark(parkProps); + const builtAction = Voice.svamlActionHelper.buildPark(parkProps); expect(builtAction).toEqual(expectedResult); }); it('should build a runMenu action', () => { - const runMenuProps: RunMenuProps = { + const runMenuProps: Voice.RunMenuProps = { barge: true, locale: 'en-US', enableVoice: true, @@ -218,21 +174,21 @@ describe('Voice models helpers', () => { }, ], }; - const expectedResult: SvamlActionRunMenu = { + const expectedResult: Voice.SvamlActionRunMenu = { ...runMenuProps, name: 'runMenu', }; - const builtAction = svamlActionHelper.buildRunMenu(runMenuProps); + const builtAction = Voice.svamlActionHelper.buildRunMenu(runMenuProps); expect(builtAction).toEqual(expectedResult); }); }); describe('SVAML Instructions helper', () => { it('should build an answer instruction', () => { - const expectedResult: SvamlInstructionAnswer = { + const expectedResult: Voice.SvamlInstructionAnswer = { name: 'answer', }; - const builtInstruction = svamlInstructionHelper.buildAnswer(); + const builtInstruction = Voice.svamlInstructionHelper.buildAnswer(); expect(builtInstruction).toEqual(expectedResult); }); @@ -240,93 +196,93 @@ describe('Voice models helpers', () => { const ids = [ '[Welcome]', ]; - const playFilesProps: PlayFilesProps = { + const playFilesProps: Voice.PlayFilesProps = { locale: 'Enrique', ids, }; - const expectedResult: SvamlInstructionPlayFiles = { + const expectedResult: Voice.SvamlInstructionPlayFiles = { ...playFilesProps, name: 'playFiles', }; - const builtInstruction = svamlInstructionHelper.buildPlayFiles(ids, 'Enrique'); + const builtInstruction = Voice.svamlInstructionHelper.buildPlayFiles(ids, 'Enrique'); expect(builtInstruction).toEqual(expectedResult); }); it('should build a say instruction', () => { const text = 'Hello, this is a text-to-speech message.'; - const sayProps: SayProps = { + const sayProps: Voice.SayProps = { text, locale: 'Ivy', }; - const expectedResult: SvamlInstructionSay = { + const expectedResult: Voice.SvamlInstructionSay = { ...sayProps, name: 'say', }; - const builtInstruction = svamlInstructionHelper.buildSay(text, 'Ivy'); + const builtInstruction = Voice.svamlInstructionHelper.buildSay(text, 'Ivy'); expect(builtInstruction).toEqual(expectedResult); }); it('should build a sendDtmf instruction', () => { - const sendDtmfProps: SendDtmfProps = { + const sendDtmfProps: Voice.SendDtmfProps = { value: '1234#', }; - const expectedResult: SvamlInstructionSendDtmf = { + const expectedResult: Voice.SvamlInstructionSendDtmf = { ...sendDtmfProps, name: 'sendDtmf', }; - const builtInstruction = svamlInstructionHelper.buildSendDtmf('1234#'); + const builtInstruction = Voice.svamlInstructionHelper.buildSendDtmf('1234#'); expect(builtInstruction).toEqual(expectedResult); }); it('should build a setCookie instruction', () => { - const setCookieProps: SetCookieProps = { + const setCookieProps: Voice.SetCookieProps = { key: 'cookie-name', value: 'cookie-value', }; - const expectedResult: SvamlInstructionSetCookie = { + const expectedResult: Voice.SvamlInstructionSetCookie = { ...setCookieProps, name: 'setCookie', }; - const builtInstruction = svamlInstructionHelper.buildSetCookie('cookie-name', 'cookie-value'); + const builtInstruction = Voice.svamlInstructionHelper.buildSetCookie('cookie-name', 'cookie-value'); expect(builtInstruction).toEqual(expectedResult); }); it('should build a startRecording instruction', () => { - const startRecordingProps: StartRecordingProps = { + const startRecordingProps: Voice.StartRecordingProps = { options: { ...RECORDING_OPTIONS, }, }; - const expectedResult: SvamlInstructionStartRecording = { + const expectedResult: Voice.SvamlInstructionStartRecording = { ...startRecordingProps, name: 'startRecording', }; - const builtInstruction = svamlInstructionHelper.buildStartRecording(RECORDING_OPTIONS); + const builtInstruction = Voice.svamlInstructionHelper.buildStartRecording(RECORDING_OPTIONS); expect(builtInstruction).toEqual(expectedResult); }); it('should build a stopRecording instruction', () => { - const expectedResult: SvamlInstructionStopRecording = { + const expectedResult: Voice.SvamlInstructionStopRecording = { name: 'stopRecording', }; - const builtInstruction = svamlInstructionHelper.buildStopRecording(); + const builtInstruction = Voice.svamlInstructionHelper.buildStopRecording(); expect(builtInstruction).toEqual(expectedResult); }); }); describe('ACE response builder', () => { it('should build an ACE response', () => { - const aceResponse = new AceSvamletBuilder() - .setAction(aceActionHelper.hangup()) - .addInstruction(aceInstructionHelper.setCookie('cookie-name', 'cookie-value')) - .addInstruction(aceInstructionHelper.startRecording(RECORDING_OPTIONS)) - .addInstruction(aceInstructionHelper.say('Hello from Sinch.', 'en-US')) - .addInstruction(aceInstructionHelper.playFiles([ + const aceResponse = new Voice.AceSvamletBuilder() + .setAction(Voice.aceActionHelper.hangup()) + .addInstruction(Voice.aceInstructionHelper.setCookie('cookie-name', 'cookie-value')) + .addInstruction(Voice.aceInstructionHelper.startRecording(RECORDING_OPTIONS)) + .addInstruction(Voice.aceInstructionHelper.say('Hello from Sinch.', 'en-US')) + .addInstruction(Voice.aceInstructionHelper.playFiles([ '#tts[Hello from Sinch]', '#ssml[Have a great day!]', ], 'en-US')) .build(); - const expectedResult: AceResponse = { + const expectedResult: Voice.AceResponse = { action: { name: 'hangup', }, @@ -360,16 +316,16 @@ describe('Voice models helpers', () => { describe('ICE response builder', () => { it('should build an ICE response', () => { - const parkProps: ParkProps = { + const parkProps: Voice.ParkProps = { introPrompt: '#tts[Welcome]', holdPrompt: '#tts[Thank you for your patience, your call is very important to us.]', maxDuration: 180, }; - const iceResponse = new IceSvamletBuilder() - .setAction(iceActionHelper.park(parkProps)) - .addInstruction(iceInstructionHelper.setCookie('sinch-app', 'app-id-value')) + const iceResponse = new Voice.IceSvamletBuilder() + .setAction(Voice.iceActionHelper.park(parkProps)) + .addInstruction(Voice.iceInstructionHelper.setCookie('sinch-app', 'app-id-value')) .build(); - const expectedResult: IceResponse = { + const expectedResult: Voice.IceResponse = { action: { name: 'park', ...parkProps, @@ -388,12 +344,12 @@ describe('Voice models helpers', () => { describe('PIE response builder', () => { it('should build a PIE response', () => { - const pieResponse = new PieSvamletBuilder() - .setAction(pieActionHelper.continue()) - .addInstruction(pieInstructionHelper.say('The call may be recorded.', 'en-US')) - .addInstruction(pieInstructionHelper.startRecording(RECORDING_OPTIONS)) + const pieResponse = new Voice.PieSvamletBuilder() + .setAction(Voice.pieActionHelper.continue()) + .addInstruction(Voice.pieInstructionHelper.say('The call may be recorded.', 'en-US')) + .addInstruction(Voice.pieInstructionHelper.startRecording(RECORDING_OPTIONS)) .build(); - const expectedResult: PieResponse = { + const expectedResult: Voice.PieResponse = { action: { name: 'continue', }, @@ -415,10 +371,10 @@ describe('Voice models helpers', () => { describe('Custom callout helper', () => { it('should build a SVAML ICE string with only an action', () => { - const ice = customCalloutHelper.formatIceResponse( - iceActionHelper.park({}), + const ice = Voice.customCalloutHelper.formatIceResponse( + Voice.iceActionHelper.park({}), ); - const expectedResult: IceResponse = { + const expectedResult: Voice.IceResponse = { action: { name: 'park', }, @@ -427,12 +383,12 @@ describe('Voice models helpers', () => { }); it('should build a SVAML ICE string with an action and instructions', () => { - const ice = customCalloutHelper.formatIceResponse( - iceActionHelper.park({}), - iceInstructionHelper.setCookie('cookie-name', 'cookie-value'), - iceInstructionHelper.say('Hello from Sinch.', 'Gwyneth'), + const ice = Voice.customCalloutHelper.formatIceResponse( + Voice.iceActionHelper.park({}), + Voice.iceInstructionHelper.setCookie('cookie-name', 'cookie-value'), + Voice.iceInstructionHelper.say('Hello from Sinch.', 'Gwyneth'), ); - const expectedResult: IceResponse = { + const expectedResult: Voice.IceResponse = { action: { name: 'park', }, @@ -453,10 +409,10 @@ describe('Voice models helpers', () => { }); it('should build a SVAML ACE string with only an action', () => { - const ace = customCalloutHelper.formatAceResponse( - aceActionHelper.continue(), + const ace = Voice.customCalloutHelper.formatAceResponse( + Voice.aceActionHelper.continue(), ); - const expectedResult: AceResponse = { + const expectedResult: Voice.AceResponse = { action: { name: 'continue', }, @@ -465,12 +421,12 @@ describe('Voice models helpers', () => { }); it('should build a SVAML ACE string with an action and instructions', () => { - const ace = customCalloutHelper.formatAceResponse( - aceActionHelper.continue(), - aceInstructionHelper.setCookie('cookie-name', 'cookie-value'), - aceInstructionHelper.say('Hello from Sinch.', 'Geraint'), + const ace = Voice.customCalloutHelper.formatAceResponse( + Voice.aceActionHelper.continue(), + Voice.aceInstructionHelper.setCookie('cookie-name', 'cookie-value'), + Voice.aceInstructionHelper.say('Hello from Sinch.', 'Geraint'), ); - const expectedResult: AceResponse = { + const expectedResult: Voice.AceResponse = { action: { name: 'continue', }, @@ -491,10 +447,10 @@ describe('Voice models helpers', () => { }); it('should build a SVAML PIE string with only an action', () => { - const pie = customCalloutHelper.formatPieResponse( - pieActionHelper.continue(), + const pie = Voice.customCalloutHelper.formatPieResponse( + Voice.pieActionHelper.continue(), ); - const expectedResult: PieResponse = { + const expectedResult: Voice.PieResponse = { action: { name: 'continue', }, @@ -503,12 +459,12 @@ describe('Voice models helpers', () => { }); it('should build a SVAML PIE string with an action and instructions', () => { - const pie = customCalloutHelper.formatPieResponse( - pieActionHelper.continue(), - pieInstructionHelper.say('Goodbye.', 'Raveena'), - pieInstructionHelper.stopRecording(), + const pie = Voice.customCalloutHelper.formatPieResponse( + Voice.pieActionHelper.continue(), + Voice.pieInstructionHelper.say('Goodbye.', 'Raveena'), + Voice.pieInstructionHelper.stopRecording(), ); - const expectedResult: PieResponse = { + const expectedResult: Voice.PieResponse = { action: { name: 'continue', }, diff --git a/packages/voice/tests/rest/v1/applications/applications-api.test.ts b/packages/voice/tests/rest/v1/applications/applications-api.test.ts index c278e14e..a95f9072 100644 --- a/packages/voice/tests/rest/v1/applications/applications-api.test.ts +++ b/packages/voice/tests/rest/v1/applications/applications-api.test.ts @@ -1,15 +1,8 @@ import { ApiClientOptions, SigningRequest } from '@sinch/sdk-client'; import { ApplicationsApi, - ApplicationsApiFixture, AssignNumbersRequestData, - GetCallbacks, - GetCallbackURLsRequestData, - GetNumbersRequestData, - ListNumbersResponse, - QueryNumberResponse, - QueryNumberRequestData, - UnassignNumberRequestData, - UpdateCallbackURLsRequestData, + ApplicationsApiFixture, + Voice, } from '../../../../src'; describe('ApplicationsApi', () => { @@ -28,10 +21,10 @@ describe('ApplicationsApi', () => { describe ('queryNumber', () => { it('should make a GET request to get information about the requested number', async () => { // Given - const requestData: QueryNumberRequestData = { + const requestData: Voice.QueryNumberRequestData = { number: '+14151112223333', }; - const expectedResponse: QueryNumberResponse = { + const expectedResponse: Voice.QueryNumberResponse = { method: 'numberItem', number: { countryId: 'US', @@ -59,10 +52,10 @@ describe('ApplicationsApi', () => { describe ('getCallbackURLs', () => { it('should make a GET request to return any callback URLs configured for the specified application', async () => { // Given - const requestData: GetCallbackURLsRequestData = { + const requestData: Voice.GetCallbackURLsRequestData = { applicationkey: 'APPLICATION_KEY', }; - const expectedResponse: GetCallbacks = { + const expectedResponse: Voice.GetCallbacks = { url:{ primary: 'primaryCallBackUrl', fallback: 'fallbackCallbackUrl', @@ -83,8 +76,8 @@ describe('ApplicationsApi', () => { describe ('getNumbers', () => { it('should make a GET request to get information about your numbers', async () => { // Given - const requestData: GetNumbersRequestData = {}; - const expectedResponse: ListNumbersResponse = { + const requestData: Voice.GetNumbersRequestData = {}; + const expectedResponse: Voice.ListNumbersResponse = { numbers: [ { number: '33444555666', @@ -108,7 +101,7 @@ describe('ApplicationsApi', () => { describe ('unassignNumber', () => { it('should make a DELETE request to un-assign a number from an application', async () => { // Given - const requestData: UnassignNumberRequestData = { + const requestData: Voice.UnassignNumberRequestData = { unassignNumbersRequestBody: { number: '+33444555666', applicationkey: 'APPLICATION_KEY', @@ -130,7 +123,7 @@ describe('ApplicationsApi', () => { describe ('updateCallbackURLs', () => { it('should make a POST request to update the configured callback URL', async () => { // Given - const requestData: UpdateCallbackURLsRequestData = { + const requestData: Voice.UpdateCallbackURLsRequestData = { applicationkey: 'APPLICATION_KEY', updateCallbacksRequestBody: { url: { @@ -155,7 +148,7 @@ describe('ApplicationsApi', () => { describe ('updateNumbers', () => { it('should make a POST request to assign some numbers to an application', async () => { // Given - const requestData: AssignNumbersRequestData = { + const requestData: Voice.AssignNumbersRequestData = { assignNumbersRequestBody: { numbers: [ '+33444555666', diff --git a/packages/voice/tests/rest/v1/callbacks/callbacks-webhook.test.ts b/packages/voice/tests/rest/v1/callbacks/callbacks-webhook.test.ts index d6811a8c..739cfb92 100644 --- a/packages/voice/tests/rest/v1/callbacks/callbacks-webhook.test.ts +++ b/packages/voice/tests/rest/v1/callbacks/callbacks-webhook.test.ts @@ -1,4 +1,4 @@ -import { AceRequest, DiceRequest, IceRequest, PieRequest, VoiceCallbackWebhooks } from '../../../../src'; +import { Voice, VoiceCallbackWebhooks } from '../../../../src'; import { SinchClientParameters } from '@sinch/sdk-client'; describe('Voice Callback Webhook', () => { @@ -65,7 +65,7 @@ describe('Voice Callback Webhook', () => { }; const parsedResultFunction = () => callbackWebhooks.parseEvent(payload); expect(parsedResultFunction).not.toThrow(); - const parsedResult = parsedResultFunction() as IceRequest; + const parsedResult = parsedResultFunction() as Voice.IceRequest; expect(parsedResult.timestamp).toStrictEqual(DATE_AS_DATE); }); @@ -79,7 +79,7 @@ describe('Voice Callback Webhook', () => { }; const parsedResultFunction = () => callbackWebhooks.parseEvent(payload); expect(parsedResultFunction).not.toThrow(); - const parsedResult = parsedResultFunction() as AceRequest; + const parsedResult = parsedResultFunction() as Voice.AceRequest; expect(parsedResult.timestamp).toStrictEqual(DATE_AS_DATE); }); @@ -109,7 +109,7 @@ describe('Voice Callback Webhook', () => { }; const parsedResultFunction = () => callbackWebhooks.parseEvent(payload); expect(parsedResultFunction).not.toThrow(); - const parsedResult = parsedResultFunction() as DiceRequest; + const parsedResult = parsedResultFunction() as Voice.DiceRequest; expect(parsedResult.timestamp).toStrictEqual(DATE_AS_DATE); }); @@ -130,7 +130,7 @@ describe('Voice Callback Webhook', () => { }; const parsedResultFunction = () => callbackWebhooks.parseEvent(payload); expect(parsedResultFunction).not.toThrow(); - const parsedResult = parsedResultFunction() as PieRequest; + const parsedResult = parsedResultFunction() as Voice.PieRequest; expect(parsedResult.timestamp).toStrictEqual(DATE_AS_DATE); }); diff --git a/packages/voice/tests/rest/v1/callouts/callouts-api.test.ts b/packages/voice/tests/rest/v1/callouts/callouts-api.test.ts index 744810ec..4c4de398 100644 --- a/packages/voice/tests/rest/v1/callouts/callouts-api.test.ts +++ b/packages/voice/tests/rest/v1/callouts/callouts-api.test.ts @@ -1,9 +1,8 @@ import { ApiClientOptions, SigningRequest } from '@sinch/sdk-client'; import { CalloutsApi, - CalloutsApiFixture, ConferenceCalloutRequestData, CustomCalloutRequestData, - CalloutResponse, - TtsCalloutRequestData, + CalloutsApiFixture, + Voice, } from '../../../../src'; describe('CalloutsApi', () => { @@ -22,7 +21,7 @@ describe('CalloutsApi', () => { describe ('TTS callouts', () => { it('should make a POST request to make a TTS callout to a phone number', async () => { // Given - const requestData: TtsCalloutRequestData = { + const requestData: Voice.TtsCalloutRequestData = { ttsCalloutRequestBody: { method: 'ttsCallout', ttsCallout: { @@ -36,7 +35,7 @@ describe('CalloutsApi', () => { }, }, }; - const expectedResponse: CalloutResponse = { + const expectedResponse: Voice.CalloutResponse = { callId: 'callId', }; @@ -54,7 +53,7 @@ describe('CalloutsApi', () => { describe ('Conference callouts', () => { it('should make a POST request to make a conference callout to a phone number', async () => { // Given - const requestData: ConferenceCalloutRequestData = { + const requestData: Voice.ConferenceCalloutRequestData = { conferenceCalloutRequestBody: { method: 'conferenceCallout', conferenceCallout: { @@ -68,7 +67,7 @@ describe('CalloutsApi', () => { }, }, }; - const expectedResponse: CalloutResponse = { + const expectedResponse: Voice.CalloutResponse = { callId: 'callId', }; @@ -86,7 +85,7 @@ describe('CalloutsApi', () => { describe ('Custom callouts', () => { it('should make a POST request to make a Custom callout to a phone number', async () => { // Given - const requestData: CustomCalloutRequestData = { + const requestData: Voice.CustomCalloutRequestData = { customCalloutRequestBody: { method: 'customCallout', customCallout: { @@ -98,7 +97,7 @@ describe('CalloutsApi', () => { }, }, }; - const expectedResponse: CalloutResponse = { + const expectedResponse: Voice.CalloutResponse = { callId: 'callId', }; diff --git a/packages/voice/tests/rest/v1/calls/calls-api.test.ts b/packages/voice/tests/rest/v1/calls/calls-api.test.ts index e47dd5dc..1bc6412c 100644 --- a/packages/voice/tests/rest/v1/calls/calls-api.test.ts +++ b/packages/voice/tests/rest/v1/calls/calls-api.test.ts @@ -2,15 +2,7 @@ import { ApiClientOptions, SigningRequest } from '@sinch/sdk-client'; import { CallsApi, CallsApiFixture, - GetCallInformation, - GetCallResultRequestData, - ManageWithCallLegRequestData, - SvamlAction, - SvamlActionHangup, - SvamlInstruction, - SvamlInstructionSay, - SvamlInstructionSendDtmf, - UpdateCallRequestData, + Voice, } from '../../../../src'; describe('CallsApi', () => { @@ -29,10 +21,10 @@ describe('CallsApi', () => { describe ('getCallResult', () => { it('should make a GET request to retrieve information about a call', async () => { // Given - const requestData: GetCallResultRequestData = { + const requestData: Voice.GetCallResultRequestData = { callId: 'callId', }; - const expectedResponse: GetCallInformation = { + const expectedResponse: Voice.GetCallInformation = { callId: 'callId', to: { type: 'Number', @@ -68,15 +60,15 @@ describe('CallsApi', () => { describe ('manageCallWithCallLeg', () => { it('should make a PATCH request to manage calls', async () => { // Given - const instruction: SvamlInstruction = { + const instruction: Voice.SvamlInstruction = { name: 'say', text: 'Hello, the call is over, hanging up now. Goodbye', locale: 'en-US', - } as SvamlInstructionSay; - const action: SvamlAction = { + } as Voice.SvamlInstructionSay; + const action: Voice.SvamlAction = { name: 'hangup', - } as SvamlActionHangup; - const requestData: ManageWithCallLegRequestData = { + } as Voice.SvamlActionHangup; + const requestData: Voice.ManageWithCallLegRequestData = { callId: 'callId', callLeg: 'caller', manageWithCallLegRequestBody: { @@ -101,14 +93,14 @@ describe('CallsApi', () => { describe ('updateCall', () => { it('should make a PATCH request to manage a call in progress', async () => { // Given - const instruction: SvamlInstruction = { + const instruction: Voice.SvamlInstruction = { name: 'sendDtmf', value: '1234#', - } as SvamlInstructionSendDtmf; - const action: SvamlAction = { + } as Voice.SvamlInstructionSendDtmf; + const action: Voice.SvamlAction = { name: 'hangup', - } as SvamlActionHangup; - const requestData: UpdateCallRequestData = { + } as Voice.SvamlActionHangup; + const requestData: Voice.UpdateCallRequestData = { callId: 'callId', updateCallRequestBody: { instructions: [ diff --git a/packages/voice/tests/rest/v1/conferences/conferences-api.test.ts b/packages/voice/tests/rest/v1/conferences/conferences-api.test.ts index 3148db87..980108d7 100644 --- a/packages/voice/tests/rest/v1/conferences/conferences-api.test.ts +++ b/packages/voice/tests/rest/v1/conferences/conferences-api.test.ts @@ -2,13 +2,7 @@ import { ApiClientOptions, SigningRequest } from '@sinch/sdk-client'; import { ConferencesApi, ConferencesApiFixture, - GetConferenceInfoResponse, - GetConferenceInfoRequestData, - KickAllRequestData, - KickParticipantRequestData, - ManageParticipantRequestData, - ConferenceCalloutRequestData, - CalloutResponse, + Voice, } from '../../../../src'; @@ -28,10 +22,10 @@ describe('ConferencesApi', () => { describe ('getConferenceInfo', () => { it('should make a GET request to get information about a conference', async () => { // Given - const requestData: GetConferenceInfoRequestData = { + const requestData: Voice.GetConferenceInfoRequestData = { conferenceId: 'conferenceId', }; - const expectedResponse: GetConferenceInfoResponse = { + const expectedResponse: Voice.GetConferenceInfoResponse = { participants: [ { cli: '+46708168731', @@ -64,7 +58,7 @@ describe('ConferencesApi', () => { describe ('Conference callouts', () => { it('should make a POST request to make a conference callout to a phone number', async () => { // Given - const requestData: ConferenceCalloutRequestData = { + const requestData: Voice.ConferenceCalloutRequestData = { conferenceCalloutRequestBody: { method: 'conferenceCallout', conferenceCallout: { @@ -78,7 +72,7 @@ describe('ConferencesApi', () => { }, }, }; - const expectedResponse: CalloutResponse = { + const expectedResponse: Voice.CalloutResponse = { callId: 'callId', }; @@ -96,7 +90,7 @@ describe('ConferencesApi', () => { describe ('kickConferenceAll', () => { it('should make a DELETE request to remove all participants from a conference', async () => { // Given - const requestData: KickAllRequestData = { + const requestData: Voice.KickAllRequestData = { conferenceId: 'conferenceId', }; @@ -114,7 +108,7 @@ describe('ConferencesApi', () => { describe ('kickConferenceParticipant', () => { it('should make a DELETE request to remove the specified participant from a conference', async () => { // Given - const requestData: KickParticipantRequestData = { + const requestData: Voice.KickParticipantRequestData = { conferenceId: 'conferenceId', callId: 'callId', }; @@ -133,7 +127,7 @@ describe('ConferencesApi', () => { describe ('manageConferenceParticipant', () => { it('should make a PATCH request to manage a conference participant', async () => { // Given - const requestData: ManageParticipantRequestData = { + const requestData: Voice.ManageParticipantRequestData = { callId: 'callId', conferenceId: 'conferenceId', manageParticipantRequestBody: {