From 8a4a72a5e3ac3d120a5a6efcff6a320090ef0ba9 Mon Sep 17 00:00:00 2001 From: Antoine Sein Date: Fri, 10 May 2024 16:25:14 +0200 Subject: [PATCH] DEVEXP-422: Update voiceConfiguration --- .../src/numbers/active/list.ts | 4 +-- .../scheduled-voice-provisioning.ts | 15 ++++---- .../voice-configuration.ts | 15 ++++---- .../active-number/active-number-api.test.ts | 34 +++++++++++++++---- 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/examples/simple-examples/src/numbers/active/list.ts b/examples/simple-examples/src/numbers/active/list.ts index 126122bb..4291d7b2 100644 --- a/examples/simple-examples/src/numbers/active/list.ts +++ b/examples/simple-examples/src/numbers/active/list.ts @@ -8,7 +8,7 @@ const populateActiveNumbersList = ( ) => { activeNumbersPage.data?.map((activeNumber: Numbers.ActiveNumber) => { activeNumbersList.push(activeNumber); - phoneNumbersList.push(activeNumber.phoneNumber); + phoneNumbersList.push(`${activeNumber.phoneNumber} - Voice Configuration: ${activeNumber.voiceConfiguration?.type}`); }); }; @@ -61,7 +61,7 @@ const populateActiveNumbersList = ( // --------------------------------------------------------------------- for await (const activeNumber of numbersService.activeNumber.list(requestData)) { if (printFormat === 'pretty') { - console.log(activeNumber.phoneNumber); + console.log(`${activeNumber.phoneNumber} - Voice Configuration: ${activeNumber.voiceConfiguration?.type}`); } else { console.log(activeNumber); } diff --git a/packages/numbers/src/models/v1/scheduled-voice-provisioning/scheduled-voice-provisioning.ts b/packages/numbers/src/models/v1/scheduled-voice-provisioning/scheduled-voice-provisioning.ts index 737e3961..b5b7e5d0 100644 --- a/packages/numbers/src/models/v1/scheduled-voice-provisioning/scheduled-voice-provisioning.ts +++ b/packages/numbers/src/models/v1/scheduled-voice-provisioning/scheduled-voice-provisioning.ts @@ -1,10 +1,3 @@ -/** - * Model: ScheduledVoiceProvisioning - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { ProvisioningStatus } from '../provisioning-status'; /** @@ -16,5 +9,11 @@ export interface ScheduledVoiceProvisioning { /** @see ProvisioningStatus */ status?: ProvisioningStatus; /** Timestamp when the status was last updated. */ - lastUpdatedTime?: string; + lastUpdatedTime?: Date; + /** Type of product the number is associated to. Default is `RTC`. */ + type?: 'RTC' | 'EST' | 'FAX' | string; + /** Reference to the SIP Trunk ID created with the Elastic SIP Trunking API. Not empty when the type is set to `EST`. */ + trunkId?: string; + /** Reference to the Service ID created with the Fax API. Not empty when the type is set to `FAX`. */ + serviceId?: string; } diff --git a/packages/numbers/src/models/v1/voice-configuration/voice-configuration.ts b/packages/numbers/src/models/v1/voice-configuration/voice-configuration.ts index 7e0a6dd6..36db2374 100644 --- a/packages/numbers/src/models/v1/voice-configuration/voice-configuration.ts +++ b/packages/numbers/src/models/v1/voice-configuration/voice-configuration.ts @@ -1,20 +1,19 @@ -/** - * Model: VoiceConfiguration - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { ScheduledVoiceProvisioning } from '../scheduled-voice-provisioning'; /** * The current voice configuration for this number. During scheduled provisioning, the app ID value may be empty in a response if it is still processing or if it has failed. The status of scheduled provisioning will show under a `scheduledVoiceProvisioning` object if it\'s still running. Once processed successfully, the `appId` sent will appear directly under the `voiceConfiguration` object. */ export interface VoiceConfiguration { - /** Your app ID for the Voice API. The `appId` can be found in your Sinch Customer Dashboard under Voice, then apps. */ + /** Your app ID for the Voice API. The `appId` can be found in your Sinch Customer Dashboard under Voice, then apps. */ appId?: string; /** Timestamp when the status was last updated. */ lastUpdatedTime?: Date | null; /** @see ScheduledVoiceProvisioning */ scheduledVoiceProvisioning?: ScheduledVoiceProvisioning | null; + /** Type of product the number is associated to. Default is `RTC`. */ + type?: 'RTC' | 'EST' | 'FAX' | string; + /** Reference to the SIP Trunk ID created with the Elastic SIP Trunking API. Not empty when the type is set to `EST`. */ + trunkId?: string; + /** Reference to the Service ID created with the Fax API. Not empty when the type is set to `FAX`. */ + serviceId?: string; } 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 889245b8..9ffaca47 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 @@ -21,7 +21,7 @@ describe('ActiveNumberApi', () => { }); describe ('getActiveNumber', () => { - it('should make a GET request to ...', async () => { + it('should make a GET request to retrieve a given phone number details', async () => { // Given const requestData: Numbers.GetActiveNumberRequestData = { phoneNumber: '+17813334444', @@ -52,6 +52,9 @@ describe('ActiveNumberApi', () => { appId: '', scheduledVoiceProvisioning: null, lastUpdatedTime: null, + type: 'RTC', + trunkId: '', + serviceId: '', }, callbackUrl: '', }; @@ -101,6 +104,9 @@ describe('ActiveNumberApi', () => { appId: '', scheduledVoiceProvisioning: null, lastUpdatedTime: null, + type: 'RTC', + trunkId: '', + serviceId: '', }, callbackUrl: '', }, @@ -148,7 +154,7 @@ describe('ActiveNumberApi', () => { nextChargeDate: new Date('2023-12-21T17:47:51.476076Z'), expireAt: new Date('2023-12-21T17:47:51.476076Z'), smsConfiguration: { - servicePlanId: '', + servicePlanId: 'servicePlanIdFromDashboard', scheduledProvisioning: null, campaignId: '', }, @@ -156,6 +162,9 @@ describe('ActiveNumberApi', () => { appId: '', scheduledVoiceProvisioning: null, lastUpdatedTime: null, + type: 'RTC', + trunkId: '', + serviceId: '', }, callbackUrl: '', }; @@ -178,8 +187,9 @@ describe('ActiveNumberApi', () => { phoneNumber: '+17813334444', updateActiveNumberRequestBody: { displayName: 'Updated display name', - smsConfiguration: { - servicePlanId: 'newServicePlanId', + voiceConfiguration: { + type: 'EST', + trunkId: 'trunkId', }, }, }; @@ -201,14 +211,24 @@ describe('ActiveNumberApi', () => { nextChargeDate: new Date('2023-12-21T17:47:51.476076Z'), expireAt: null, smsConfiguration: { - servicePlanId: 'newServicePlanId', + servicePlanId: 'servicePlanIdFromDashboard', scheduledProvisioning: null, campaignId: '', }, voiceConfiguration: { - appId: '', - scheduledVoiceProvisioning: null, + appId: 'appId', + scheduledVoiceProvisioning: { + appId: '', + status: 'WAITING', + lastUpdatedTime: new Date('2023-12-15T08:18:38.508882Z'), + type: 'EST', + trunkId: 'trunkId', + serviceId: '', + }, lastUpdatedTime: null, + type: 'RTC', + trunkId: '', + serviceId: '', }, callbackUrl: '', };