From 300d0f12c6e25a7ea72c027de60723700bf085ee Mon Sep 17 00:00:00 2001 From: Antoine Sein Date: Sat, 27 Apr 2024 10:47:34 +0200 Subject: [PATCH 1/4] DEVEXP-408: Add support for Country Permissions --- .../country-permissions/get.ts | 28 +++++ .../country-permissions/list.ts | 30 +++++ .../country-permissions/update.ts | 32 ++++++ .../country-permission/country-permission.ts | 15 +++ .../src/models/v1/country-permission/index.ts | 1 + .../src/models/v1/index.ts | 2 + .../index.ts | 1 + .../list-country-permissions-response.ts | 7 ++ .../country-permissions-request-data.ts | 14 +++ .../src/models/v1/requests/index.ts | 1 + .../country-permissions-api.jest.fixture.ts | 31 +++++ .../country-permissions-api.ts | 107 ++++++++++++++++++ .../src/rest/v1/country-permissions/index.ts | 2 + .../rest/v1/elastic-sip-trunking-service.ts | 4 + .../elastic-sip-trunking/src/rest/v1/index.ts | 1 + .../country-permissions-api.test.ts | 106 +++++++++++++++++ 16 files changed, 382 insertions(+) create mode 100644 examples/simple-examples/src/elastic-sip-trunking/country-permissions/get.ts create mode 100644 examples/simple-examples/src/elastic-sip-trunking/country-permissions/list.ts create mode 100644 examples/simple-examples/src/elastic-sip-trunking/country-permissions/update.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/country-permission/country-permission.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/country-permission/index.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/list-country-permissions-response/index.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/list-country-permissions-response/list-country-permissions-response.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/requests/country-permissions/country-permissions-request-data.ts create mode 100644 packages/elastic-sip-trunking/src/rest/v1/country-permissions/country-permissions-api.jest.fixture.ts create mode 100644 packages/elastic-sip-trunking/src/rest/v1/country-permissions/country-permissions-api.ts create mode 100644 packages/elastic-sip-trunking/src/rest/v1/country-permissions/index.ts create mode 100644 packages/elastic-sip-trunking/tests/rest/v1/country-permissions/country-permissions-api.test.ts diff --git a/examples/simple-examples/src/elastic-sip-trunking/country-permissions/get.ts b/examples/simple-examples/src/elastic-sip-trunking/country-permissions/get.ts new file mode 100644 index 00000000..0530a719 --- /dev/null +++ b/examples/simple-examples/src/elastic-sip-trunking/country-permissions/get.ts @@ -0,0 +1,28 @@ +import { ElasticSipTrunking } from '@sinch/sdk-core'; +import { + getPrintFormat, + initElasticSipTrunkingService, + printFullResponse, +} from '../../config'; + +(async () => { + console.log('************************'); + console.log('* getCountryPermission *'); + console.log('************************'); + + const requestData: ElasticSipTrunking.GetCountryPermissionRequestData = { + isoCode: 'US', + }; + + const elasticSipTrunkingService = initElasticSipTrunkingService(); + const response = await elasticSipTrunkingService.countryPermissions.get(requestData); + + const printFormat = getPrintFormat(process.argv); + + if (printFormat === 'pretty') { + console.log(`The country permission for the country '${response.name}' is ${response.enabled ? '' : 'not '}enabled`); + } else { + printFullResponse(response); + } + +})(); diff --git a/examples/simple-examples/src/elastic-sip-trunking/country-permissions/list.ts b/examples/simple-examples/src/elastic-sip-trunking/country-permissions/list.ts new file mode 100644 index 00000000..4396fa50 --- /dev/null +++ b/examples/simple-examples/src/elastic-sip-trunking/country-permissions/list.ts @@ -0,0 +1,30 @@ +import { ElasticSipTrunking } from '@sinch/sdk-core'; +import { + getPrintFormat, + initElasticSipTrunkingService, + printFullResponse, +} from '../../config'; + +(async () => { + console.log('*************************'); + console.log('* getCountryPermissions *'); + console.log('*************************'); + + const requestData: ElasticSipTrunking.ListCountryPermissionsRequestData = {}; + + const elasticSipTrunkingService = initElasticSipTrunkingService(); + const response = await elasticSipTrunkingService.countryPermissions.list(requestData); + + const printFormat = getPrintFormat(process.argv); + + if (printFormat === 'pretty') { + console.log(`Here is the status for all the countries:\n${response.countryPermissions?.map((permission) => formatPermission(permission)).join('\n')}`); + } else { + printFullResponse(response); + } + +})(); + +const formatPermission = (countryPermission: ElasticSipTrunking.CountryPermission): string => { + return ` - ${countryPermission.name}: ${countryPermission.enabled ? '' : 'NOT '} enabled`; +}; diff --git a/examples/simple-examples/src/elastic-sip-trunking/country-permissions/update.ts b/examples/simple-examples/src/elastic-sip-trunking/country-permissions/update.ts new file mode 100644 index 00000000..47efaacc --- /dev/null +++ b/examples/simple-examples/src/elastic-sip-trunking/country-permissions/update.ts @@ -0,0 +1,32 @@ +import { ElasticSipTrunking } from '@sinch/sdk-core'; +import { + getAccessControlListIdFromConfig, + getPrintFormat, + initElasticSipTrunkingService, + printFullResponse, +} from '../../config'; + +(async () => { + console.log('***************************'); + console.log('* updateCountryPermission *'); + console.log('***************************'); + + const requestData: ElasticSipTrunking.UpdateCountryPermissionRequestData = { + isoCode: 'US', + updateCountryPermissionRequestBody: { + enabled: false, + }, + }; + + const elasticSipTrunkingService = initElasticSipTrunkingService(); + const response = await elasticSipTrunkingService.countryPermissions.update(requestData); + + const printFormat = getPrintFormat(process.argv); + + if (printFormat === 'pretty') { + console.log(`The Permission for the country '${response.name}' is ${response.enabled ? '' : 'NOT '}enabled`); + } else { + printFullResponse(response); + } + +})(); diff --git a/packages/elastic-sip-trunking/src/models/v1/country-permission/country-permission.ts b/packages/elastic-sip-trunking/src/models/v1/country-permission/country-permission.ts new file mode 100644 index 00000000..59a5214f --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/country-permission/country-permission.ts @@ -0,0 +1,15 @@ +/** + * With country permissions you can control which countries can be dialed from your account. For beta only, countries supported are US,CA and * if you would like to allow international dialing. + */ +export interface CountryPermission { + /** The [ISO code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the country */ + isoCode?: string; + /** Country name in english */ + name?: string; + /** Continent of the country */ + continent?: string; + /** The country calling codes as an array, most countries have only one but some have multiple like the San Marino, China, and a few others. */ + countryDialingCodes?: string[]; + /** If the country is enabled or not. When this is enabled regular numbers can be dialed from the account. */ + enabled: boolean; +} diff --git a/packages/elastic-sip-trunking/src/models/v1/country-permission/index.ts b/packages/elastic-sip-trunking/src/models/v1/country-permission/index.ts new file mode 100644 index 00000000..e1cc9e53 --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/country-permission/index.ts @@ -0,0 +1 @@ +export type { CountryPermission } from './country-permission'; diff --git a/packages/elastic-sip-trunking/src/models/v1/index.ts b/packages/elastic-sip-trunking/src/models/v1/index.ts index 1306e894..89bf4834 100644 --- a/packages/elastic-sip-trunking/src/models/v1/index.ts +++ b/packages/elastic-sip-trunking/src/models/v1/index.ts @@ -1,6 +1,8 @@ export * from './access-control-list'; export * from './add-access-control-list-to-trunk'; +export * from './country-permission'; export * from './ip-range'; +export * from './list-country-permissions-response'; export * from './sip-endpoint'; export * from './sip-trunk'; export * from './update-access-control-list-request'; diff --git a/packages/elastic-sip-trunking/src/models/v1/list-country-permissions-response/index.ts b/packages/elastic-sip-trunking/src/models/v1/list-country-permissions-response/index.ts new file mode 100644 index 00000000..3884b784 --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/list-country-permissions-response/index.ts @@ -0,0 +1 @@ +export type { ListCountryPermissionsResponse } from './list-country-permissions-response'; diff --git a/packages/elastic-sip-trunking/src/models/v1/list-country-permissions-response/list-country-permissions-response.ts b/packages/elastic-sip-trunking/src/models/v1/list-country-permissions-response/list-country-permissions-response.ts new file mode 100644 index 00000000..9c191c69 --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/list-country-permissions-response/list-country-permissions-response.ts @@ -0,0 +1,7 @@ +import { CountryPermission } from '../country-permission'; + +export interface ListCountryPermissionsResponse { + + /** List of CountryPermissions */ + countryPermissions?: CountryPermission[]; +} diff --git a/packages/elastic-sip-trunking/src/models/v1/requests/country-permissions/country-permissions-request-data.ts b/packages/elastic-sip-trunking/src/models/v1/requests/country-permissions/country-permissions-request-data.ts new file mode 100644 index 00000000..910d8491 --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/requests/country-permissions/country-permissions-request-data.ts @@ -0,0 +1,14 @@ +import { CountryPermission } from '../../country-permission'; + +export interface GetCountryPermissionRequestData { + /** The ISO code of the country. */ + 'isoCode': string; +} +export interface ListCountryPermissionsRequestData { +} +export interface UpdateCountryPermissionRequestData { + /** The ISO code of the country. */ + 'isoCode': string; + /** The body containing the Country Permission details to update */ + 'updateCountryPermissionRequestBody': CountryPermission; +} diff --git a/packages/elastic-sip-trunking/src/models/v1/requests/index.ts b/packages/elastic-sip-trunking/src/models/v1/requests/index.ts index 5e4ffd42..980bcf7d 100644 --- a/packages/elastic-sip-trunking/src/models/v1/requests/index.ts +++ b/packages/elastic-sip-trunking/src/models/v1/requests/index.ts @@ -1,3 +1,4 @@ export * from './access-control-list/access-control-list-request-data'; +export * from './country-permissions/country-permissions-request-data'; export * from './sip-endpoints/sip-endpoints-request-data'; export * from './sip-trunks/sip-trunks-request-data'; diff --git a/packages/elastic-sip-trunking/src/rest/v1/country-permissions/country-permissions-api.jest.fixture.ts b/packages/elastic-sip-trunking/src/rest/v1/country-permissions/country-permissions-api.jest.fixture.ts new file mode 100644 index 00000000..7e3f1ef2 --- /dev/null +++ b/packages/elastic-sip-trunking/src/rest/v1/country-permissions/country-permissions-api.jest.fixture.ts @@ -0,0 +1,31 @@ +import { CountryPermissionsApi } from './country-permissions-api'; +import { + CountryPermission, + GetCountryPermissionRequestData, + ListCountryPermissionsRequestData, + ListCountryPermissionsResponse, + UpdateCountryPermissionRequestData, +} from '../../../models'; + +export class CountryPermissionsApiFixture implements Partial> { + + /** + * Fixture associated to function getCountryPermission + */ + public get: jest.Mock, [GetCountryPermissionRequestData]> = jest.fn(); + /** + * Fixture associated to function getCountryPermissions + */ + public list: jest.Mock< + Promise, + [ListCountryPermissionsRequestData] + > = jest.fn(); + /** + * Fixture associated to function updateCountryPermission + */ + public update: jest.Mock< + Promise, + [UpdateCountryPermissionRequestData] + > = jest.fn(); +} + diff --git a/packages/elastic-sip-trunking/src/rest/v1/country-permissions/country-permissions-api.ts b/packages/elastic-sip-trunking/src/rest/v1/country-permissions/country-permissions-api.ts new file mode 100644 index 00000000..007f9f95 --- /dev/null +++ b/packages/elastic-sip-trunking/src/rest/v1/country-permissions/country-permissions-api.ts @@ -0,0 +1,107 @@ +import { + CountryPermission, + ListCountryPermissionsResponse, + GetCountryPermissionRequestData, + ListCountryPermissionsRequestData, + UpdateCountryPermissionRequestData, +} from '../../../models'; +import { + RequestBody, + SinchClientParameters, +} from '@sinch/sdk-client'; +import { ElasticSipTrunkingDomainApi } from '../elastic-sip-trunking-domain-api'; + +export class CountryPermissionsApi extends ElasticSipTrunkingDomainApi { + + /** + * Initialize your interface + * + * @param {SinchClientParameters} sinchClientParameters - The parameters used to initialize the API Client. + */ + constructor(sinchClientParameters: SinchClientParameters) { + super(sinchClientParameters, 'CountryPermissionsApi'); + } + + /** + * Fetch country permission + * Fetches the requested country permission. + * @param { GetCountryPermissionRequestData } data - The data to provide to the API call. + */ + public async get(data: GetCountryPermissionRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = ''; + const basePathUrl = `${this.client.apiClientOptions.hostname}/v1/projects/${this.client.apiClientOptions.projectId}/countryPermissions/${data['isoCode']}`; + + const requestOptions = await this.client.prepareOptions(basePathUrl, 'GET', getParams, headers, body || undefined); + const url = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'GetCountryPermission', + }); + } + + /** + * Fetch all country permissions + * Fetches the list of country permissions. + * @param { ListCountryPermissionsRequestData } data - The data to provide to the API call. + */ + public async list(data: ListCountryPermissionsRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = ''; + const basePathUrl = `${this.client.apiClientOptions.hostname}/v1/projects/${this.client.apiClientOptions.projectId}/countryPermissions`; + + const requestOptions = await this.client.prepareOptions(basePathUrl, 'GET', getParams, headers, body || undefined); + const url = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'GetCountryPermissions', + }); + } + + /** + * Update country permission + * Update the requested country permission. + * @param { UpdateCountryPermissionRequestData } data - The data to provide to the API call. + */ + public async update(data: UpdateCountryPermissionRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = data['updateCountryPermissionRequestBody'] ? JSON.stringify(data['updateCountryPermissionRequestBody']) : '{}'; + const basePathUrl = `${this.client.apiClientOptions.hostname}/v1/projects/${this.client.apiClientOptions.projectId}/countryPermissions/${data['isoCode']}`; + + const requestOptions = await this.client.prepareOptions(basePathUrl, 'PUT', getParams, headers, body || undefined); + const url = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'UpdateCountryPermission', + }); + } + + +} diff --git a/packages/elastic-sip-trunking/src/rest/v1/country-permissions/index.ts b/packages/elastic-sip-trunking/src/rest/v1/country-permissions/index.ts new file mode 100644 index 00000000..7c0e5706 --- /dev/null +++ b/packages/elastic-sip-trunking/src/rest/v1/country-permissions/index.ts @@ -0,0 +1,2 @@ +export * from './country-permissions-api'; +export * from './country-permissions-api.jest.fixture'; diff --git a/packages/elastic-sip-trunking/src/rest/v1/elastic-sip-trunking-service.ts b/packages/elastic-sip-trunking/src/rest/v1/elastic-sip-trunking-service.ts index 99eb6448..cfcc0c98 100644 --- a/packages/elastic-sip-trunking/src/rest/v1/elastic-sip-trunking-service.ts +++ b/packages/elastic-sip-trunking/src/rest/v1/elastic-sip-trunking-service.ts @@ -2,17 +2,20 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { SipTrunksApi } from './sip-trunks'; import { AccessControlListApi } from './access-control-list'; import { SipEndpointsApi } from './sip-endpoints'; +import { CountryPermissionsApi } from './country-permissions'; export class ElasticSipTrunkingService { public readonly sipTrunks: SipTrunksApi; public readonly sipEndpoints: SipEndpointsApi; public readonly accessControlList: AccessControlListApi; + public readonly countryPermissions: CountryPermissionsApi; constructor(params: SinchClientParameters) { this.sipTrunks = new SipTrunksApi(params); this.sipEndpoints = new SipEndpointsApi(params); this.accessControlList = new AccessControlListApi(params); + this.countryPermissions = new CountryPermissionsApi(params); } /** @@ -24,5 +27,6 @@ export class ElasticSipTrunkingService { this.sipTrunks.setHostname(hostname); this.sipEndpoints.setHostname(hostname); this.accessControlList.setHostname(hostname); + this.countryPermissions.setHostname(hostname); } } diff --git a/packages/elastic-sip-trunking/src/rest/v1/index.ts b/packages/elastic-sip-trunking/src/rest/v1/index.ts index b92e1cdd..f5db553a 100644 --- a/packages/elastic-sip-trunking/src/rest/v1/index.ts +++ b/packages/elastic-sip-trunking/src/rest/v1/index.ts @@ -1,4 +1,5 @@ export * from './access-control-list'; +export * from './country-permissions'; export * from './sip-endpoints'; export * from './sip-trunks'; export * from './elastic-sip-trunking-service'; diff --git a/packages/elastic-sip-trunking/tests/rest/v1/country-permissions/country-permissions-api.test.ts b/packages/elastic-sip-trunking/tests/rest/v1/country-permissions/country-permissions-api.test.ts new file mode 100644 index 00000000..6ce76e4b --- /dev/null +++ b/packages/elastic-sip-trunking/tests/rest/v1/country-permissions/country-permissions-api.test.ts @@ -0,0 +1,106 @@ +import { SinchClientParameters } from '@sinch/sdk-client'; +import { CountryPermissionsApi, CountryPermissionsApiFixture, ElasticSipTrunking } from '../../../../src'; + +describe('CountryPermissionsApi', () => { + let countryPermissionsApi: CountryPermissionsApi; + let fixture: CountryPermissionsApiFixture; + let credentials: SinchClientParameters; + + beforeEach(() => { + fixture = new CountryPermissionsApiFixture(); + credentials = { + projectId: 'PROJECT_ID', + keyId: 'KEY_ID', + keySecret: 'KEY_SECRET', + }; + countryPermissionsApi = new CountryPermissionsApi(credentials); + }); + + + describe ('getCountryPermission', () => { + it('should make a GET request to fetch the requested country permission', async () => { + // Given + const requestData: ElasticSipTrunking.GetCountryPermissionRequestData = { + isoCode: 'US', + }; + const expectedResponse: ElasticSipTrunking.CountryPermission = { + isoCode: 'US', + name: 'United States/Canada', + continent: 'North America', + countryDialingCodes: [ + '+1', + ], + enabled: true, + }; + + // When + fixture.get.mockResolvedValue(expectedResponse); + countryPermissionsApi.get = fixture.get; + const response = await countryPermissionsApi.get(requestData); + + // Then + expect(response).toEqual(expectedResponse); + expect(fixture.get).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('getCountryPermissions', () => { + it('should make a GET request to fetch the list of country permissions', async () => { + // Given + const requestData: ElasticSipTrunking.ListCountryPermissionsRequestData = {}; + const expectedResponse: ElasticSipTrunking.ListCountryPermissionsResponse = { + countryPermissions: [ + { + isoCode: 'US', + name: 'United States/Canada', + continent: 'North America', + countryDialingCodes: [ + '+1', + ], + enabled: true, + }, + ], + }; + + // When + fixture.list.mockResolvedValue(expectedResponse); + countryPermissionsApi.list = fixture.list; + const response = await countryPermissionsApi.list(requestData); + + // Then + expect(response).toEqual(expectedResponse); + expect(fixture.list).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('updateCountryPermission', () => { + it('should make a PUT request to update the requested country permission', async () => { + // Given + const requestData: ElasticSipTrunking.UpdateCountryPermissionRequestData = { + isoCode: 'US', + updateCountryPermissionRequestBody: { + enabled: false, + name: 'United States only', + }, + }; + const expectedResponse: ElasticSipTrunking.CountryPermission = { + isoCode: 'US', + name: 'United States only', + continent: 'North America', + countryDialingCodes: [ + '+1', + ], + enabled: true, + }; + + // When + fixture.update.mockResolvedValue(expectedResponse); + countryPermissionsApi.update = fixture.update; + const response = await countryPermissionsApi.update(requestData); + + // Then + expect(response).toEqual(expectedResponse); + expect(fixture.update).toHaveBeenCalledWith(requestData); + }); + }); +}); From cc98311ead95f0a8a9f334b0b45fb9da7ecabc76 Mon Sep 17 00:00:00 2001 From: Antoine Sein Date: Sat, 27 Apr 2024 10:48:11 +0200 Subject: [PATCH 2/4] DEVEXP-408: Fix linter --- .../rest/v1/country-permissions/country-permissions-api.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/elastic-sip-trunking/src/rest/v1/country-permissions/country-permissions-api.ts b/packages/elastic-sip-trunking/src/rest/v1/country-permissions/country-permissions-api.ts index 007f9f95..656e6433 100644 --- a/packages/elastic-sip-trunking/src/rest/v1/country-permissions/country-permissions-api.ts +++ b/packages/elastic-sip-trunking/src/rest/v1/country-permissions/country-permissions-api.ts @@ -89,7 +89,9 @@ export class CountryPermissionsApi extends ElasticSipTrunkingDomainApi { 'Accept': 'application/json', }; - const body: RequestBody = data['updateCountryPermissionRequestBody'] ? JSON.stringify(data['updateCountryPermissionRequestBody']) : '{}'; + const body: RequestBody = data['updateCountryPermissionRequestBody'] + ? JSON.stringify(data['updateCountryPermissionRequestBody']) + : '{}'; const basePathUrl = `${this.client.apiClientOptions.hostname}/v1/projects/${this.client.apiClientOptions.projectId}/countryPermissions/${data['isoCode']}`; const requestOptions = await this.client.prepareOptions(basePathUrl, 'PUT', getParams, headers, body || undefined); From f8101c7b8237120a1d52a7291a67a645f83d720c Mon Sep 17 00:00:00 2001 From: Antoine Sein Date: Sat, 27 Apr 2024 11:17:43 +0200 Subject: [PATCH 3/4] Fix update country permission --- examples/simple-examples/README.md | 3 +++ examples/simple-examples/package.json | 3 +++ .../src/elastic-sip-trunking/country-permissions/update.ts | 1 - packages/elastic-sip-trunking/src/models/v1/index.ts | 1 + .../country-permissions/country-permissions-request-data.ts | 4 ++-- .../src/models/v1/update-country-permission-request/index.ts | 1 + .../update-country-permission-request.ts | 4 ++++ .../v1/country-permissions/country-permissions-api.test.ts | 1 - 8 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 packages/elastic-sip-trunking/src/models/v1/update-country-permission-request/index.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/update-country-permission-request/update-country-permission-request.ts diff --git a/examples/simple-examples/README.md b/examples/simple-examples/README.md index a28e3c96..a6de085e 100644 --- a/examples/simple-examples/README.md +++ b/examples/simple-examples/README.md @@ -303,3 +303,6 @@ yarn run numbers:regions:list | | [./src/elastic-sip-trunking/access-control-list/addToTrunk.ts](./src/elastic-sip-trunking/access-control-list/addToTrunk.ts) | SIP_TRUNK_ID, ACL_ID | | | [./src/elastic-sip-trunking/access-control-list/listForTrunk.ts](./src/elastic-sip-trunking/access-control-list/listForTrunk.ts) | SIP_TRUNK_ID | | | [./src/elastic-sip-trunking/access-control-list/deleteFromTrunk.ts](./src/elastic-sip-trunking/access-control-list/deleteFromTrunk.ts) | SIP_TRUNK_ID, ACL_ID | +| Country Permissions | [./src/elastic-sip-trunking/country-permissions/get.ts](./src/elastic-sip-trunking/country-permissions/get.ts) | | +| | [./src/elastic-sip-trunking/country-permissions/list.ts](./src/elastic-sip-trunking/country-permissions/list.ts) | | +| | [./src/elastic-sip-trunking/country-permissions/update.ts](./src/elastic-sip-trunking/country-permissions/update.ts) | | diff --git a/examples/simple-examples/package.json b/examples/simple-examples/package.json index 87adca7f..5d96f491 100644 --- a/examples/simple-examples/package.json +++ b/examples/simple-examples/package.json @@ -95,6 +95,9 @@ "elasticSipTrunks:accessControlList:addToTrunk": "ts-node src/elastic-sip-trunking/access-control-list/addToTrunk.ts", "elasticSipTrunks:accessControlList:listForTrunk": "ts-node src/elastic-sip-trunking/access-control-list/listForTrunk.ts", "elasticSipTrunks:accessControlList:deleteFromTrunk": "ts-node src/elastic-sip-trunking/access-control-list/deleteFromTrunk.ts", + "elasticSipTrunks:countryPermissions:get": "ts-node src/elastic-sip-trunking/country-permissions/get.ts", + "elasticSipTrunks:countryPermissions:list": "ts-node src/elastic-sip-trunking/country-permissions/list.ts", + "elasticSipTrunks:countryPermissions:update": "ts-node src/elastic-sip-trunking/country-permissions/update.ts", "fax:services:create": "ts-node src/fax/services/create.ts", "fax:services:get": "ts-node src/fax/services/get.ts", "fax:services:list": "ts-node src/fax/services/list.ts", diff --git a/examples/simple-examples/src/elastic-sip-trunking/country-permissions/update.ts b/examples/simple-examples/src/elastic-sip-trunking/country-permissions/update.ts index 47efaacc..178cfe87 100644 --- a/examples/simple-examples/src/elastic-sip-trunking/country-permissions/update.ts +++ b/examples/simple-examples/src/elastic-sip-trunking/country-permissions/update.ts @@ -1,6 +1,5 @@ import { ElasticSipTrunking } from '@sinch/sdk-core'; import { - getAccessControlListIdFromConfig, getPrintFormat, initElasticSipTrunkingService, printFullResponse, diff --git a/packages/elastic-sip-trunking/src/models/v1/index.ts b/packages/elastic-sip-trunking/src/models/v1/index.ts index 89bf4834..e7c0d90e 100644 --- a/packages/elastic-sip-trunking/src/models/v1/index.ts +++ b/packages/elastic-sip-trunking/src/models/v1/index.ts @@ -6,4 +6,5 @@ export * from './list-country-permissions-response'; export * from './sip-endpoint'; export * from './sip-trunk'; export * from './update-access-control-list-request'; +export * from './update-country-permission-request'; export * from './requests'; diff --git a/packages/elastic-sip-trunking/src/models/v1/requests/country-permissions/country-permissions-request-data.ts b/packages/elastic-sip-trunking/src/models/v1/requests/country-permissions/country-permissions-request-data.ts index 910d8491..8c0eeaf1 100644 --- a/packages/elastic-sip-trunking/src/models/v1/requests/country-permissions/country-permissions-request-data.ts +++ b/packages/elastic-sip-trunking/src/models/v1/requests/country-permissions/country-permissions-request-data.ts @@ -1,4 +1,4 @@ -import { CountryPermission } from '../../country-permission'; +import { UpdateCountryPermissionRequest } from '../../update-country-permission-request'; export interface GetCountryPermissionRequestData { /** The ISO code of the country. */ @@ -10,5 +10,5 @@ export interface UpdateCountryPermissionRequestData { /** The ISO code of the country. */ 'isoCode': string; /** The body containing the Country Permission details to update */ - 'updateCountryPermissionRequestBody': CountryPermission; + 'updateCountryPermissionRequestBody': UpdateCountryPermissionRequest; } diff --git a/packages/elastic-sip-trunking/src/models/v1/update-country-permission-request/index.ts b/packages/elastic-sip-trunking/src/models/v1/update-country-permission-request/index.ts new file mode 100644 index 00000000..9f3f24aa --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/update-country-permission-request/index.ts @@ -0,0 +1 @@ +export type { UpdateCountryPermissionRequest } from './update-country-permission-request'; diff --git a/packages/elastic-sip-trunking/src/models/v1/update-country-permission-request/update-country-permission-request.ts b/packages/elastic-sip-trunking/src/models/v1/update-country-permission-request/update-country-permission-request.ts new file mode 100644 index 00000000..2181a794 --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/update-country-permission-request/update-country-permission-request.ts @@ -0,0 +1,4 @@ +export interface UpdateCountryPermissionRequest { + /** If the country is enabled or not. When this is enabled regular numbers can be dialed from the account. */ + enabled: boolean; +} diff --git a/packages/elastic-sip-trunking/tests/rest/v1/country-permissions/country-permissions-api.test.ts b/packages/elastic-sip-trunking/tests/rest/v1/country-permissions/country-permissions-api.test.ts index 6ce76e4b..cb780eab 100644 --- a/packages/elastic-sip-trunking/tests/rest/v1/country-permissions/country-permissions-api.test.ts +++ b/packages/elastic-sip-trunking/tests/rest/v1/country-permissions/country-permissions-api.test.ts @@ -80,7 +80,6 @@ describe('CountryPermissionsApi', () => { isoCode: 'US', updateCountryPermissionRequestBody: { enabled: false, - name: 'United States only', }, }; const expectedResponse: ElasticSipTrunking.CountryPermission = { From 4e8bba9bae7ccf1abf5ac2749d75120f6c93eb82 Mon Sep 17 00:00:00 2001 From: Antoine SEIN <142824551+asein-sinch@users.noreply.github.com> Date: Mon, 13 May 2024 11:28:24 +0200 Subject: [PATCH 4/4] DEVEXP-409: Add support for Phone Numbers (#80) --- examples/simple-examples/README.md | 1 + examples/simple-examples/package.json | 1 + .../calls-history/find.ts | 75 +++++++++++++++++++ .../src/numbers/active/list.ts | 4 +- .../src/rest/v1/conversation-domain-api.ts | 9 ++- .../src/models/v1/call/call.ts | 36 +++++++++ .../src/models/v1/call/index.ts | 1 + .../src/models/v1/enum.ts | 3 + .../src/models/v1/index.ts | 4 + .../src/models/v1/money/index.ts | 1 + .../src/models/v1/money/money.ts | 9 +++ .../src/models/v1/phoneNumber/index.ts | 1 + .../src/models/v1/phoneNumber/phoneNumber.ts | 17 +++++ .../calls-history-request-data.ts | 20 +++++ .../src/models/v1/requests/index.ts | 1 + .../models/v1/sip-endpoint/sip-endpoint.ts | 2 +- .../src/models/v1/sip-trunk/sip-trunk.ts | 2 +- .../calls-history-api.jest.fixture.ts | 12 +++ .../v1/calls-history/calls-history-api.ts | 69 +++++++++++++++++ .../src/rest/v1/calls-history/index.ts | 2 + .../v1/elastic-sip-trunking-domain-api.ts | 4 +- .../rest/v1/elastic-sip-trunking-service.ts | 4 + .../elastic-sip-trunking/src/rest/v1/index.ts | 1 + .../src/rest/v1/sip-trunks/sip-trunks-api.ts | 2 +- .../calls-history/calls-history-api.test.ts | 68 +++++++++++++++++ .../elastic-sip-trunking-domain-api.test.ts | 37 +++++++++ .../v1/elastic-sip-trunking-service.test.ts | 62 +++++++++++++++ packages/fax/src/rest/v3/fax-domain-api.ts | 4 +- .../active-number-request.ts | 7 -- .../models/v1/active-number/active-number.ts | 7 -- .../active-numbers-response.ts | 7 -- .../v1/available-number/available-number.ts | 7 -- .../available-numbers-response.ts | 7 -- .../v1/available-region/available-region.ts | 7 -- .../src/models/v1/bad-request/bad-request.ts | 7 -- .../callback-configuration-update.ts | 7 -- .../callback-configuration.ts | 7 -- .../v1/callback-payload/callback-payload.ts | 8 -- .../v1/field-violation/field-violation.ts | 7 -- .../internal-error-error.ts | 7 -- .../v1/internal-error/internal-error.ts | 7 -- .../invalid-argument-error.ts | 7 -- .../v1/invalid-argument/invalid-argument.ts | 7 -- .../list-available-number-request.ts | 7 -- .../list-available-regions-response.ts | 7 -- packages/numbers/src/models/v1/money/money.ts | 7 -- .../v1/not-found-error/not-found-error.ts | 7 -- .../src/models/v1/not-found/not-found.ts | 7 -- .../number-pattern-pattern.ts | 7 -- .../number-pattern-search-pattern.ts | 7 -- .../provisioning-status.ts | 7 -- ...nt-any-number-request-sms-configuration.ts | 7 -- ...-any-number-request-voice-configuration.ts | 7 -- .../rent-any-number-request.ts | 7 -- .../rent-number-request.ts | 7 -- .../scheduled-provisioning.ts | 7 -- .../scheduled-voice-provisioning.ts | 15 ++-- .../v1/search-pattern/search-pattern.ts | 6 -- .../v1/sms-configuration/sms-configuration.ts | 7 -- .../v1/sms-error-code/sms-error-code.ts | 7 -- .../voice-configuration.ts | 15 ++-- .../numbers/src/rest/v1/numbers-domain-api.ts | 3 +- .../active-number/active-number-api.test.ts | 34 +++++++-- .../available-number-api.test.ts | 37 ++++++++- .../sdk-client/src/domain/domain-helper.ts | 16 ++++ packages/sdk-client/src/domain/index.ts | 1 + .../plugins/oauth2/oauth2-token.request.ts | 3 +- .../tests/domain/domain-helper.test.ts | 51 +++++++++++++ .../v1/api-inbound-list/api-inbound-list.ts | 7 -- .../v1/api-mo-message/api-mo-message.ts | 8 -- .../api-update-binary-mt-message.ts | 1 - .../api-update-mt-message.ts | 7 -- .../v1/binary-request/binary-request.ts | 1 - .../create-group-request.ts | 7 -- .../create-group-response.ts | 7 -- .../delivery-feedback-request.ts | 8 -- .../delivery-report-list.ts | 7 -- .../v1/dry-run-request/dry-run-request.ts | 7 -- .../dry-run-response-per-recipient-inner.ts | 8 -- .../v1/dry-run-response/dry-run-response.ts | 7 -- .../error-response-obj/error-response-obj.ts | 8 -- .../v1/group-auto-update/group-auto-update.ts | 8 -- .../group-object-auto-update-remove.ts | 8 -- .../group-object-auto-update.ts | 7 -- .../inbound-message-response.ts | 7 -- .../list-groups-response.ts | 7 -- .../message-delivery-status.ts | 8 -- .../parameter-obj-parameter-key.ts | 8 -- .../models/v1/parameter-obj/parameter-obj.ts | 7 -- .../recipient-delivery-report.ts | 1 - .../replace-group-request.ts | 8 -- .../update-batch-message-request.ts | 7 -- .../update-group-request-auto-update-add.ts | 8 -- ...update-group-request-auto-update-remove.ts | 8 -- .../update-group-request-auto-update.ts | 7 -- .../update-group-request.ts | 7 -- packages/sms/src/rest/v1/sms-domain-api.ts | 4 +- .../src/rest/v1/verification-domain-api.ts | 3 +- .../voice/src/rest/v1/voice-domain-api.ts | 7 +- 99 files changed, 599 insertions(+), 448 deletions(-) create mode 100644 examples/simple-examples/src/elastic-sip-trunking/calls-history/find.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/call/call.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/call/index.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/enum.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/money/index.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/money/money.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/phoneNumber/index.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/phoneNumber/phoneNumber.ts create mode 100644 packages/elastic-sip-trunking/src/models/v1/requests/calls-history/calls-history-request-data.ts create mode 100644 packages/elastic-sip-trunking/src/rest/v1/calls-history/calls-history-api.jest.fixture.ts create mode 100644 packages/elastic-sip-trunking/src/rest/v1/calls-history/calls-history-api.ts create mode 100644 packages/elastic-sip-trunking/src/rest/v1/calls-history/index.ts create mode 100644 packages/elastic-sip-trunking/tests/rest/v1/calls-history/calls-history-api.test.ts create mode 100644 packages/elastic-sip-trunking/tests/rest/v1/elastic-sip-trunking-domain-api.test.ts create mode 100644 packages/elastic-sip-trunking/tests/rest/v1/elastic-sip-trunking-service.test.ts create mode 100644 packages/sdk-client/src/domain/domain-helper.ts create mode 100644 packages/sdk-client/tests/domain/domain-helper.test.ts diff --git a/examples/simple-examples/README.md b/examples/simple-examples/README.md index a6de085e..d78fe15f 100644 --- a/examples/simple-examples/README.md +++ b/examples/simple-examples/README.md @@ -306,3 +306,4 @@ yarn run numbers:regions:list | Country Permissions | [./src/elastic-sip-trunking/country-permissions/get.ts](./src/elastic-sip-trunking/country-permissions/get.ts) | | | | [./src/elastic-sip-trunking/country-permissions/list.ts](./src/elastic-sip-trunking/country-permissions/list.ts) | | | | [./src/elastic-sip-trunking/country-permissions/update.ts](./src/elastic-sip-trunking/country-permissions/update.ts) | | +| Calls | [./src/elastic-sip-trunking/calls-history/find.ts](./src/elastic-sip-trunking/calls-history/find.ts) | SIP_TRUNK_ID | diff --git a/examples/simple-examples/package.json b/examples/simple-examples/package.json index 5d96f491..e29b8787 100644 --- a/examples/simple-examples/package.json +++ b/examples/simple-examples/package.json @@ -98,6 +98,7 @@ "elasticSipTrunks:countryPermissions:get": "ts-node src/elastic-sip-trunking/country-permissions/get.ts", "elasticSipTrunks:countryPermissions:list": "ts-node src/elastic-sip-trunking/country-permissions/list.ts", "elasticSipTrunks:countryPermissions:update": "ts-node src/elastic-sip-trunking/country-permissions/update.ts", + "elasticSipTrunks:calls:find": "ts-node src/elastic-sip-trunking/calls-history/find.ts", "fax:services:create": "ts-node src/fax/services/create.ts", "fax:services:get": "ts-node src/fax/services/get.ts", "fax:services:list": "ts-node src/fax/services/list.ts", diff --git a/examples/simple-examples/src/elastic-sip-trunking/calls-history/find.ts b/examples/simple-examples/src/elastic-sip-trunking/calls-history/find.ts new file mode 100644 index 00000000..10dcddfe --- /dev/null +++ b/examples/simple-examples/src/elastic-sip-trunking/calls-history/find.ts @@ -0,0 +1,75 @@ +import { ElasticSipTrunking, PageResult } from '@sinch/sdk-core'; +import { + getPrintFormat, + getSipTrunkIdFromConfig, + initElasticSipTrunkingService, + printFullResponse, +} from '../../config'; + +const populateCallsList = ( + callsPage: PageResult, + callsList: ElasticSipTrunking.Call[], + callsDetailsList: string[], +) => { + callsPage.data.map((call: ElasticSipTrunking.Call) => { + callsList.push(call); + callsDetailsList.push(`${call.callId} - From: ${call.from} - To: ${call.to}`); + }); +}; + +(async () => { + console.log('*************'); + console.log('* findCalls *'); + console.log('*************'); + + const trunkId = getSipTrunkIdFromConfig(); + + const requestData: ElasticSipTrunking.FindCallsRequestData = { + trunkId, + callResult: 'COMPLETED', + direction: 'INBOUND', + }; + + const elasticSipTrunkingService = initElasticSipTrunkingService(); + + // ---------------------------------------------- + // Method 1: Fetch the data page by page manually + // ---------------------------------------------- + let response = await elasticSipTrunkingService.calls.find(requestData); + + const callsList: ElasticSipTrunking.Call[] = []; + const callsDetailsList: string[] = []; + + // Loop on all the pages to get all the active numbers + let reachedEndOfPages = false; + while (!reachedEndOfPages) { + populateCallsList(response, callsList, callsDetailsList); + if (response.hasNextPage) { + response = await response.nextPage(); + } else { + reachedEndOfPages = true; + } + } + + const printFormat = getPrintFormat(process.argv); + + if (printFormat === 'pretty') { + console.log(callsDetailsList.length > 0 + ? 'List of calls found:\n' + callsDetailsList.join('\n') + : 'Sorry, no calls were found.'); + } else { + printFullResponse(callsList); + } + + // --------------------------------------------------------------------- + // Method 2: Use the iterator and fetch data on more pages automatically + // --------------------------------------------------------------------- + for await (const call of elasticSipTrunkingService.calls.find(requestData)) { + if (printFormat === 'pretty') { + console.log(`${call.callId} - From: ${call.from} - To: ${call.to}`); + } else { + console.log(call); + } + } + +})(); 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/conversation/src/rest/v1/conversation-domain-api.ts b/packages/conversation/src/rest/v1/conversation-domain-api.ts index a5179dcb..d795a72e 100644 --- a/packages/conversation/src/rest/v1/conversation-domain-api.ts +++ b/packages/conversation/src/rest/v1/conversation-domain-api.ts @@ -3,7 +3,10 @@ import { ApiClient, ApiFetchClient, buildOAuth2ApiClientOptions, + CONVERSATION_HOSTNAME, + CONVERSATION_TEMPLATES_HOSTNAME, ConversationRegion, + formatRegionalizedHostname, SinchClientParameters, SupportedConversationRegion, UnifiedCredentials, @@ -92,9 +95,11 @@ export class ConversationDomainApi implements Api { switch (this.apiName) { case 'TemplatesV1Api': case 'TemplatesV2Api': - return this.sinchClientParameters.conversationTemplatesHostname ?? `https://${formattedRegion}template.api.sinch.com`; + return this.sinchClientParameters.conversationTemplatesHostname + ?? formatRegionalizedHostname(CONVERSATION_TEMPLATES_HOSTNAME, formattedRegion); default: - return this.sinchClientParameters.conversationHostname ?? `https://${formattedRegion}conversation.api.sinch.com`; + return this.sinchClientParameters.conversationHostname + ?? formatRegionalizedHostname(CONVERSATION_HOSTNAME, formattedRegion); } } diff --git a/packages/elastic-sip-trunking/src/models/v1/call/call.ts b/packages/elastic-sip-trunking/src/models/v1/call/call.ts new file mode 100644 index 00000000..7fd6425a --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/call/call.ts @@ -0,0 +1,36 @@ +import { Money } from '../money'; +import { CallResult, DirectionEnum } from '../enum'; + +/** + * The call resource represents an inbound or outbound connection between Sinch and a supported device + */ +export interface Call { + /** The unique identifier of the call. */ + callId?: string; + /** For `INBOUND` calls, this is the Sinch number the phone dialed. For `OUTBOUND` calls, this is the phone number you want to make a call to. Formatted according e164 format. */ + to?: string; + /** For `INBOUND` calls, this is the number of the person calling. When making an outbound call set this to the your Sinch number you want to show up as Caller Id. The call\'s origination, formatted according to the call\'s `callType`. For calls in the telephone network, this is a phone number in [E.164](/docs/voice/api-reference/call-types) format, including the leading `+`. More info see [Call types](/docs/voice/api-reference/call-types) */ + from?: string; + /** Describes whether the call was `INBOUND` *to* your Sinch number or was `OUTBOUND` and made *from* your Sinch number. */ + direction?: DirectionEnum; + /** Time when call was answered */ + answerTime?: Date; + /** The time the call ended */ + endTime?: Date; + /** The duration of the call in seconds. For inbound calls, this is the time from when the call started until the call ended. For outbound calls, this is the time from when the call was answered until the call ended. */ + durationSeconds?: number; + /** The result of the call */ + callResult?: CallResult; + /** @see Money */ + pricePerMinute?: Money; + /** The duration of the call adjusted with the billing period. */ + billingDurationSeconds?: number; + /** @see Money */ + price?: Money; + /** The time the call was created. */ + createTime?: Date; + /** The ID of the project that the call belongs to. */ + projectId?: string; + /** The ID of the trunk that the call was made through. */ + trunkId?: string; +} diff --git a/packages/elastic-sip-trunking/src/models/v1/call/index.ts b/packages/elastic-sip-trunking/src/models/v1/call/index.ts new file mode 100644 index 00000000..48ba5cae --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/call/index.ts @@ -0,0 +1 @@ +export type { Call } from './call'; diff --git a/packages/elastic-sip-trunking/src/models/v1/enum.ts b/packages/elastic-sip-trunking/src/models/v1/enum.ts new file mode 100644 index 00000000..312f600f --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/enum.ts @@ -0,0 +1,3 @@ +export type DirectionEnum = 'INBOUND' | 'OUTBOUND'; + +export type CallResult = 'COMPLETED' | 'NO_ANSWER' | 'CANCEL' | 'BUSY' | 'FAILED'; diff --git a/packages/elastic-sip-trunking/src/models/v1/index.ts b/packages/elastic-sip-trunking/src/models/v1/index.ts index e7c0d90e..4f57738f 100644 --- a/packages/elastic-sip-trunking/src/models/v1/index.ts +++ b/packages/elastic-sip-trunking/src/models/v1/index.ts @@ -1,10 +1,14 @@ export * from './access-control-list'; export * from './add-access-control-list-to-trunk'; +export * from './call'; export * from './country-permission'; export * from './ip-range'; export * from './list-country-permissions-response'; +export * from './money'; +export * from './phoneNumber'; export * from './sip-endpoint'; export * from './sip-trunk'; export * from './update-access-control-list-request'; export * from './update-country-permission-request'; +export * from './enum'; export * from './requests'; diff --git a/packages/elastic-sip-trunking/src/models/v1/money/index.ts b/packages/elastic-sip-trunking/src/models/v1/money/index.ts new file mode 100644 index 00000000..6b156e03 --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/money/index.ts @@ -0,0 +1 @@ +export type { Money } from './money'; diff --git a/packages/elastic-sip-trunking/src/models/v1/money/money.ts b/packages/elastic-sip-trunking/src/models/v1/money/money.ts new file mode 100644 index 00000000..bc45fbfb --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/money/money.ts @@ -0,0 +1,9 @@ +/** + * This is where we need description to be overridden by `$ref:` description + */ +export interface Money { + /** The 3-letter currency code defined in ISO 4217. */ + currencyCode?: string; + /** The amount with 4 decimals and decimal delimiter `.`. */ + amount?: string; +} diff --git a/packages/elastic-sip-trunking/src/models/v1/phoneNumber/index.ts b/packages/elastic-sip-trunking/src/models/v1/phoneNumber/index.ts new file mode 100644 index 00000000..9be32744 --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/phoneNumber/index.ts @@ -0,0 +1 @@ +export type { PhoneNumber } from './phoneNumber'; diff --git a/packages/elastic-sip-trunking/src/models/v1/phoneNumber/phoneNumber.ts b/packages/elastic-sip-trunking/src/models/v1/phoneNumber/phoneNumber.ts new file mode 100644 index 00000000..929ff8d4 --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/phoneNumber/phoneNumber.ts @@ -0,0 +1,17 @@ +/** + * A Sinch phone number assigned to a SIP trunk. This must be a number you own and configured for Elastic SIP Trunking. + */ +export interface PhoneNumber { + /** The ID of the phone number. */ + id?: string; + /** The ID of the SIP trunk to which the phone number is assigned. */ + sipTrunkId?: string; + /** A phone number in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format, including the leading \'+\'. */ + phoneNumber?: string; + /** The country code of the phone number in ISO 3166-1 alpha-2 format. */ + countryCode?: string; + /** The date and time that the number was assigned to the SIP trunk. */ + createTime?: Date; + /** The date and time that the phone number was last modified. */ + updateTime?: Date; +} diff --git a/packages/elastic-sip-trunking/src/models/v1/requests/calls-history/calls-history-request-data.ts b/packages/elastic-sip-trunking/src/models/v1/requests/calls-history/calls-history-request-data.ts new file mode 100644 index 00000000..f22dc84a --- /dev/null +++ b/packages/elastic-sip-trunking/src/models/v1/requests/calls-history/calls-history-request-data.ts @@ -0,0 +1,20 @@ +import { CallResult, DirectionEnum } from '../../enum'; + +export interface FindCallsRequestData { + /** A phone number that you want to use to filter results. You can pass a partial number to get all calls sent to numbers that start with the number you passed. */ + 'from'?: string; + /** Only include calls made to this number or address. You can pass a partial number to get all calls sent to numbers that start with the number you passed. */ + 'to'?: string; + /** Only include calls made from this trunk. */ + 'trunkId'?: string; + /** Filter calls based on `createTime`. You make the query more precise, fewer results will be returned. For example, 2021-02-01 will return all calls from the first of February 2021, and 2021-02-01T14:00:00Z will return all calls after 14:00 on the first of February. This field also supports <= and >= to search for calls in a range ?createTime>=2021-10-01&createTime<=2021-10-30 to get a list if calls for october 2021 It is also possible to submit partial dates for example createTime=2021-02 will return all calls for February ***Defaults to 24 hours*** ***Internal notes*** If a customer submits = and not <> we should add min and max for the date range psueodo sql ``` createTime = 2021-02-01 select * from calls where createTime >= 2021-02-01 and createTime <= 2021-02-01T23:59:59Z createTime = 2021-02-01T08 select * from calls where createTime >= 2021-02-01T08:00:00 and createTime <= 2021-02-01T08:59:59Z ``` but if they submit < or > we should just use the value they submitted and parse it a complete date */ + 'createTime'?: string; + /** only include calls by on the callResult(s), example callResult=COMPLETED will return all calls which have completed normally. */ + 'callResult'?: CallResult; + /** only include calls by on the direction(s), example direction=INBOUND,OUTBOUND will return all calls that are inbound or outbound. */ + 'direction'?: DirectionEnum; + /** The page you want to fetch */ + 'page'?: string; + /** The maximum number of items to return per request. The default is 100 and the maximum is 1000. If you need to export larger amounts and pagination is not suitable for you can use the Export function in the dashboard. */ + 'pageSize'?: number; +} diff --git a/packages/elastic-sip-trunking/src/models/v1/requests/index.ts b/packages/elastic-sip-trunking/src/models/v1/requests/index.ts index 980bcf7d..a24aea09 100644 --- a/packages/elastic-sip-trunking/src/models/v1/requests/index.ts +++ b/packages/elastic-sip-trunking/src/models/v1/requests/index.ts @@ -1,4 +1,5 @@ export * from './access-control-list/access-control-list-request-data'; +export * from './calls-history/calls-history-request-data'; export * from './country-permissions/country-permissions-request-data'; export * from './sip-endpoints/sip-endpoints-request-data'; export * from './sip-trunks/sip-trunks-request-data'; diff --git a/packages/elastic-sip-trunking/src/models/v1/sip-endpoint/sip-endpoint.ts b/packages/elastic-sip-trunking/src/models/v1/sip-endpoint/sip-endpoint.ts index abb45c38..156253fa 100644 --- a/packages/elastic-sip-trunking/src/models/v1/sip-endpoint/sip-endpoint.ts +++ b/packages/elastic-sip-trunking/src/models/v1/sip-endpoint/sip-endpoint.ts @@ -21,5 +21,5 @@ export interface SipEndpoint { /** The date and time that the SIP endpoint was created. */ createTime?: Date; /** The date and time that the SIP endpoint was last modified. */ - updateTime?: Date; + updateTime?: Date | null; } diff --git a/packages/elastic-sip-trunking/src/models/v1/sip-trunk/sip-trunk.ts b/packages/elastic-sip-trunking/src/models/v1/sip-trunk/sip-trunk.ts index 8bd1cc9b..31f9122d 100644 --- a/packages/elastic-sip-trunking/src/models/v1/sip-trunk/sip-trunk.ts +++ b/packages/elastic-sip-trunking/src/models/v1/sip-trunk/sip-trunk.ts @@ -21,7 +21,7 @@ export interface SipTrunk { /** The date and time that the SIP trunk was created. */ createTime?: Date; /** The date and time that the SIP trunk was last modified. */ - updateTime?: Date; + updateTime?: Date | null; /** The ID of the account. */ projectId?: string; } diff --git a/packages/elastic-sip-trunking/src/rest/v1/calls-history/calls-history-api.jest.fixture.ts b/packages/elastic-sip-trunking/src/rest/v1/calls-history/calls-history-api.jest.fixture.ts new file mode 100644 index 00000000..98322470 --- /dev/null +++ b/packages/elastic-sip-trunking/src/rest/v1/calls-history/calls-history-api.jest.fixture.ts @@ -0,0 +1,12 @@ +import { CallsHistoryApi } from './calls-history-api'; +import { Call, FindCallsRequestData } from '../../../models'; +import { ApiListPromise } from '@sinch/sdk-client'; + +export class CallsHistoryApiFixture implements Partial> { + + /** + * Fixture associated to function find + */ + public find: jest.Mock, [FindCallsRequestData]> = jest.fn(); +} + diff --git a/packages/elastic-sip-trunking/src/rest/v1/calls-history/calls-history-api.ts b/packages/elastic-sip-trunking/src/rest/v1/calls-history/calls-history-api.ts new file mode 100644 index 00000000..6c42951b --- /dev/null +++ b/packages/elastic-sip-trunking/src/rest/v1/calls-history/calls-history-api.ts @@ -0,0 +1,69 @@ +import { Call, FindCallsRequestData } from '../../../models'; +import { + RequestBody, + SinchClientParameters, + ApiListPromise, + PaginatedApiProperties, + PaginationEnum, + buildPageResultPromise, + createIteratorMethodsForPagination, +} from '@sinch/sdk-client'; +import { ElasticSipTrunkingDomainApi } from '../elastic-sip-trunking-domain-api'; + +export class CallsHistoryApi extends ElasticSipTrunkingDomainApi { + + /** + * Initialize your interface + * + * @param {SinchClientParameters} sinchClientParameters - The parameters used to initialize the API Client. + */ + constructor(sinchClientParameters: SinchClientParameters) { + super(sinchClientParameters, 'CallsHistoryApi'); + } + + /** + * Find calls + * Find calls by query parameters. + * @param { FindCallsRequestData } data - The data to provide to the API call. + * @return { ApiListPromise } + */ + public find(data: FindCallsRequestData): ApiListPromise { + this.client = this.getSinchClient(); + data['createTime'] = data['createTime'] !== undefined ? data['createTime'] : 'now-24h'; + const getParams = this.client.extractQueryParams(data, [ + 'from', 'to', 'trunkId', 'createTime', 'callResult', 'direction', 'page', 'pageSize']); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = ''; + const basePathUrl = `${this.client.apiClientOptions.hostname}/v1/projects/${this.client.apiClientOptions.projectId}/calls`; + + const requestOptionsPromise = this.client.prepareOptions(basePathUrl, 'GET', getParams, headers, body || undefined); + + const operationProperties: PaginatedApiProperties = { + pagination: PaginationEnum.PAGE2, + apiName: this.apiName, + operationId: 'FindCalls', + dataKey: 'calls', + }; + + // Create the promise containing the response wrapped as a PageResult + const listPromise = buildPageResultPromise( + this.client, + requestOptionsPromise, + operationProperties, + ); + + // Add properties to the Promise to offer the possibility to use it as an iterator + Object.assign( + listPromise, + createIteratorMethodsForPagination( + this.client, requestOptionsPromise, listPromise, operationProperties), + ); + + return listPromise as ApiListPromise; + } + +} diff --git a/packages/elastic-sip-trunking/src/rest/v1/calls-history/index.ts b/packages/elastic-sip-trunking/src/rest/v1/calls-history/index.ts new file mode 100644 index 00000000..2e3d0744 --- /dev/null +++ b/packages/elastic-sip-trunking/src/rest/v1/calls-history/index.ts @@ -0,0 +1,2 @@ +export * from './calls-history-api'; +export * from './calls-history-api.jest.fixture'; diff --git a/packages/elastic-sip-trunking/src/rest/v1/elastic-sip-trunking-domain-api.ts b/packages/elastic-sip-trunking/src/rest/v1/elastic-sip-trunking-domain-api.ts index 007eee92..79a5bef1 100644 --- a/packages/elastic-sip-trunking/src/rest/v1/elastic-sip-trunking-domain-api.ts +++ b/packages/elastic-sip-trunking/src/rest/v1/elastic-sip-trunking-domain-api.ts @@ -3,6 +3,7 @@ import { ApiClient, ApiFetchClient, buildOAuth2ApiClientOptions, + ELASTIC_SIP_TRUNKING_HOSTNAME, SinchClientParameters, UnifiedCredentials, } from '@sinch/sdk-client'; @@ -60,7 +61,8 @@ export class ElasticSipTrunkingDomainApi implements Api { if (!this.client) { const apiClientOptions = buildOAuth2ApiClientOptions(this.sinchClientParameters, 'Elastic SIP Trunking'); this.client = new ApiFetchClient(apiClientOptions); - this.client.apiClientOptions.hostname = this.sinchClientParameters.elasticSipTrunkingHostname ?? 'https://elastic-trunking.api.sinch.com'; + this.client.apiClientOptions.hostname = this.sinchClientParameters.elasticSipTrunkingHostname + ?? ELASTIC_SIP_TRUNKING_HOSTNAME; } return this.client; } diff --git a/packages/elastic-sip-trunking/src/rest/v1/elastic-sip-trunking-service.ts b/packages/elastic-sip-trunking/src/rest/v1/elastic-sip-trunking-service.ts index cfcc0c98..6d59e7d6 100644 --- a/packages/elastic-sip-trunking/src/rest/v1/elastic-sip-trunking-service.ts +++ b/packages/elastic-sip-trunking/src/rest/v1/elastic-sip-trunking-service.ts @@ -3,6 +3,7 @@ import { SipTrunksApi } from './sip-trunks'; import { AccessControlListApi } from './access-control-list'; import { SipEndpointsApi } from './sip-endpoints'; import { CountryPermissionsApi } from './country-permissions'; +import { CallsHistoryApi } from './calls-history'; export class ElasticSipTrunkingService { @@ -10,12 +11,14 @@ export class ElasticSipTrunkingService { public readonly sipEndpoints: SipEndpointsApi; public readonly accessControlList: AccessControlListApi; public readonly countryPermissions: CountryPermissionsApi; + public readonly calls: CallsHistoryApi; constructor(params: SinchClientParameters) { this.sipTrunks = new SipTrunksApi(params); this.sipEndpoints = new SipEndpointsApi(params); this.accessControlList = new AccessControlListApi(params); this.countryPermissions = new CountryPermissionsApi(params); + this.calls = new CallsHistoryApi(params); } /** @@ -28,5 +31,6 @@ export class ElasticSipTrunkingService { this.sipEndpoints.setHostname(hostname); this.accessControlList.setHostname(hostname); this.countryPermissions.setHostname(hostname); + this.calls.setHostname(hostname); } } diff --git a/packages/elastic-sip-trunking/src/rest/v1/index.ts b/packages/elastic-sip-trunking/src/rest/v1/index.ts index f5db553a..c0b3d2a9 100644 --- a/packages/elastic-sip-trunking/src/rest/v1/index.ts +++ b/packages/elastic-sip-trunking/src/rest/v1/index.ts @@ -1,4 +1,5 @@ export * from './access-control-list'; +export * from './calls-history'; export * from './country-permissions'; export * from './sip-endpoints'; export * from './sip-trunks'; diff --git a/packages/elastic-sip-trunking/src/rest/v1/sip-trunks/sip-trunks-api.ts b/packages/elastic-sip-trunking/src/rest/v1/sip-trunks/sip-trunks-api.ts index 7b59645b..22c32b60 100644 --- a/packages/elastic-sip-trunking/src/rest/v1/sip-trunks/sip-trunks-api.ts +++ b/packages/elastic-sip-trunking/src/rest/v1/sip-trunks/sip-trunks-api.ts @@ -243,7 +243,7 @@ export class SipTrunksApi extends ElasticSipTrunkingDomainApi { pagination: PaginationEnum.PAGE2, apiName: this.apiName, operationId: 'GetSipTrunks', - dataKey: 'sipTrunks', + dataKey: 'trunks', }; // Create the promise containing the response wrapped as a PageResult diff --git a/packages/elastic-sip-trunking/tests/rest/v1/calls-history/calls-history-api.test.ts b/packages/elastic-sip-trunking/tests/rest/v1/calls-history/calls-history-api.test.ts new file mode 100644 index 00000000..5801b35f --- /dev/null +++ b/packages/elastic-sip-trunking/tests/rest/v1/calls-history/calls-history-api.test.ts @@ -0,0 +1,68 @@ +import { SinchClientParameters } from '@sinch/sdk-client'; +import { CallsHistoryApi, CallsHistoryApiFixture, ElasticSipTrunking } from '../../../../src'; + +describe('CallsApi', () => { + let callsApi: CallsHistoryApi; + let fixture: CallsHistoryApiFixture; + let credentials: SinchClientParameters; + + beforeEach(() => { + fixture = new CallsHistoryApiFixture(); + credentials = { + projectId: 'PROJECT_ID', + keyId: 'KEY_ID', + keySecret: 'KEY_SECRET', + }; + callsApi = new CallsHistoryApi(credentials); + }); + + + describe ('findCalls', () => { + it('should make a GET request to find calls by query parameters', async () => { + // Given + const requestData: ElasticSipTrunking.FindCallsRequestData = { + trunkId: 'dFeDe67-09d5-49d5-b469-e1fc2cb163c7', + }; + const mockData: ElasticSipTrunking.Call[] = [ + { + callId: '01AQ3D80ZKSSK35TZFKM3JG9CT', + to: '+15551239898', + from: '+14155553434', + direction: 'INBOUND', + answerTime: new Date('2021-11-01T23:26:50Z'), + endTime: new Date('2021-11-01T23:27:35Z'), + durationSeconds: 45, + callResult: 'COMPLETED', + pricePerMinute: { + currencyCode: 'USD', + amount: '0.0040', + }, + billingDurationSeconds: 60, + price: { + currencyCode: 'USD', + amount: '0.0040', + }, + createTime: new Date('2021-11-01T23:20:50Z'), + projectId: '1bf62742-7b84-4666-9cbe-8e5734fd57d0', + trunkId: 'dFeDe67-09d5-49d5-b469-e1fc2cb163c7', + }, + ]; + const expectedResponse = { + data: mockData, + hasNextPage: false, + nextPageValue: '', + nextPage: jest.fn(), + }; + + // When + fixture.find.mockResolvedValue(expectedResponse); + callsApi.find = fixture.find; + const response = await callsApi.find(requestData); + + // Then + expect(response).toEqual(expectedResponse); + expect(response.data).toBeDefined(); + expect(fixture.find).toHaveBeenCalledWith(requestData); + }); + }); +}); diff --git a/packages/elastic-sip-trunking/tests/rest/v1/elastic-sip-trunking-domain-api.test.ts b/packages/elastic-sip-trunking/tests/rest/v1/elastic-sip-trunking-domain-api.test.ts new file mode 100644 index 00000000..37713c3e --- /dev/null +++ b/packages/elastic-sip-trunking/tests/rest/v1/elastic-sip-trunking-domain-api.test.ts @@ -0,0 +1,37 @@ +import { ElasticSipTrunkingDomainApi } from '../../../src/rest/v1/elastic-sip-trunking-domain-api'; +import { ApiHostname, UnifiedCredentials } from '@sinch/sdk-client'; + +describe('Elastic SIP Trunking API', () => { + let elasticSipTrunkingApi: ElasticSipTrunkingDomainApi; + let params: UnifiedCredentials & Pick; + const CUSTOM_HOSTNAME = 'https://new.host.name'; + + beforeEach(() => { + params = { + projectId: 'PROJECT_ID', + keyId: 'KEY_ID', + keySecret: 'KEY_SECRET', + }; + }); + + it('should initialize the client with the default hostname', () => { + elasticSipTrunkingApi = new ElasticSipTrunkingDomainApi(params, 'dummy'); + elasticSipTrunkingApi.getSinchClient(); + expect(elasticSipTrunkingApi.client).toBeDefined(); + expect(elasticSipTrunkingApi.client?.apiClientOptions.hostname).toBe('https://elastic-trunking.api.sinch.com'); + }); + + it('should use the hostname parameter', () => { + params.elasticSipTrunkingHostname = CUSTOM_HOSTNAME; + elasticSipTrunkingApi = new ElasticSipTrunkingDomainApi(params, 'dummy'); + elasticSipTrunkingApi.getSinchClient(); + expect(elasticSipTrunkingApi.client?.apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); + }); + + it('should set a custom URL', () => { + elasticSipTrunkingApi = new ElasticSipTrunkingDomainApi(params, 'dummy'); + elasticSipTrunkingApi.setHostname(CUSTOM_HOSTNAME); + expect(elasticSipTrunkingApi.client).toBeDefined(); + expect(elasticSipTrunkingApi.client?.apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); + }); +}); diff --git a/packages/elastic-sip-trunking/tests/rest/v1/elastic-sip-trunking-service.test.ts b/packages/elastic-sip-trunking/tests/rest/v1/elastic-sip-trunking-service.test.ts new file mode 100644 index 00000000..c4aacf27 --- /dev/null +++ b/packages/elastic-sip-trunking/tests/rest/v1/elastic-sip-trunking-service.test.ts @@ -0,0 +1,62 @@ +import { SinchClientParameters } from '@sinch/sdk-client'; +import { + AccessControlListApi, CallsHistoryApi, + CountryPermissionsApi, + ElasticSipTrunkingService, + SipEndpointsApi, + SipTrunksApi, +} from '../../../src'; + +describe('Elastic SIP Trunking Service', () => { + const DEFAULT_HOSTNAME = 'https://elastic-trunking.api.sinch.com'; + const CUSTOM_HOSTNAME = 'https://new.host.name'; + + it('should initialize the APIs', () => { + // Given + const params: SinchClientParameters = { + projectId: 'PROJECT_ID', + keyId: 'KEY_ID', + keySecret: 'KEY_SECRET', + }; + + // When + const elasticSipTrunkingService = new ElasticSipTrunkingService(params); + + // Then + expect(elasticSipTrunkingService.sipTrunks).toBeInstanceOf(SipTrunksApi); + expect(elasticSipTrunkingService.sipEndpoints).toBeInstanceOf(SipEndpointsApi); + expect(elasticSipTrunkingService.accessControlList).toBeInstanceOf(AccessControlListApi); + expect(elasticSipTrunkingService.countryPermissions).toBeInstanceOf(CountryPermissionsApi); + expect(elasticSipTrunkingService.calls).toBeInstanceOf(CallsHistoryApi); + expect(elasticSipTrunkingService.sipTrunks.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); + expect(elasticSipTrunkingService.sipEndpoints.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); + expect(elasticSipTrunkingService.accessControlList.getSinchClient().apiClientOptions.hostname) + .toBe(DEFAULT_HOSTNAME); + expect(elasticSipTrunkingService.countryPermissions.getSinchClient().apiClientOptions.hostname) + .toBe(DEFAULT_HOSTNAME); + expect(elasticSipTrunkingService.calls.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); + }); + + it('should set a custom hostname for all AOPIs', () => { + // Given + const params: SinchClientParameters = { + projectId: 'PROJECT_ID', + keyId: 'KEY_ID', + keySecret: 'KEY_SECRET', + }; + const elasticSipTrunkingService = new ElasticSipTrunkingService(params); + + // When + elasticSipTrunkingService.setHostname(CUSTOM_HOSTNAME); + + // Then + expect(elasticSipTrunkingService.sipTrunks.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); + expect(elasticSipTrunkingService.sipEndpoints.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); + expect(elasticSipTrunkingService.accessControlList.getSinchClient().apiClientOptions.hostname) + .toBe(CUSTOM_HOSTNAME); + expect(elasticSipTrunkingService.countryPermissions.getSinchClient().apiClientOptions.hostname) + .toBe(CUSTOM_HOSTNAME); + expect(elasticSipTrunkingService.calls.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); + }); + +}); diff --git a/packages/fax/src/rest/v3/fax-domain-api.ts b/packages/fax/src/rest/v3/fax-domain-api.ts index a7da0d86..fa159003 100644 --- a/packages/fax/src/rest/v3/fax-domain-api.ts +++ b/packages/fax/src/rest/v3/fax-domain-api.ts @@ -3,7 +3,9 @@ import { ApiClient, ApiFetchClient, buildOAuth2ApiClientOptions, + FAX_HOSTNAME, FaxRegion, + formatRegionalizedHostname, SinchClientParameters, SupportedFaxRegion, UnifiedCredentials, @@ -84,7 +86,7 @@ export class FaxDomainApi implements Api { private buildHostname(region: FaxRegion) { const formattedRegion = region !== '' ? `${region}.` : ''; - return `https://${formattedRegion}fax.api.sinch.com`; + return formatRegionalizedHostname(FAX_HOSTNAME, formattedRegion); } } diff --git a/packages/numbers/src/models/v1/active-number-request/active-number-request.ts b/packages/numbers/src/models/v1/active-number-request/active-number-request.ts index e85c00f6..a93f2e63 100644 --- a/packages/numbers/src/models/v1/active-number-request/active-number-request.ts +++ b/packages/numbers/src/models/v1/active-number-request/active-number-request.ts @@ -1,10 +1,3 @@ -/** - * Model: ActiveNumberRequest - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { SMSConfiguration } from '../sms-configuration'; import { VoiceConfiguration } from '../voice-configuration'; diff --git a/packages/numbers/src/models/v1/active-number/active-number.ts b/packages/numbers/src/models/v1/active-number/active-number.ts index 6495febf..132fbf9b 100644 --- a/packages/numbers/src/models/v1/active-number/active-number.ts +++ b/packages/numbers/src/models/v1/active-number/active-number.ts @@ -1,10 +1,3 @@ -/** - * Model: ActiveNumber - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { Money } from '../money'; import { SMSConfiguration } from '../sms-configuration'; import { VoiceConfiguration } from '../voice-configuration'; diff --git a/packages/numbers/src/models/v1/active-numbers-response/active-numbers-response.ts b/packages/numbers/src/models/v1/active-numbers-response/active-numbers-response.ts index 227bbf7e..14769f9e 100644 --- a/packages/numbers/src/models/v1/active-numbers-response/active-numbers-response.ts +++ b/packages/numbers/src/models/v1/active-numbers-response/active-numbers-response.ts @@ -1,10 +1,3 @@ -/** - * Model: ActiveNumbersResponse - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { ActiveNumber } from '../active-number'; /** diff --git a/packages/numbers/src/models/v1/available-number/available-number.ts b/packages/numbers/src/models/v1/available-number/available-number.ts index ddd1d072..6993ce82 100644 --- a/packages/numbers/src/models/v1/available-number/available-number.ts +++ b/packages/numbers/src/models/v1/available-number/available-number.ts @@ -1,10 +1,3 @@ -/** - * Model: AvailableNumber - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { Money } from '../money'; /** diff --git a/packages/numbers/src/models/v1/available-numbers-response/available-numbers-response.ts b/packages/numbers/src/models/v1/available-numbers-response/available-numbers-response.ts index 136ef00c..4ade5a5d 100644 --- a/packages/numbers/src/models/v1/available-numbers-response/available-numbers-response.ts +++ b/packages/numbers/src/models/v1/available-numbers-response/available-numbers-response.ts @@ -1,10 +1,3 @@ -/** - * Model: AvailableNumbersResponse - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { AvailableNumber } from '../available-number'; /** diff --git a/packages/numbers/src/models/v1/available-region/available-region.ts b/packages/numbers/src/models/v1/available-region/available-region.ts index 38852ce7..f4034aed 100644 --- a/packages/numbers/src/models/v1/available-region/available-region.ts +++ b/packages/numbers/src/models/v1/available-region/available-region.ts @@ -1,10 +1,3 @@ -/** - * Model: AvailableRegion - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - /** * A region for which numbers are provided. */ diff --git a/packages/numbers/src/models/v1/bad-request/bad-request.ts b/packages/numbers/src/models/v1/bad-request/bad-request.ts index cfb192d5..80709747 100644 --- a/packages/numbers/src/models/v1/bad-request/bad-request.ts +++ b/packages/numbers/src/models/v1/bad-request/bad-request.ts @@ -1,10 +1,3 @@ -/** - * Model: BadRequest - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { FieldViolation } from '../field-violation'; export interface BadRequest { diff --git a/packages/numbers/src/models/v1/callback-configuration-update/callback-configuration-update.ts b/packages/numbers/src/models/v1/callback-configuration-update/callback-configuration-update.ts index a6d69a28..aab07b0b 100644 --- a/packages/numbers/src/models/v1/callback-configuration-update/callback-configuration-update.ts +++ b/packages/numbers/src/models/v1/callback-configuration-update/callback-configuration-update.ts @@ -1,10 +1,3 @@ -/** - * Model: CallbackConfigurationUpdate - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - /** * The request to update the callbacks configuration for the current project */ diff --git a/packages/numbers/src/models/v1/callback-configuration/callback-configuration.ts b/packages/numbers/src/models/v1/callback-configuration/callback-configuration.ts index de7ba74f..8f342b29 100644 --- a/packages/numbers/src/models/v1/callback-configuration/callback-configuration.ts +++ b/packages/numbers/src/models/v1/callback-configuration/callback-configuration.ts @@ -1,10 +1,3 @@ -/** - * Model: CallbackConfiguration - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - /** * Response message containing the callbacks configuration for a specific project */ diff --git a/packages/numbers/src/models/v1/callback-payload/callback-payload.ts b/packages/numbers/src/models/v1/callback-payload/callback-payload.ts index ef12cc83..b47d1270 100644 --- a/packages/numbers/src/models/v1/callback-payload/callback-payload.ts +++ b/packages/numbers/src/models/v1/callback-payload/callback-payload.ts @@ -1,11 +1,3 @@ -/** - * Model: CallbackPayload - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - - export interface CallbackPayload { /** The ID of the event. */ diff --git a/packages/numbers/src/models/v1/field-violation/field-violation.ts b/packages/numbers/src/models/v1/field-violation/field-violation.ts index eccf3dda..bf33b23d 100644 --- a/packages/numbers/src/models/v1/field-violation/field-violation.ts +++ b/packages/numbers/src/models/v1/field-violation/field-violation.ts @@ -1,10 +1,3 @@ -/** - * Model: FieldViolation - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - export interface FieldViolation { field?: string; description?: string; diff --git a/packages/numbers/src/models/v1/internal-error-error/internal-error-error.ts b/packages/numbers/src/models/v1/internal-error-error/internal-error-error.ts index 50af5acf..d48652d0 100644 --- a/packages/numbers/src/models/v1/internal-error-error/internal-error-error.ts +++ b/packages/numbers/src/models/v1/internal-error-error/internal-error-error.ts @@ -1,10 +1,3 @@ -/** - * Model: InternalErrorError - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - export interface InternalErrorError { /** @see CodeEnum */ code?: CodeEnum; diff --git a/packages/numbers/src/models/v1/internal-error/internal-error.ts b/packages/numbers/src/models/v1/internal-error/internal-error.ts index dd20b941..d0084679 100644 --- a/packages/numbers/src/models/v1/internal-error/internal-error.ts +++ b/packages/numbers/src/models/v1/internal-error/internal-error.ts @@ -1,10 +1,3 @@ -/** - * Model: InternalError - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { InternalErrorError } from '../internal-error-error'; export interface InternalError { diff --git a/packages/numbers/src/models/v1/invalid-argument-error/invalid-argument-error.ts b/packages/numbers/src/models/v1/invalid-argument-error/invalid-argument-error.ts index 2f7f99ad..d32eae7b 100644 --- a/packages/numbers/src/models/v1/invalid-argument-error/invalid-argument-error.ts +++ b/packages/numbers/src/models/v1/invalid-argument-error/invalid-argument-error.ts @@ -1,10 +1,3 @@ -/** - * Model: InvalidArgumentError - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { BadRequest } from '../bad-request'; export interface InvalidArgumentError { diff --git a/packages/numbers/src/models/v1/invalid-argument/invalid-argument.ts b/packages/numbers/src/models/v1/invalid-argument/invalid-argument.ts index 08675ecb..7a397871 100644 --- a/packages/numbers/src/models/v1/invalid-argument/invalid-argument.ts +++ b/packages/numbers/src/models/v1/invalid-argument/invalid-argument.ts @@ -1,10 +1,3 @@ -/** - * Model: InvalidArgument - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { InvalidArgumentError } from '../invalid-argument-error'; export interface InvalidArgument { diff --git a/packages/numbers/src/models/v1/list-available-number-request/list-available-number-request.ts b/packages/numbers/src/models/v1/list-available-number-request/list-available-number-request.ts index 89f4c22c..84f66787 100644 --- a/packages/numbers/src/models/v1/list-available-number-request/list-available-number-request.ts +++ b/packages/numbers/src/models/v1/list-available-number-request/list-available-number-request.ts @@ -1,10 +1,3 @@ -/** - * Model: ListAvailableNumberRequest - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { NumberPatternPattern } from '../number-pattern-pattern'; import { NumberPatternSearchPattern } from '../number-pattern-search-pattern'; diff --git a/packages/numbers/src/models/v1/list-available-regions-response/list-available-regions-response.ts b/packages/numbers/src/models/v1/list-available-regions-response/list-available-regions-response.ts index 94330c3c..991477bb 100644 --- a/packages/numbers/src/models/v1/list-available-regions-response/list-available-regions-response.ts +++ b/packages/numbers/src/models/v1/list-available-regions-response/list-available-regions-response.ts @@ -1,10 +1,3 @@ -/** - * Model: ListAvailableRegionsResponse - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { AvailableRegion } from '../available-region'; /** diff --git a/packages/numbers/src/models/v1/money/money.ts b/packages/numbers/src/models/v1/money/money.ts index dbd14246..ba23ee76 100644 --- a/packages/numbers/src/models/v1/money/money.ts +++ b/packages/numbers/src/models/v1/money/money.ts @@ -1,10 +1,3 @@ -/** - * Model: Money - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - /** * An object giving details on currency code and the amount charged. */ diff --git a/packages/numbers/src/models/v1/not-found-error/not-found-error.ts b/packages/numbers/src/models/v1/not-found-error/not-found-error.ts index ba8224f8..1ecb2804 100644 --- a/packages/numbers/src/models/v1/not-found-error/not-found-error.ts +++ b/packages/numbers/src/models/v1/not-found-error/not-found-error.ts @@ -1,10 +1,3 @@ -/** - * Model: NotFoundError - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - export interface NotFoundError { /** @see CodeEnum */ code?: CodeEnum; diff --git a/packages/numbers/src/models/v1/not-found/not-found.ts b/packages/numbers/src/models/v1/not-found/not-found.ts index 923aa48c..10d34b15 100644 --- a/packages/numbers/src/models/v1/not-found/not-found.ts +++ b/packages/numbers/src/models/v1/not-found/not-found.ts @@ -1,10 +1,3 @@ -/** - * Model: NotFound - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { NotFoundError } from '../not-found-error'; export interface NotFound { diff --git a/packages/numbers/src/models/v1/number-pattern-pattern/number-pattern-pattern.ts b/packages/numbers/src/models/v1/number-pattern-pattern/number-pattern-pattern.ts index c29f826d..8c653707 100644 --- a/packages/numbers/src/models/v1/number-pattern-pattern/number-pattern-pattern.ts +++ b/packages/numbers/src/models/v1/number-pattern-pattern/number-pattern-pattern.ts @@ -1,10 +1,3 @@ -/** - * Model: NumberPatternPattern - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { SearchPattern } from '../search-pattern'; /** diff --git a/packages/numbers/src/models/v1/number-pattern-search-pattern/number-pattern-search-pattern.ts b/packages/numbers/src/models/v1/number-pattern-search-pattern/number-pattern-search-pattern.ts index 9d5aabf2..729263af 100644 --- a/packages/numbers/src/models/v1/number-pattern-search-pattern/number-pattern-search-pattern.ts +++ b/packages/numbers/src/models/v1/number-pattern-search-pattern/number-pattern-search-pattern.ts @@ -1,10 +1,3 @@ -/** - * Model: NumberPatternSearchPattern - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - /** * Search pattern to apply. Options include, `START`, `CONTAIN`, and `END`. */ diff --git a/packages/numbers/src/models/v1/provisioning-status/provisioning-status.ts b/packages/numbers/src/models/v1/provisioning-status/provisioning-status.ts index 46ad6f18..55bacee5 100644 --- a/packages/numbers/src/models/v1/provisioning-status/provisioning-status.ts +++ b/packages/numbers/src/models/v1/provisioning-status/provisioning-status.ts @@ -1,10 +1,3 @@ -/** - * Model: ProvisioningStatus - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - /** * The provisioning status. It will be either `WAITING`, `IN_PROGRESS` or `FAILED`. If the provisioning fails, a reason for the failure will be provided. */ diff --git a/packages/numbers/src/models/v1/rent-any-number-request-sms-configuration/rent-any-number-request-sms-configuration.ts b/packages/numbers/src/models/v1/rent-any-number-request-sms-configuration/rent-any-number-request-sms-configuration.ts index 8b55a3a6..c69bef29 100644 --- a/packages/numbers/src/models/v1/rent-any-number-request-sms-configuration/rent-any-number-request-sms-configuration.ts +++ b/packages/numbers/src/models/v1/rent-any-number-request-sms-configuration/rent-any-number-request-sms-configuration.ts @@ -1,10 +1,3 @@ -/** - * Model: RentAnyNumberRequestSmsConfiguration - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - export interface RentAnyNumberRequestSmsConfiguration { /** The SMS service that the number will be linked to. The `servicePlanId` can be found in the [Sinch Customer Dashboard](https://dashboard.sinch.com/sms/api/rest). */ servicePlanId: string; diff --git a/packages/numbers/src/models/v1/rent-any-number-request-voice-configuration/rent-any-number-request-voice-configuration.ts b/packages/numbers/src/models/v1/rent-any-number-request-voice-configuration/rent-any-number-request-voice-configuration.ts index ae946bf8..721abdae 100644 --- a/packages/numbers/src/models/v1/rent-any-number-request-voice-configuration/rent-any-number-request-voice-configuration.ts +++ b/packages/numbers/src/models/v1/rent-any-number-request-voice-configuration/rent-any-number-request-voice-configuration.ts @@ -1,10 +1,3 @@ -/** - * Model: RentAnyNumberRequestVoiceConfiguration - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - export interface RentAnyNumberRequestVoiceConfiguration { /** Your app ID for the Voice API. The `appId` can be found in your Sinch Customer Dashboard under Voice, then apps. */ appId: string; diff --git a/packages/numbers/src/models/v1/rent-any-number-request/rent-any-number-request.ts b/packages/numbers/src/models/v1/rent-any-number-request/rent-any-number-request.ts index 29fe71d9..c7978199 100644 --- a/packages/numbers/src/models/v1/rent-any-number-request/rent-any-number-request.ts +++ b/packages/numbers/src/models/v1/rent-any-number-request/rent-any-number-request.ts @@ -1,10 +1,3 @@ -/** - * Model: RentAnyNumberRequest - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { RentAnyNumberRequestSmsConfiguration } from '../rent-any-number-request-sms-configuration'; import { RentAnyNumberRequestVoiceConfiguration } from '../rent-any-number-request-voice-configuration'; import { SearchPattern } from '../search-pattern'; diff --git a/packages/numbers/src/models/v1/rent-number-request/rent-number-request.ts b/packages/numbers/src/models/v1/rent-number-request/rent-number-request.ts index 57ab0aac..5c1b6bf0 100644 --- a/packages/numbers/src/models/v1/rent-number-request/rent-number-request.ts +++ b/packages/numbers/src/models/v1/rent-number-request/rent-number-request.ts @@ -1,10 +1,3 @@ -/** - * Model: RentNumberRequest - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { RentAnyNumberRequestSmsConfiguration } from '../rent-any-number-request-sms-configuration'; import { RentAnyNumberRequestVoiceConfiguration } from '../rent-any-number-request-voice-configuration'; diff --git a/packages/numbers/src/models/v1/scheduled-provisioning/scheduled-provisioning.ts b/packages/numbers/src/models/v1/scheduled-provisioning/scheduled-provisioning.ts index 017b5245..e2b6610f 100644 --- a/packages/numbers/src/models/v1/scheduled-provisioning/scheduled-provisioning.ts +++ b/packages/numbers/src/models/v1/scheduled-provisioning/scheduled-provisioning.ts @@ -1,10 +1,3 @@ -/** - * Model: ScheduledProvisioning - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { ProvisioningStatus } from '../provisioning-status'; import { SmsErrorCode } from '../sms-error-code'; 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..c8e8fe45 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; + /** The type of voice configuration. Default is `RTC`. */ + type: 'RTC' | 'EST' | 'FAX'; + /** The trunk ID for the EST voice configuration. The `trunkId` can be found in your Sinch Customer Dashboard under sip, then trunks.*/ + trunkId?: string; + /** The service ID for the FAX configuration. The `serviceId` can be found in your Sinch Customer Dashboard under fax, then services.*/ + serviceId?: string; } diff --git a/packages/numbers/src/models/v1/search-pattern/search-pattern.ts b/packages/numbers/src/models/v1/search-pattern/search-pattern.ts index dbe3d555..b49108b7 100644 --- a/packages/numbers/src/models/v1/search-pattern/search-pattern.ts +++ b/packages/numbers/src/models/v1/search-pattern/search-pattern.ts @@ -1,9 +1,3 @@ -/** - * Model: SearchPattern - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ import { SearchPatternEnum } from '../enums'; export interface SearchPattern { diff --git a/packages/numbers/src/models/v1/sms-configuration/sms-configuration.ts b/packages/numbers/src/models/v1/sms-configuration/sms-configuration.ts index 318ba196..30bc8b08 100644 --- a/packages/numbers/src/models/v1/sms-configuration/sms-configuration.ts +++ b/packages/numbers/src/models/v1/sms-configuration/sms-configuration.ts @@ -1,10 +1,3 @@ -/** - * Model: SMSConfiguration - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { ScheduledProvisioning } from '../scheduled-provisioning'; /** diff --git a/packages/numbers/src/models/v1/sms-error-code/sms-error-code.ts b/packages/numbers/src/models/v1/sms-error-code/sms-error-code.ts index 5562854f..3c7cbd78 100644 --- a/packages/numbers/src/models/v1/sms-error-code/sms-error-code.ts +++ b/packages/numbers/src/models/v1/sms-error-code/sms-error-code.ts @@ -1,10 +1,3 @@ -/** - * Model: SmsErrorCode - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - /** * The error codes that show the reason of failure of a scheduled provisioning */ 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..92b5bbdb 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; + /** The type of voice configuration. Default is `RTC`. */ + type: 'RTC' | 'EST' | 'FAX'; + /** The trunk ID for the EST voice configuration. The `trunkId` can be found in your Sinch Customer Dashboard under sip, then trunks.*/ + trunkId?: string; + /** The service ID for the FAX configuration. The `serviceId` can be found in your Sinch Customer Dashboard under fax, then services.*/ + serviceId?: string; } diff --git a/packages/numbers/src/rest/v1/numbers-domain-api.ts b/packages/numbers/src/rest/v1/numbers-domain-api.ts index 255ea28c..ba483746 100644 --- a/packages/numbers/src/rest/v1/numbers-domain-api.ts +++ b/packages/numbers/src/rest/v1/numbers-domain-api.ts @@ -3,6 +3,7 @@ import { ApiClient, ApiFetchClient, buildOAuth2ApiClientOptions, + NUMBERS_HOSTNAME, SinchClientParameters, UnifiedCredentials, } from '@sinch/sdk-client'; @@ -60,7 +61,7 @@ export class NumbersDomainApi implements Api { if (!this.client) { const apiClientOptions = buildOAuth2ApiClientOptions(this.sinchClientParameters, 'Numbers'); this.client = new ApiFetchClient(apiClientOptions); - this.client.apiClientOptions.hostname = this.sinchClientParameters.numbersHostname ?? 'https://numbers.api.sinch.com'; + this.client.apiClientOptions.hostname = this.sinchClientParameters.numbersHostname ?? NUMBERS_HOSTNAME; } return this.client; } 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: '', }; 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 e954c06d..61df75bd 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 @@ -114,6 +114,12 @@ describe('AvailableNumberApi', () => { searchPattern: 'START', }, capabilities: ['SMS', 'VOICE'], + smsConfiguration: { + servicePlanId: 'servicePlanIdFromSinchDashboard', + }, + voiceConfiguration: { + appId: 'appIdFromSinchDashboard', + }, }, }; const expectedResponse: Numbers.ActiveNumber = { @@ -136,7 +142,7 @@ describe('AvailableNumberApi', () => { smsConfiguration: { servicePlanId: '', scheduledProvisioning: { - servicePlanId: 'a4c187cffc754d2da37f594d46f35246', + servicePlanId: 'servicePlanIdFromSinchDashboard', status: 'WAITING', lastUpdatedTime: new Date('2023-11-21T17:47:52.950101Z'), campaignId: '', @@ -146,8 +152,18 @@ describe('AvailableNumberApi', () => { }, voiceConfiguration: { appId: '', - scheduledVoiceProvisioning: null, + scheduledVoiceProvisioning: { + appId: 'appIdFromSinchDashboard', + status: 'WAITING', + lastUpdatedTime: new Date('2023-11-21T17:47:52.950101Z'), + type: 'RTC', + trunkId: '', + serviceId: '', + }, lastUpdatedTime: null, + type: 'RTC', + trunkId: '', + serviceId: '', }, callbackUrl: '', }; @@ -172,6 +188,9 @@ describe('AvailableNumberApi', () => { smsConfiguration: { servicePlanId: 'servicePlanIdFromSinchDashboard', }, + voiceConfiguration: { + appId: 'appIdFromSinchDashboard', + }, }, }; const expectedResponse: Numbers.ActiveNumber = { @@ -194,7 +213,7 @@ describe('AvailableNumberApi', () => { smsConfiguration: { servicePlanId: '', scheduledProvisioning: { - servicePlanId: 'a4c187cffc754d2da37f594d46f35246', + servicePlanId: 'servicePlanIdFromSinchDashboard', status: 'WAITING', lastUpdatedTime: new Date('2023-11-21T17:47:52.950101Z'), campaignId: '', @@ -204,8 +223,18 @@ describe('AvailableNumberApi', () => { }, voiceConfiguration: { appId: '', - scheduledVoiceProvisioning: null, + scheduledVoiceProvisioning: { + appId: 'appIdFromSinchDashboard', + status: 'WAITING', + lastUpdatedTime: new Date('2023-11-21T17:47:52.950101Z'), + type: 'RTC', + trunkId: '', + serviceId: '', + }, lastUpdatedTime: null, + type: 'RTC', + trunkId: '', + serviceId: '', }, callbackUrl: '', }; diff --git a/packages/sdk-client/src/domain/domain-helper.ts b/packages/sdk-client/src/domain/domain-helper.ts new file mode 100644 index 00000000..3a63f187 --- /dev/null +++ b/packages/sdk-client/src/domain/domain-helper.ts @@ -0,0 +1,16 @@ +export const REGION_PATTERN = '{region}'; + +export const AUTH_HOSTNAME = 'https://auth.sinch.com'; +export const CONVERSATION_HOSTNAME = `https://${REGION_PATTERN}conversation.api.sinch.com`; +export const CONVERSATION_TEMPLATES_HOSTNAME = `https://${REGION_PATTERN}template.api.sinch.com`; +export const ELASTIC_SIP_TRUNKING_HOSTNAME = 'https://elastic-trunking.api.sinch.com'; +export const FAX_HOSTNAME = `https://${REGION_PATTERN}fax.api.sinch.com`; +export const NUMBERS_HOSTNAME = 'https://numbers.api.sinch.com'; +export const SMS_HOSTNAME = `https://${REGION_PATTERN}sms.api.sinch.com`;; +export const VERIFICATION_HOSTNAME = 'https://verification.api.sinch.com'; +export const VOICE_HOSTNAME = `https://calling${REGION_PATTERN}.api.sinch.com`; +export const VOICE_APPLICATION_MANAGEMENT_HOSTNAME = 'https://callingapi.sinch.com'; + +export const formatRegionalizedHostname = (hostnamePattern: string, region: string) => { + return hostnamePattern.replace(REGION_PATTERN, region); +}; diff --git a/packages/sdk-client/src/domain/index.ts b/packages/sdk-client/src/domain/index.ts index e4e7e49c..a5c2e9fc 100644 --- a/packages/sdk-client/src/domain/index.ts +++ b/packages/sdk-client/src/domain/index.ts @@ -1 +1,2 @@ +export * from './domain-helper'; export * from './domain-interface'; diff --git a/packages/sdk-client/src/plugins/oauth2/oauth2-token.request.ts b/packages/sdk-client/src/plugins/oauth2/oauth2-token.request.ts index 95c64ff4..fc691217 100644 --- a/packages/sdk-client/src/plugins/oauth2/oauth2-token.request.ts +++ b/packages/sdk-client/src/plugins/oauth2/oauth2-token.request.ts @@ -5,6 +5,7 @@ import { ApiClient } from '../../api/api-client'; import { OAuth2Api } from './oauth2-api'; import { BasicAuthenticationRequest } from '../basicAuthentication'; import { ApiFetchClient } from '../../client/api-fetch-client'; +import { AUTH_HOSTNAME } from '../../domain'; export class Oauth2TokenRequest implements RequestPlugin { private readonly apiClient: ApiClient; @@ -25,7 +26,7 @@ export class Oauth2TokenRequest implements RequestPlugin { clientSecret, ); if (!authenticationUrl) { - authenticationUrl = 'https://auth.sinch.com'; + authenticationUrl = AUTH_HOSTNAME; } this.apiClient = new ApiFetchClient({ hostname: authenticationUrl, diff --git a/packages/sdk-client/tests/domain/domain-helper.test.ts b/packages/sdk-client/tests/domain/domain-helper.test.ts new file mode 100644 index 00000000..b866c47f --- /dev/null +++ b/packages/sdk-client/tests/domain/domain-helper.test.ts @@ -0,0 +1,51 @@ +import { + AUTH_HOSTNAME, + CONVERSATION_HOSTNAME, + CONVERSATION_TEMPLATES_HOSTNAME, + ELASTIC_SIP_TRUNKING_HOSTNAME, + FAX_HOSTNAME, + NUMBERS_HOSTNAME, + formatRegionalizedHostname, + SMS_HOSTNAME, + VERIFICATION_HOSTNAME, + VOICE_APPLICATION_MANAGEMENT_HOSTNAME, + VOICE_HOSTNAME, +} from '../../src'; + +describe('Domain Helper', () => { + + it('should format the hostname with the given region', () => { + const formattedConversationHostname = formatRegionalizedHostname(CONVERSATION_HOSTNAME, 'bzh.'); + expect(formattedConversationHostname).toBe('https://bzh.conversation.api.sinch.com'); + + const formattedConversationTemplatesHostname = formatRegionalizedHostname(CONVERSATION_TEMPLATES_HOSTNAME, 'bzh.'); + expect(formattedConversationTemplatesHostname).toBe('https://bzh.template.api.sinch.com'); + + const formattedFaxHostname = formatRegionalizedHostname(FAX_HOSTNAME, 'bzh.'); + expect(formattedFaxHostname).toBe('https://bzh.fax.api.sinch.com'); + + const formattedSmsHostname = formatRegionalizedHostname(SMS_HOSTNAME, 'bzh.'); + expect(formattedSmsHostname).toBe('https://bzh.sms.api.sinch.com'); + + const formattedVoiceHostname = formatRegionalizedHostname(VOICE_HOSTNAME, '-bzh'); + expect(formattedVoiceHostname).toBe('https://calling-bzh.api.sinch.com'); + }); + + it('should leave the hostname untouched', () => { + const formattedAuthHostname = formatRegionalizedHostname(AUTH_HOSTNAME, 'bzh'); + expect(formattedAuthHostname).toBe(AUTH_HOSTNAME); + + const formattedElasticSipTrunkingHostname = formatRegionalizedHostname(ELASTIC_SIP_TRUNKING_HOSTNAME, 'bzh'); + expect(formattedElasticSipTrunkingHostname).toBe(ELASTIC_SIP_TRUNKING_HOSTNAME); + + const formattedNumbersHostname = formatRegionalizedHostname(NUMBERS_HOSTNAME, 'bzh'); + expect(formattedNumbersHostname).toBe(NUMBERS_HOSTNAME); + + const formattedVerificationHostname = formatRegionalizedHostname(VERIFICATION_HOSTNAME, 'bzh'); + expect(formattedVerificationHostname).toBe(VERIFICATION_HOSTNAME); + + const formattedVoiceAppMgmtHostname = formatRegionalizedHostname(VOICE_APPLICATION_MANAGEMENT_HOSTNAME, 'bzh'); + expect(formattedVoiceAppMgmtHostname).toBe(VOICE_APPLICATION_MANAGEMENT_HOSTNAME); + }); + +}); diff --git a/packages/sms/src/models/v1/api-inbound-list/api-inbound-list.ts b/packages/sms/src/models/v1/api-inbound-list/api-inbound-list.ts index de254143..efbef35d 100644 --- a/packages/sms/src/models/v1/api-inbound-list/api-inbound-list.ts +++ b/packages/sms/src/models/v1/api-inbound-list/api-inbound-list.ts @@ -1,10 +1,3 @@ -/** - * Model: ApiInboundList - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { InboundMessageResponse } from '../inbound-message-response'; export interface ApiInboundList { diff --git a/packages/sms/src/models/v1/api-mo-message/api-mo-message.ts b/packages/sms/src/models/v1/api-mo-message/api-mo-message.ts index 42a14783..f323974a 100644 --- a/packages/sms/src/models/v1/api-mo-message/api-mo-message.ts +++ b/packages/sms/src/models/v1/api-mo-message/api-mo-message.ts @@ -1,11 +1,3 @@ -/** - * Model: ApiMoMessage - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - - /** * The page of inbounds matching the given filters. */ diff --git a/packages/sms/src/models/v1/api-update-binary-mt-message/api-update-binary-mt-message.ts b/packages/sms/src/models/v1/api-update-binary-mt-message/api-update-binary-mt-message.ts index 3892c1d6..5a271e87 100644 --- a/packages/sms/src/models/v1/api-update-binary-mt-message/api-update-binary-mt-message.ts +++ b/packages/sms/src/models/v1/api-update-binary-mt-message/api-update-binary-mt-message.ts @@ -1,6 +1,5 @@ import { DeliveryReportEnum } from '../enums'; - export interface ApiUpdateBinaryMtMessage { /** Sender number. Must be valid phone number, short code or alphanumeric. */ diff --git a/packages/sms/src/models/v1/api-update-mt-message/api-update-mt-message.ts b/packages/sms/src/models/v1/api-update-mt-message/api-update-mt-message.ts index afbba270..9408262d 100644 --- a/packages/sms/src/models/v1/api-update-mt-message/api-update-mt-message.ts +++ b/packages/sms/src/models/v1/api-update-mt-message/api-update-mt-message.ts @@ -1,12 +1,5 @@ -/** - * Model: ApiUpdateMtMessage - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ import { DeliveryReportEnum } from '../enums'; - export interface ApiUpdateMtMessage { /** Sender number. Must be valid phone number, short code or alphanumeric. */ diff --git a/packages/sms/src/models/v1/binary-request/binary-request.ts b/packages/sms/src/models/v1/binary-request/binary-request.ts index a95f7500..7ab6c9dd 100644 --- a/packages/sms/src/models/v1/binary-request/binary-request.ts +++ b/packages/sms/src/models/v1/binary-request/binary-request.ts @@ -1,6 +1,5 @@ import { DeliveryReportEnum } from '../enums'; - export interface BinaryRequest { /** A list of phone numbers and group IDs that will receive the batch. [More info](https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628). */ to: string[]; diff --git a/packages/sms/src/models/v1/create-group-request/create-group-request.ts b/packages/sms/src/models/v1/create-group-request/create-group-request.ts index 113f85f0..078afc96 100644 --- a/packages/sms/src/models/v1/create-group-request/create-group-request.ts +++ b/packages/sms/src/models/v1/create-group-request/create-group-request.ts @@ -1,10 +1,3 @@ -/** - * Model: CreateGroupRequest - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { GroupObjectAutoUpdate } from '../group-object-auto-update'; export interface CreateGroupRequest { diff --git a/packages/sms/src/models/v1/create-group-response/create-group-response.ts b/packages/sms/src/models/v1/create-group-response/create-group-response.ts index d4729737..db546bc0 100644 --- a/packages/sms/src/models/v1/create-group-response/create-group-response.ts +++ b/packages/sms/src/models/v1/create-group-response/create-group-response.ts @@ -1,10 +1,3 @@ -/** - * Model: CreateGroupResponse - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { GroupAutoUpdate } from '../group-auto-update'; export interface CreateGroupResponse { diff --git a/packages/sms/src/models/v1/delivery-feedback-request/delivery-feedback-request.ts b/packages/sms/src/models/v1/delivery-feedback-request/delivery-feedback-request.ts index 5afd8601..0b157306 100644 --- a/packages/sms/src/models/v1/delivery-feedback-request/delivery-feedback-request.ts +++ b/packages/sms/src/models/v1/delivery-feedback-request/delivery-feedback-request.ts @@ -1,11 +1,3 @@ -/** - * Model: DeliveryFeedbackRequest - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - - export interface DeliveryFeedbackRequest { /** A list of phone numbers (MSISDNs) that have successfully received the message. The key is required, however, the value can be an empty array (`[]`) for *a batch*. If the feedback was enabled for *a group*, at least one phone number is required. */ diff --git a/packages/sms/src/models/v1/delivery-report-list/delivery-report-list.ts b/packages/sms/src/models/v1/delivery-report-list/delivery-report-list.ts index 08fc052c..2baceb3d 100644 --- a/packages/sms/src/models/v1/delivery-report-list/delivery-report-list.ts +++ b/packages/sms/src/models/v1/delivery-report-list/delivery-report-list.ts @@ -1,10 +1,3 @@ -/** - * Model: DeliveryReportList - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { RecipientDeliveryReport } from '../recipient-delivery-report'; export interface DeliveryReportList { diff --git a/packages/sms/src/models/v1/dry-run-request/dry-run-request.ts b/packages/sms/src/models/v1/dry-run-request/dry-run-request.ts index 82ece021..b85e8fba 100644 --- a/packages/sms/src/models/v1/dry-run-request/dry-run-request.ts +++ b/packages/sms/src/models/v1/dry-run-request/dry-run-request.ts @@ -1,10 +1,3 @@ -/** - * Model: DryRunRequest - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { BinaryRequest } from '../binary-request'; import { MediaRequest } from '../media-request'; import { TextRequest } from '../text-request'; diff --git a/packages/sms/src/models/v1/dry-run-response-per-recipient-inner/dry-run-response-per-recipient-inner.ts b/packages/sms/src/models/v1/dry-run-response-per-recipient-inner/dry-run-response-per-recipient-inner.ts index 70e96cbb..2094dba5 100644 --- a/packages/sms/src/models/v1/dry-run-response-per-recipient-inner/dry-run-response-per-recipient-inner.ts +++ b/packages/sms/src/models/v1/dry-run-response-per-recipient-inner/dry-run-response-per-recipient-inner.ts @@ -1,11 +1,3 @@ -/** - * Model: DryRunResponsePerRecipientInner - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - - export interface DryRunResponsePerRecipientInner { recipient?: string; diff --git a/packages/sms/src/models/v1/dry-run-response/dry-run-response.ts b/packages/sms/src/models/v1/dry-run-response/dry-run-response.ts index e0a7a8ca..96da08b3 100644 --- a/packages/sms/src/models/v1/dry-run-response/dry-run-response.ts +++ b/packages/sms/src/models/v1/dry-run-response/dry-run-response.ts @@ -1,10 +1,3 @@ -/** - * Model: DryRunResponse - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { DryRunResponsePerRecipientInner } from '../dry-run-response-per-recipient-inner'; export interface DryRunResponse { diff --git a/packages/sms/src/models/v1/error-response-obj/error-response-obj.ts b/packages/sms/src/models/v1/error-response-obj/error-response-obj.ts index acbf474b..60432bd1 100644 --- a/packages/sms/src/models/v1/error-response-obj/error-response-obj.ts +++ b/packages/sms/src/models/v1/error-response-obj/error-response-obj.ts @@ -1,11 +1,3 @@ -/** - * Model: ErrorResponseObj - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - - export interface ErrorResponseObj { /** The error code. See [error codes](/docs/sms/api-reference/#error-codes). */ diff --git a/packages/sms/src/models/v1/group-auto-update/group-auto-update.ts b/packages/sms/src/models/v1/group-auto-update/group-auto-update.ts index 20f78809..88795cb3 100644 --- a/packages/sms/src/models/v1/group-auto-update/group-auto-update.ts +++ b/packages/sms/src/models/v1/group-auto-update/group-auto-update.ts @@ -1,11 +1,3 @@ -/** - * Model: GroupAutoUpdate - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - - export interface GroupAutoUpdate { /** Short code or long number addressed in MO. Constraints: Must be valid MSISDN or short code. */ diff --git a/packages/sms/src/models/v1/group-object-auto-update-remove/group-object-auto-update-remove.ts b/packages/sms/src/models/v1/group-object-auto-update-remove/group-object-auto-update-remove.ts index 0e4ff224..b3406177 100644 --- a/packages/sms/src/models/v1/group-object-auto-update-remove/group-object-auto-update-remove.ts +++ b/packages/sms/src/models/v1/group-object-auto-update-remove/group-object-auto-update-remove.ts @@ -1,11 +1,3 @@ -/** - * Model: GroupObjectAutoUpdateRemove - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - - /** * Keyword to be sent in MO to remove from a group. */ diff --git a/packages/sms/src/models/v1/group-object-auto-update/group-object-auto-update.ts b/packages/sms/src/models/v1/group-object-auto-update/group-object-auto-update.ts index ae3babff..8290776a 100644 --- a/packages/sms/src/models/v1/group-object-auto-update/group-object-auto-update.ts +++ b/packages/sms/src/models/v1/group-object-auto-update/group-object-auto-update.ts @@ -1,10 +1,3 @@ -/** - * Model: GroupObjectAutoUpdate - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { GroupObjectAutoUpdateRemove } from '../group-object-auto-update-remove'; import { UpdateGroupRequestAutoUpdateAdd } from '../update-group-request-auto-update-add'; diff --git a/packages/sms/src/models/v1/inbound-message-response/inbound-message-response.ts b/packages/sms/src/models/v1/inbound-message-response/inbound-message-response.ts index aa580c0c..7a37afe2 100644 --- a/packages/sms/src/models/v1/inbound-message-response/inbound-message-response.ts +++ b/packages/sms/src/models/v1/inbound-message-response/inbound-message-response.ts @@ -1,10 +1,3 @@ -/** - * Model: InboundMessageResponse - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { MOBinary } from '../mo-binary'; import { MOText } from '../mo-text'; diff --git a/packages/sms/src/models/v1/list-groups-response/list-groups-response.ts b/packages/sms/src/models/v1/list-groups-response/list-groups-response.ts index 811ffa91..17bb4adc 100644 --- a/packages/sms/src/models/v1/list-groups-response/list-groups-response.ts +++ b/packages/sms/src/models/v1/list-groups-response/list-groups-response.ts @@ -1,10 +1,3 @@ -/** - * Model: ListGroupsResponse - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { CreateGroupResponse } from '../create-group-response'; export interface ListGroupsResponse { diff --git a/packages/sms/src/models/v1/message-delivery-status/message-delivery-status.ts b/packages/sms/src/models/v1/message-delivery-status/message-delivery-status.ts index 7f89999c..d33094ff 100644 --- a/packages/sms/src/models/v1/message-delivery-status/message-delivery-status.ts +++ b/packages/sms/src/models/v1/message-delivery-status/message-delivery-status.ts @@ -1,11 +1,3 @@ -/** - * Model: MessageDeliveryStatus - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - - import { DeliveryReportStatusEnum } from '../enums'; /** diff --git a/packages/sms/src/models/v1/parameter-obj-parameter-key/parameter-obj-parameter-key.ts b/packages/sms/src/models/v1/parameter-obj-parameter-key/parameter-obj-parameter-key.ts index 33c3de38..2e33d1d2 100644 --- a/packages/sms/src/models/v1/parameter-obj-parameter-key/parameter-obj-parameter-key.ts +++ b/packages/sms/src/models/v1/parameter-obj-parameter-key/parameter-obj-parameter-key.ts @@ -1,11 +1,3 @@ -/** - * Model: ParameterObjParameterKey - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - - /** * The name of the parameter that will be replaced in the message body. Letters A-Z and a-z, digits 0-9 and .-_ allowed. */ diff --git a/packages/sms/src/models/v1/parameter-obj/parameter-obj.ts b/packages/sms/src/models/v1/parameter-obj/parameter-obj.ts index 89e6cb5d..15beaa86 100644 --- a/packages/sms/src/models/v1/parameter-obj/parameter-obj.ts +++ b/packages/sms/src/models/v1/parameter-obj/parameter-obj.ts @@ -1,10 +1,3 @@ -/** - * Model: ParameterObj - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { ParameterObjParameterKey } from '../parameter-obj-parameter-key'; /** diff --git a/packages/sms/src/models/v1/recipient-delivery-report/recipient-delivery-report.ts b/packages/sms/src/models/v1/recipient-delivery-report/recipient-delivery-report.ts index 917064b9..a8daedf2 100644 --- a/packages/sms/src/models/v1/recipient-delivery-report/recipient-delivery-report.ts +++ b/packages/sms/src/models/v1/recipient-delivery-report/recipient-delivery-report.ts @@ -1,6 +1,5 @@ import { DeliveryReportStatusEnum } from '../enums'; - export interface RecipientDeliveryReport { /** The default originator used for the recipient this delivery report belongs to, if default originator pool configured and no originator set when submitting batch. */ diff --git a/packages/sms/src/models/v1/replace-group-request/replace-group-request.ts b/packages/sms/src/models/v1/replace-group-request/replace-group-request.ts index 63b644bc..0dbf3659 100644 --- a/packages/sms/src/models/v1/replace-group-request/replace-group-request.ts +++ b/packages/sms/src/models/v1/replace-group-request/replace-group-request.ts @@ -1,11 +1,3 @@ -/** - * Model: ReplaceGroupRequest - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - - export interface ReplaceGroupRequest { /** Name of group. */ diff --git a/packages/sms/src/models/v1/update-batch-message-request/update-batch-message-request.ts b/packages/sms/src/models/v1/update-batch-message-request/update-batch-message-request.ts index 9247db5c..bfee60f7 100644 --- a/packages/sms/src/models/v1/update-batch-message-request/update-batch-message-request.ts +++ b/packages/sms/src/models/v1/update-batch-message-request/update-batch-message-request.ts @@ -1,10 +1,3 @@ -/** - * Model: UpdateBatchMessageRequest - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { ApiUpdateBinaryMtMessage } from '../api-update-binary-mt-message'; import { ApiUpdateMmsMtMessage } from '../api-update-mms-mt-message'; import { ApiUpdateTextMtMessage } from '../api-update-text-mt-message'; diff --git a/packages/sms/src/models/v1/update-group-request-auto-update-add/update-group-request-auto-update-add.ts b/packages/sms/src/models/v1/update-group-request-auto-update-add/update-group-request-auto-update-add.ts index 9ded96c3..d4502d9c 100644 --- a/packages/sms/src/models/v1/update-group-request-auto-update-add/update-group-request-auto-update-add.ts +++ b/packages/sms/src/models/v1/update-group-request-auto-update-add/update-group-request-auto-update-add.ts @@ -1,11 +1,3 @@ -/** - * Model: UpdateGroupRequestAutoUpdateAdd - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - - export interface UpdateGroupRequestAutoUpdateAdd { /** Keyword to be sent in MO to add phone number to a group opt-in keyword like \"JOIN\". If `auto_update.to` is dedicated long/short number or unique brand keyword like \"Sinch\" if it is a shared short code. Constraints: Must be one word. */ diff --git a/packages/sms/src/models/v1/update-group-request-auto-update-remove/update-group-request-auto-update-remove.ts b/packages/sms/src/models/v1/update-group-request-auto-update-remove/update-group-request-auto-update-remove.ts index f92a0446..0f55e6f7 100644 --- a/packages/sms/src/models/v1/update-group-request-auto-update-remove/update-group-request-auto-update-remove.ts +++ b/packages/sms/src/models/v1/update-group-request-auto-update-remove/update-group-request-auto-update-remove.ts @@ -1,11 +1,3 @@ -/** - * Model: UpdateGroupRequestAutoUpdateRemove - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - - /** * Keyword to be sent in MO to remove from a group. */ diff --git a/packages/sms/src/models/v1/update-group-request-auto-update/update-group-request-auto-update.ts b/packages/sms/src/models/v1/update-group-request-auto-update/update-group-request-auto-update.ts index 9ab5dbac..e245759d 100644 --- a/packages/sms/src/models/v1/update-group-request-auto-update/update-group-request-auto-update.ts +++ b/packages/sms/src/models/v1/update-group-request-auto-update/update-group-request-auto-update.ts @@ -1,10 +1,3 @@ -/** - * Model: UpdateGroupRequestAutoUpdate - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { UpdateGroupRequestAutoUpdateAdd } from '../update-group-request-auto-update-add'; import { UpdateGroupRequestAutoUpdateRemove } from '../update-group-request-auto-update-remove'; diff --git a/packages/sms/src/models/v1/update-group-request/update-group-request.ts b/packages/sms/src/models/v1/update-group-request/update-group-request.ts index 791512d2..e98f1eff 100644 --- a/packages/sms/src/models/v1/update-group-request/update-group-request.ts +++ b/packages/sms/src/models/v1/update-group-request/update-group-request.ts @@ -1,10 +1,3 @@ -/** - * Model: UpdateGroupRequest - * - * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. - * - */ - import { UpdateGroupRequestAutoUpdate } from '../update-group-request-auto-update'; export interface UpdateGroupRequest { diff --git a/packages/sms/src/rest/v1/sms-domain-api.ts b/packages/sms/src/rest/v1/sms-domain-api.ts index 0dae116f..1b372b05 100644 --- a/packages/sms/src/rest/v1/sms-domain-api.ts +++ b/packages/sms/src/rest/v1/sms-domain-api.ts @@ -3,8 +3,10 @@ import { ApiClient, ApiFetchClient, buildFlexibleOAuth2OrApiTokenApiClientOptions, + formatRegionalizedHostname, SinchClientParameters, SmsRegion, + SMS_HOSTNAME, UnifiedCredentials, ServicePlanIdCredentials, SupportedSmsRegion, @@ -93,7 +95,7 @@ export class SmsDomainApi implements Api { private buildHostname(region: SmsRegion, useZapStack: boolean) { const formattedRegion = region !== '' ? `${region}.` : ''; - return `https://${useZapStack?'zt.':''}${formattedRegion}sms.api.sinch.com`; + return formatRegionalizedHostname(SMS_HOSTNAME, `${useZapStack?'zt.':''}${formattedRegion}`); } } diff --git a/packages/verification/src/rest/v1/verification-domain-api.ts b/packages/verification/src/rest/v1/verification-domain-api.ts index 7b000970..8270b36c 100644 --- a/packages/verification/src/rest/v1/verification-domain-api.ts +++ b/packages/verification/src/rest/v1/verification-domain-api.ts @@ -5,6 +5,7 @@ import { buildApplicationSignedApiClientOptions, SinchClientParameters, ApplicationCredentials, + VERIFICATION_HOSTNAME, } from '@sinch/sdk-client'; export class VerificationDomainApi implements Api { @@ -65,7 +66,7 @@ export class VerificationDomainApi implements Api { if (!this.client) { const apiClientOptions = buildApplicationSignedApiClientOptions(this.sinchClientParameters, 'Verification'); this.client = new ApiFetchClient(apiClientOptions); - this.client.apiClientOptions.hostname = this.sinchClientParameters.verificationHostname ?? 'https://verification.api.sinch.com'; + this.client.apiClientOptions.hostname = this.sinchClientParameters.verificationHostname ?? VERIFICATION_HOSTNAME; } return this.client; } diff --git a/packages/voice/src/rest/v1/voice-domain-api.ts b/packages/voice/src/rest/v1/voice-domain-api.ts index ba60ba99..38b6edb4 100644 --- a/packages/voice/src/rest/v1/voice-domain-api.ts +++ b/packages/voice/src/rest/v1/voice-domain-api.ts @@ -4,8 +4,11 @@ import { ApiFetchClient, ApplicationCredentials, buildApplicationSignedApiClientOptions, + formatRegionalizedHostname, SinchClientParameters, SupportedVoiceRegion, + VOICE_APPLICATION_MANAGEMENT_HOSTNAME, + VOICE_HOSTNAME, VoiceRegion, } from '@sinch/sdk-client'; @@ -90,10 +93,10 @@ export class VoiceDomainApi implements Api { private buildHostname(region: VoiceRegion) { switch (this.apiName) { case 'ApplicationsApi': - return this.sinchClientParameters.voiceApplicationManagementHostname ?? 'https://callingapi.sinch.com'; + return this.sinchClientParameters.voiceApplicationManagementHostname ?? VOICE_APPLICATION_MANAGEMENT_HOSTNAME; default: { const formattedRegion = region === VoiceRegion.DEFAULT ? region : `-${region}`; - return this.sinchClientParameters.voiceHostname ?? `https://calling${formattedRegion}.api.sinch.com`; + return this.sinchClientParameters.voiceHostname ?? formatRegionalizedHostname(VOICE_HOSTNAME, formattedRegion); } } }