From 960c73662970253c849f8e98bdddc6589f353e99 Mon Sep 17 00:00:00 2001 From: Antoine SEIN <142824551+asein-sinch@users.noreply.github.com> Date: Thu, 12 Sep 2024 12:07:25 +0200 Subject: [PATCH 1/5] DEVEXP-556: Add snippets for Numbers API --- snippets/numbers/available-regions/list.js | 15 ++ .../numbers/callback-configuration/get.js | 10 + .../numbers/callback-configuration/update.js | 19 ++ snippets/numbers/check-availability.js | 25 +++ snippets/numbers/get.js | 17 ++ snippets/numbers/list.js | 30 +++ snippets/numbers/release.js | 17 ++ snippets/numbers/rent-any.js | 40 ++++ snippets/numbers/rent.js | 25 +++ .../numbers/search-for-available-numbers.js | 17 ++ snippets/numbers/update.js | 29 +++ snippets/package-lock.json | 188 ++++++++++++++++++ snippets/package.json | 10 + 13 files changed, 442 insertions(+) create mode 100644 snippets/numbers/available-regions/list.js create mode 100644 snippets/numbers/callback-configuration/get.js create mode 100644 snippets/numbers/callback-configuration/update.js create mode 100644 snippets/numbers/check-availability.js create mode 100644 snippets/numbers/get.js create mode 100644 snippets/numbers/list.js create mode 100644 snippets/numbers/release.js create mode 100644 snippets/numbers/rent-any.js create mode 100644 snippets/numbers/rent.js create mode 100644 snippets/numbers/search-for-available-numbers.js create mode 100644 snippets/numbers/update.js create mode 100644 snippets/package-lock.json create mode 100644 snippets/package.json diff --git a/snippets/numbers/available-regions/list.js b/snippets/numbers/available-regions/list.js new file mode 100644 index 0000000..6bf9329 --- /dev/null +++ b/snippets/numbers/available-regions/list.js @@ -0,0 +1,15 @@ +// eslint-disable-next-line no-unused-vars +import { Numbers, NumbersService } from '@sinch/sdk-core'; + +/** @param {NumbersService} numbersService */ +export const execute = async (numbersService) => { + + /** @type {Numbers.ListAvailableRegionsRequestData} */ + const requestData = { + types: ['LOCAL', 'MOBILE'], + }; + + const response = await numbersService.availableRegions.list(requestData); + + console.log(`Available regions:\n${JSON.stringify(response, null, 2)}`); +}; diff --git a/snippets/numbers/callback-configuration/get.js b/snippets/numbers/callback-configuration/get.js new file mode 100644 index 0000000..fc03424 --- /dev/null +++ b/snippets/numbers/callback-configuration/get.js @@ -0,0 +1,10 @@ +// eslint-disable-next-line no-unused-vars +import { Numbers, NumbersService } from '@sinch/sdk-core'; + +/** @param {NumbersService} numbersService */ +export const execute = async (numbersService) => { + + const response = await numbersService.callbacks.get({}); + + console.log(`Callback configuration:\n${JSON.stringify(response, null, 2)}`); +}; diff --git a/snippets/numbers/callback-configuration/update.js b/snippets/numbers/callback-configuration/update.js new file mode 100644 index 0000000..8b9c918 --- /dev/null +++ b/snippets/numbers/callback-configuration/update.js @@ -0,0 +1,19 @@ +// eslint-disable-next-line no-unused-vars +import { Numbers, NumbersService } from '@sinch/sdk-core'; + +/** @param {NumbersService} numbersService */ +export const execute = async (numbersService) => { + + const hmacSecret = 'New_HMAC_secret'; + + /** @type {Numbers.UpdateCallbackConfigurationRequestData} */ + const requestData = { + updateCallbackConfigurationRequestBody: { + hmacSecret, + }, + }; + + const response = await numbersService.callbacks.update(requestData); + + console.log(`Updated callback configuration:\n${JSON.stringify(response, null, 2)}`); +}; diff --git a/snippets/numbers/check-availability.js b/snippets/numbers/check-availability.js new file mode 100644 index 0000000..93a1bc4 --- /dev/null +++ b/snippets/numbers/check-availability.js @@ -0,0 +1,25 @@ +// eslint-disable-next-line no-unused-vars +import { Numbers, NumbersService } from '@sinch/sdk-core'; + +/** @param {NumbersService} numbersService */ +export const execute = async (numbersService) => { + + const phoneNumber = 'a_phone_number'; + + /** @type {Numbers.GetAvailableNumberRequestData} */ + const requestData = { + phoneNumber, + }; + + let response; + try { + response = await numbersService.availableNumber.checkAvailability(requestData); + } catch (error) { + console.error(`ERROR: the phone number ${requestData.phoneNumber} is not available`); + } + + if (response) { + console.log(`The phone number is available:\n${JSON.stringify(response, null, 2)}`); + } + +}; diff --git a/snippets/numbers/get.js b/snippets/numbers/get.js new file mode 100644 index 0000000..9dd6da3 --- /dev/null +++ b/snippets/numbers/get.js @@ -0,0 +1,17 @@ +// eslint-disable-next-line no-unused-vars +import { Numbers, NumbersService } from '@sinch/sdk-core'; + +/** @param {NumbersService} numbersService */ +export const execute = async (numbersService) => { + + const phoneNumber = 'YOUR_rented_phoneNumber'; + + /** @type {Numbers.GetActiveNumberRequestData} */ + const requestData = { + phoneNumber, + }; + + const response = await numbersService.activeNumber.get(requestData); + + console.log(`Rented number details:\n${JSON.stringify(response, null, 2)}`); +}; diff --git a/snippets/numbers/list.js b/snippets/numbers/list.js new file mode 100644 index 0000000..d6a7fa6 --- /dev/null +++ b/snippets/numbers/list.js @@ -0,0 +1,30 @@ +// eslint-disable-next-line no-unused-vars +import { Numbers, NumbersService } from '@sinch/sdk-core'; + +/** @param {NumbersService} numbersService */ +export const execute = async (numbersService) => { + + /** @type Numbers.ListActiveNumbersRequestData */ + const requestData = { + regionCode: 'US', + type: 'LOCAL', + }; + + // Method 1: Fetch the data page by page manually + /** @type {Numbers.ActiveNumber[]} */ + const activeNumbersList = []; + let response = await numbersService.activeNumber.list(requestData); + + do { + activeNumbersList.push(...response.data); + response = response.hasNextPage ? await response.nextPage() : null; + } while (response); + console.log(`Full list of numbers printed at once (length = ${activeNumbersList.length}):\n${JSON.stringify(activeNumbersList, null, 2)}`); + + // Method 2: Use the iterator and fetch data from more pages automatically + console.log('List of numbers printed one by one:'); + for await (const rentedNumber of numbersService.activeNumber.list(requestData)) { + console.log(JSON.stringify(rentedNumber, null, 2)); + } + +}; diff --git a/snippets/numbers/release.js b/snippets/numbers/release.js new file mode 100644 index 0000000..935db91 --- /dev/null +++ b/snippets/numbers/release.js @@ -0,0 +1,17 @@ +// eslint-disable-next-line no-unused-vars +import { Numbers, NumbersService } from '@sinch/sdk-core'; + +/** @param {NumbersService} numbersService */ +export const execute = async (numbersService) => { + + const phoneNumber = 'YOUR_phone_number_to_be_released'; + + /** @type {Numbers.ReleaseNumberRequestData} */ + const requestData = { + phoneNumber, + }; + + const response = await numbersService.activeNumber.release(requestData); + + console.log(`Released number:\n${JSON.stringify(response, null, 2)}`); +}; diff --git a/snippets/numbers/rent-any.js b/snippets/numbers/rent-any.js new file mode 100644 index 0000000..3ef7ebd --- /dev/null +++ b/snippets/numbers/rent-any.js @@ -0,0 +1,40 @@ +// eslint-disable-next-line no-unused-vars +import { Numbers, NumbersService } from '@sinch/sdk-core'; + +/** @param {NumbersService} numbersService */ +export const execute = async (numbersService) => { + + const servicePlanId = 'YOUR_service_plan_id'; + const appId = 'YOUR_app_id'; + const callbackUrl = 'YOUR_callback_url'; + + /** @type {Numbers.RentAnyNumberRequestSmsConfiguration} */ + const smsConfiguration = { + servicePlanId, + }; + + /** @type {Numbers.RentAnyNumberRequestVoiceConfiguration} */ + const voiceConfiguration = { + appId, + }; + + /** @type {Numbers.RentAnyNumberRequestData} */ + const requestData = { + rentAnyNumberRequestBody: { + regionCode: 'US', + type: 'LOCAL', + numberPattern: { + pattern: '+1781', + searchPattern: 'START', + }, + smsConfiguration, + voiceConfiguration, + callbackUrl, + }, + }; + + const response = await numbersService.availableNumber.rentAny(requestData); + + console.log(`Rented number:\n${JSON.stringify(response, null, 2)}`); + +}; diff --git a/snippets/numbers/rent.js b/snippets/numbers/rent.js new file mode 100644 index 0000000..ef6eaf1 --- /dev/null +++ b/snippets/numbers/rent.js @@ -0,0 +1,25 @@ +// eslint-disable-next-line no-unused-vars +import { Numbers, NumbersService } from '@sinch/sdk-core'; + +/** @param {NumbersService} numbersService */ +export const execute = async (numbersService) => { + + // Available numbers list can be retrieved by using list() function from available service, see: + // https://developers.sinch.com/docs/numbers/getting-started/node-sdk/searchavailable/ + const phoneNumber = 'available_phone_number_to_be_rented'; + const servicePlanId = 'YOUR_service_plan_id'; + + /** @type {Numbers.RentNumberRequestData} */ + const requestData = { + phoneNumber, + rentNumberRequestBody: { + smsConfiguration: { + servicePlanId, + }, + }, + }; + + const response = await numbersService.availableNumber.rent(requestData); + + console.log(`Rented number:\n${JSON.stringify(response, null, 2)}`); +}; diff --git a/snippets/numbers/search-for-available-numbers.js b/snippets/numbers/search-for-available-numbers.js new file mode 100644 index 0000000..53bccc0 --- /dev/null +++ b/snippets/numbers/search-for-available-numbers.js @@ -0,0 +1,17 @@ +// eslint-disable-next-line no-unused-vars +import { Numbers, NumbersService } from '@sinch/sdk-core'; + +/** @param {NumbersService} numbersService */ +export const execute = async (numbersService) => { + + /** @type {Numbers.ListAvailableNumbersRequestData} */ + const requestData = { + regionCode: 'US', + type: 'LOCAL', + capabilities: ['SMS', 'VOICE'], + }; + + const response = await numbersService.availableNumber.list(requestData); + + console.log(`Available numbers to rent:\n${JSON.stringify(response, null, 2)}`); +}; diff --git a/snippets/numbers/update.js b/snippets/numbers/update.js new file mode 100644 index 0000000..5bbc842 --- /dev/null +++ b/snippets/numbers/update.js @@ -0,0 +1,29 @@ +// eslint-disable-next-line no-unused-vars +import { Numbers, NumbersService } from '@sinch/sdk-core'; + +/** @param {NumbersService} numbersService */ +export const execute = async (numbersService) => { + + const phoneNumber = 'YOUR_phone_number_to_be_updated'; + const appId = 'YOUR_app_id'; + const displayName = 'Updated from Sinch Node.js SDK'; + + /** @type {Numbers.VoiceConfiguration} */ + const voiceConfiguration= { + appId, + type: 'RTC', + }; + + /** @type {Numbers.UpdateActiveNumberRequestData} */ + const requestData = { + phoneNumber, + updateActiveNumberRequestBody: { + displayName, + voiceConfiguration, + }, + }; + + const response = await numbersService.activeNumber.update(requestData); + + console.log(`Updated number:\n${JSON.stringify(response, null, 2)}`); +}; diff --git a/snippets/package-lock.json b/snippets/package-lock.json new file mode 100644 index 0000000..6899799 --- /dev/null +++ b/snippets/package-lock.json @@ -0,0 +1,188 @@ +{ + "name": "@sinch/code-snippets", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@sinch/code-snippets", + "version": "0.0.0", + "dependencies": { + "@sinch/sdk-core": "^1.1.0" + } + }, + "node_modules/@sinch/conversation": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@sinch/conversation/-/conversation-1.1.0.tgz", + "integrity": "sha512-8KxUnzO+a8fPmhSmpRX9zGfgF3Hvgg4ZQNF9CNVDVRckcE7p+mWENdWts7GXWSEKMONZIOXwYnosAeENMsZVow==", + "dependencies": { + "@sinch/sdk-client": "^1.1.0" + } + }, + "node_modules/@sinch/elastic-sip-trunking": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@sinch/elastic-sip-trunking/-/elastic-sip-trunking-1.1.0.tgz", + "integrity": "sha512-1E635dxPFnCfS1e01WGSY2xcLGUsAngcghcsodFFMTXxmAL+2cxhFdmrodmBdNmCVpfPLkMSIdQC/t+1p+awNA==", + "dependencies": { + "@sinch/sdk-client": "^1.0.0" + } + }, + "node_modules/@sinch/fax": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@sinch/fax/-/fax-1.1.0.tgz", + "integrity": "sha512-89NS1zMg07QAjj6Fr93moVjkfZSkVwYwegZfZ2LEo7SEuFXp9CahL5UoHXzipTNbtCxcouGUgiJkN0fxJBN/VQ==", + "dependencies": { + "@sinch/sdk-client": "^1.1.0" + } + }, + "node_modules/@sinch/numbers": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@sinch/numbers/-/numbers-1.1.0.tgz", + "integrity": "sha512-uEtTDTPabY7f2CU1X/rpuBqWbDutqcHA34vaaJ1HbGWhdK406YfUKxBha60/kTAO5df+eDjVxg2SYiVNRpJNLw==", + "dependencies": { + "@sinch/sdk-client": "^1.1.0" + } + }, + "node_modules/@sinch/sdk-client": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@sinch/sdk-client/-/sdk-client-1.1.0.tgz", + "integrity": "sha512-YiF8LpZ8RdWFdjyA1mlySyuNfVQPA1EV8gSecrvBUpwO8LyFhvbZF1OsMfaqVJiUr4mA/UArbbO6qSzwA2XgCQ==", + "dependencies": { + "form-data": "^4.0.0", + "node-fetch": "2.7.0" + } + }, + "node_modules/@sinch/sdk-core": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@sinch/sdk-core/-/sdk-core-1.1.0.tgz", + "integrity": "sha512-kqZ0n0ycClYPPSk5ugy9FFmq/j/qVXmhC8rgUBu2JWTjsOTsRVe9dSnUuQYaxj6V8sEjySUALtLiJBU3neeq8A==", + "dependencies": { + "@sinch/conversation": "^1.1.0", + "@sinch/elastic-sip-trunking": "^1.1.0", + "@sinch/fax": "^1.1.0", + "@sinch/numbers": "^1.1.0", + "@sinch/sms": "^1.1.0", + "@sinch/verification": "^1.1.0", + "@sinch/voice": "^1.1.0" + } + }, + "node_modules/@sinch/sms": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@sinch/sms/-/sms-1.1.0.tgz", + "integrity": "sha512-6QXpLujzcl5jTvYFmB+UebVWYGXEHaRBsmE1vG7GAwIAOrCxdpusvSWitHeigCUz9CxrzdjC+3JmlS7q7rbONA==", + "dependencies": { + "@sinch/sdk-client": "^1.1.0" + } + }, + "node_modules/@sinch/verification": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@sinch/verification/-/verification-1.1.0.tgz", + "integrity": "sha512-UcXf4dsrG0+qATCJIiCEyHwnyLknEtYSK1UKV40EGPkYNn4kVwxLRDglKOIq9txBQZ5MgpbFDTqedbf4AcREZQ==", + "dependencies": { + "@sinch/sdk-client": "^1.1.0" + } + }, + "node_modules/@sinch/voice": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@sinch/voice/-/voice-1.1.0.tgz", + "integrity": "sha512-znOVSxBHRoI7J8zZGcFUrqDHR8hyOifh+IOR1FUnel4c1hS5s9HsHfmcnd4HmUca1P/ln0c19+KxMhNFBVLTAw==", + "dependencies": { + "@sinch/sdk-client": "^1.1.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + } + } +} diff --git a/snippets/package.json b/snippets/package.json new file mode 100644 index 0000000..cb703ba --- /dev/null +++ b/snippets/package.json @@ -0,0 +1,10 @@ +{ + "name": "@sinch/code-snippets", + "version": "1.0.0", + "description": "Code snippets related to the Sinch Node.js SDK usage", + "author": "Sinch", + "type": "module", + "dependencies": { + "@sinch/sdk-core": "^1.1.0" + } +} From 31f003c19abf4a7e5e5388bda150427829fcf1a5 Mon Sep 17 00:00:00 2001 From: Antoine SEIN <142824551+asein-sinch@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:18:17 +0200 Subject: [PATCH 2/5] Split the 2 ways for fetching data with pagination --- snippets/numbers/list-auto.js | 19 +++++++++++++++++++ snippets/numbers/list.js | 18 +++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 snippets/numbers/list-auto.js diff --git a/snippets/numbers/list-auto.js b/snippets/numbers/list-auto.js new file mode 100644 index 0000000..3ad03f2 --- /dev/null +++ b/snippets/numbers/list-auto.js @@ -0,0 +1,19 @@ +// eslint-disable-next-line no-unused-vars +import { Numbers, NumbersService } from '@sinch/sdk-core'; + +/** @param {NumbersService} numbersService */ +export const execute = async (numbersService) => { + + /** @type Numbers.ListActiveNumbersRequestData */ + const requestData = { + regionCode: 'US', + type: 'LOCAL', + }; + + console.log('List of numbers printed one by one:'); + // Use the iterator and fetch data from all the pages automatically + for await (const rentedNumber of numbersService.activeNumber.list(requestData)) { + console.log(JSON.stringify(rentedNumber, null, 2)); + } + +}; diff --git a/snippets/numbers/list.js b/snippets/numbers/list.js index d6a7fa6..cd58782 100644 --- a/snippets/numbers/list.js +++ b/snippets/numbers/list.js @@ -10,21 +10,17 @@ export const execute = async (numbersService) => { type: 'LOCAL', }; - // Method 1: Fetch the data page by page manually /** @type {Numbers.ActiveNumber[]} */ const activeNumbersList = []; + // Fetch a page of Numbers let response = await numbersService.activeNumber.list(requestData); - - do { + // Fetch the data page by page manually + while (response.hasNextPage) { activeNumbersList.push(...response.data); - response = response.hasNextPage ? await response.nextPage() : null; - } while (response); - console.log(`Full list of numbers printed at once (length = ${activeNumbersList.length}):\n${JSON.stringify(activeNumbersList, null, 2)}`); - - // Method 2: Use the iterator and fetch data from more pages automatically - console.log('List of numbers printed one by one:'); - for await (const rentedNumber of numbersService.activeNumber.list(requestData)) { - console.log(JSON.stringify(rentedNumber, null, 2)); + response = await response.nextPage(); } + activeNumbersList.push(...response.data); + + console.log(`Full list of numbers printed at once (length = ${activeNumbersList.length}):\n${JSON.stringify(activeNumbersList, null, 2)}`); }; From 6c62b00f31f3c388127dd3e4afabca0895312147 Mon Sep 17 00:00:00 2001 From: Antoine SEIN <142824551+asein-sinch@users.noreply.github.com> Date: Mon, 23 Sep 2024 12:10:10 +0200 Subject: [PATCH 3/5] Fix comment --- snippets/numbers/check-availability.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/snippets/numbers/check-availability.js b/snippets/numbers/check-availability.js index 93a1bc4..41462d9 100644 --- a/snippets/numbers/check-availability.js +++ b/snippets/numbers/check-availability.js @@ -11,15 +11,11 @@ export const execute = async (numbersService) => { phoneNumber, }; - let response; try { - response = await numbersService.availableNumber.checkAvailability(requestData); + const response = await numbersService.availableNumber.checkAvailability(requestData); + console.log(`The phone number is available:\n${JSON.stringify(response, null, 2)}`); } catch (error) { console.error(`ERROR: the phone number ${requestData.phoneNumber} is not available`); } - if (response) { - console.log(`The phone number is available:\n${JSON.stringify(response, null, 2)}`); - } - }; From 18fbae1b74588e8112cd896737c9d4d206a82a15 Mon Sep 17 00:00:00 2001 From: Antoine SEIN <142824551+asein-sinch@users.noreply.github.com> Date: Mon, 23 Sep 2024 13:40:47 +0200 Subject: [PATCH 4/5] Rename snippet files --- snippets/numbers/{get.js => active-numbers/get/snippet.js} | 0 .../numbers/{list-auto.js => active-numbers/list-auto/snippet.js} | 0 snippets/numbers/{list.js => active-numbers/list/snippet.js} | 0 .../numbers/{release.js => active-numbers/release/snippet.js} | 0 snippets/numbers/{update.js => active-numbers/update/snippet.js} | 0 .../check-availability/snippet.js} | 0 .../{rent-any.js => available-numbers/rent-any/snippet.js} | 0 snippets/numbers/{rent.js => available-numbers/rent/snippet.js} | 0 .../search-for-available-numbers/snippet.js} | 0 snippets/numbers/available-regions/{list.js => snippet.js} | 0 .../numbers/callback-configuration/{get.js => get/snippet.js} | 0 .../callback-configuration/{update.js => update/snippet.js} | 0 12 files changed, 0 insertions(+), 0 deletions(-) rename snippets/numbers/{get.js => active-numbers/get/snippet.js} (100%) rename snippets/numbers/{list-auto.js => active-numbers/list-auto/snippet.js} (100%) rename snippets/numbers/{list.js => active-numbers/list/snippet.js} (100%) rename snippets/numbers/{release.js => active-numbers/release/snippet.js} (100%) rename snippets/numbers/{update.js => active-numbers/update/snippet.js} (100%) rename snippets/numbers/{check-availability.js => available-numbers/check-availability/snippet.js} (100%) rename snippets/numbers/{rent-any.js => available-numbers/rent-any/snippet.js} (100%) rename snippets/numbers/{rent.js => available-numbers/rent/snippet.js} (100%) rename snippets/numbers/{search-for-available-numbers.js => available-numbers/search-for-available-numbers/snippet.js} (100%) rename snippets/numbers/available-regions/{list.js => snippet.js} (100%) rename snippets/numbers/callback-configuration/{get.js => get/snippet.js} (100%) rename snippets/numbers/callback-configuration/{update.js => update/snippet.js} (100%) diff --git a/snippets/numbers/get.js b/snippets/numbers/active-numbers/get/snippet.js similarity index 100% rename from snippets/numbers/get.js rename to snippets/numbers/active-numbers/get/snippet.js diff --git a/snippets/numbers/list-auto.js b/snippets/numbers/active-numbers/list-auto/snippet.js similarity index 100% rename from snippets/numbers/list-auto.js rename to snippets/numbers/active-numbers/list-auto/snippet.js diff --git a/snippets/numbers/list.js b/snippets/numbers/active-numbers/list/snippet.js similarity index 100% rename from snippets/numbers/list.js rename to snippets/numbers/active-numbers/list/snippet.js diff --git a/snippets/numbers/release.js b/snippets/numbers/active-numbers/release/snippet.js similarity index 100% rename from snippets/numbers/release.js rename to snippets/numbers/active-numbers/release/snippet.js diff --git a/snippets/numbers/update.js b/snippets/numbers/active-numbers/update/snippet.js similarity index 100% rename from snippets/numbers/update.js rename to snippets/numbers/active-numbers/update/snippet.js diff --git a/snippets/numbers/check-availability.js b/snippets/numbers/available-numbers/check-availability/snippet.js similarity index 100% rename from snippets/numbers/check-availability.js rename to snippets/numbers/available-numbers/check-availability/snippet.js diff --git a/snippets/numbers/rent-any.js b/snippets/numbers/available-numbers/rent-any/snippet.js similarity index 100% rename from snippets/numbers/rent-any.js rename to snippets/numbers/available-numbers/rent-any/snippet.js diff --git a/snippets/numbers/rent.js b/snippets/numbers/available-numbers/rent/snippet.js similarity index 100% rename from snippets/numbers/rent.js rename to snippets/numbers/available-numbers/rent/snippet.js diff --git a/snippets/numbers/search-for-available-numbers.js b/snippets/numbers/available-numbers/search-for-available-numbers/snippet.js similarity index 100% rename from snippets/numbers/search-for-available-numbers.js rename to snippets/numbers/available-numbers/search-for-available-numbers/snippet.js diff --git a/snippets/numbers/available-regions/list.js b/snippets/numbers/available-regions/snippet.js similarity index 100% rename from snippets/numbers/available-regions/list.js rename to snippets/numbers/available-regions/snippet.js diff --git a/snippets/numbers/callback-configuration/get.js b/snippets/numbers/callback-configuration/get/snippet.js similarity index 100% rename from snippets/numbers/callback-configuration/get.js rename to snippets/numbers/callback-configuration/get/snippet.js diff --git a/snippets/numbers/callback-configuration/update.js b/snippets/numbers/callback-configuration/update/snippet.js similarity index 100% rename from snippets/numbers/callback-configuration/update.js rename to snippets/numbers/callback-configuration/update/snippet.js From e53a11818eeffae0dfe48dca69981b6e89254c95 Mon Sep 17 00:00:00 2001 From: Antoine SEIN <142824551+asein-sinch@users.noreply.github.com> Date: Mon, 23 Sep 2024 13:51:07 +0200 Subject: [PATCH 5/5] Change CI configuration path --- .github/{ => workflows}/ci.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/ci.yml (100%) diff --git a/.github/ci.yml b/.github/workflows/ci.yml similarity index 100% rename from .github/ci.yml rename to .github/workflows/ci.yml