diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index 359998ae..25e583e9 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - node-version: [8.x, 9.x, 10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x] + node-version: [11.x, 12.x, 13.x, 14.x, 15.x, 16.x] steps: - uses: actions/checkout@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e87b6c0..d81c9108 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,21 @@ # Change Log +## [4.43.1](https://github.com/plivo/plivo-node/tree/v4.43.1) (2023-04-04) +- Added `monthly_recording_storage_amount`, `recording_storage_rate`, `rounded_recording_duration`, and `recording_storage_duration` parameters to the response for [get single recording API](https://www.plivo.com/docs/voice/api/recording#retrieve-a-recording) and [get all recordings API](https://www.plivo.com/docs/voice/api/recording#list-all-recordings) +- Added `recording_storage_duration` parameter as a filter option for [get all recordings API](https://www.plivo.com/docs/voice/api/recording#list-all-recordings) + +## [4.43.0](https://github.com/plivo/plivo-node/tree/v4.43.0) (2023-03-14) +**Adding new status code - Hosted Messaging order** +- Added new status code for create hosted messaging order. + +## [4.42.0](https://github.com/plivo/plivo-node/tree/v4.42.0) (2023-03-07) +**Bug fix - 'text' parameter should be optional for MMS** +- Make `text` as an optional parameter for [sending MMS](https://www.plivo.com/docs/sms/api/message#send-a-message). +- Fix code breaking due to undefined error.response while accessing response `status` property. + +## [4.41.0](https://github.com/plivo/plivo-node/tree/v4.41.0) (2023-03-03) +**Adding new attribute - 'isDomestic' in Get Message and List Message APIs** +- Add `isDomestic` to the response for the [list all messages API](https://www.plivo.com/docs/sms/api/message/list-all-messages/) and the [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) + ## [4.40.0](https://github.com/plivo/plivo-node/tree/v4.40.0) (2023-02-23) **Feature - Enhance MDR filtering capabilities ** - Added new fields on MDR object response diff --git a/Dockerfile b/Dockerfile index d938868b..ecb321ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:18.04 WORKDIR /usr/src/app -RUN apt-get update && apt-get install -y wget git vim +RUN apt-get update && apt-get install -y wget git vim make # Install node using nvm RUN mkdir -p /usr/src/.nvm diff --git a/Makefile b/Makefile index 9fe8b1a2..e3a0eb54 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,14 @@ -.PHONY: build test +.PHONY: build test run build: docker-compose up --build --remove-orphans test: - docker exec -it $$CONTAINER /bin/bash -c "npm install request --no-save && npm test" \ No newline at end of file + @[ "${CONTAINER}" ] && \ + (docker exec -it $$CONTAINER /bin/bash -c "npm install request --no-save && npm test") || \ + (npm install request --no-save && npm test) + +run: + @[ "${CONTAINER}" ] && \ + (docker exec -it $$CONTAINER /bin/bash -c 'cd /usr/src/app/node-sdk-test/ && node test.js') || \ + (cd /usr/src/app/node-sdk-test/ && node test.js) \ No newline at end of file diff --git a/README.md b/README.md index 18ee628e..103a94ac 100644 --- a/README.md +++ b/README.md @@ -147,5 +147,10 @@ export PLIVO_API_PROD_HOST= 5. The sdk directory will be mounted as a volume in the container. So any changes in the sdk code will also be reflected inside the container. However, when any change is made, the dependencies for the test program need to be re-installed. To do that: * Either restart the docker container * Or Run the `setup_sdk.sh` script -6. To run unit tests, run `make test CONTAINER=` in host, where `` is the docker container id created in 2. -(The docker container should be running) \ No newline at end of file +6. To run test code, run `make run CONTAINER=` in host. +7. To run unit tests, run `make test CONTAINER=` in host. +> `` is the docker container id created in 2. +(The docker container should be running) + +> Test code and unit tests can also be run within the container using +`make run` and `make test` respectively. (`CONTAINER` argument should be omitted when running from the container) \ No newline at end of file diff --git a/lib/resources/hostedMessagingNumber.js b/lib/resources/hostedMessagingNumber.js index 086e5865..b163a52b 100644 --- a/lib/resources/hostedMessagingNumber.js +++ b/lib/resources/hostedMessagingNumber.js @@ -127,7 +127,6 @@ export class HostedMessagingNumber extends PlivoResource { create(params = {}) { let client = this[clientKey]; return new Promise((resolve, reject) => { - params.multipart = true; client('POST', action, params) .then(response => { let object = new CreateHostedMessagingNumberResponse(response.body, idField); diff --git a/lib/resources/messages.js b/lib/resources/messages.js index e8d5da35..64e3ed71 100644 --- a/lib/resources/messages.js +++ b/lib/resources/messages.js @@ -49,6 +49,7 @@ export class MessageGetResponse { this.tendlcRegistrationStatus = params.tendlcRegistrationStatus; this.destinationCountryIso2 = params.destinationCountryIso2; this.requesterIP = params.requesterIp; + this.isDomestic = params.isDomestic; } } @@ -72,6 +73,7 @@ export class MessageListResponse { this.tendlcRegistrationStatus = params.tendlcRegistrationStatus; this.destinationCountryIso2 = params.destinationCountryIso2; this.requesterIP = params.requesterIp; + this.isDomestic = params.isDomestic; } } @@ -210,11 +212,6 @@ export class MessageInterface extends PlivoResourceInterface { value: dst, validators: ['isRequired'] }, - { - field: 'text', - value: text, - validators: ['isRequired'] - }, ]); if (errors) { diff --git a/lib/resources/recordings.js b/lib/resources/recordings.js index 91bf16c7..0e26b73c 100644 --- a/lib/resources/recordings.js +++ b/lib/resources/recordings.js @@ -29,6 +29,10 @@ export class RetrieveRecordingResponse { this.resourceUri = params.resourceUri; this.fromNumber = params.fromNumber; this.toNumber = params.toNumber; + this.monthlyRecordingStorageAmount = params.monthlyRecordingStorageAmount; + this.roundedRecordingDuration = params.roundedRecordingDuration; + this.recordingStorageDuration = params.recordingStorageDuration; + this.recordingStorageRate = params.recordingStorageRate; } } @@ -52,6 +56,10 @@ export class ListRecordingResponse { this.mpcName = params.mpcName; this.conferenceUuid = params.conferenceUuid; this.mpcUuid = params.mpcUuid; + this.monthlyRecordingStorageAmount = params.monthlyRecordingStorageAmount; + this.roundedRecordingDuration = params.roundedRecordingDuration; + this.recordingStorageDuration = params.recordingStorageDuration; + this.recordingStorageRate = params.recordingStorageRate; } } @@ -156,6 +164,7 @@ export class RecordingInterface extends PlivoResourceInterface { * @param {string} [params.addTime] - Filter based on the timings they were added * @param {string} [params.limit] - Display no of results per page * @param {string} [params.offset] - No of value items by which results should be offset + * @param {string} [params.recordingStorageDuration] - Filter based on how old the recordings are */ list(params = {}) { params.isVoiceRequest = 'true'; diff --git a/lib/rest/axios.js b/lib/rest/axios.js index 99502844..d4c559c4 100644 --- a/lib/rest/axios.js +++ b/lib/rest/axios.js @@ -21,7 +21,7 @@ export function Axios(config) { let counter = 0; axios.interceptors.response.use(null, (error) => { const config = error.config; - if (counter < max_time && error.response.status >= 500) { + if (counter < max_time && error.response && error.response.status >= 500) { counter++; config.url = options.urls[counter] + options.authId + '/' + options.action; return new Promise((resolve) => { @@ -76,6 +76,7 @@ export function Axios(config) { 401: Exceptions.AuthenticationError, 404: Exceptions.ResourceNotFoundError, 405: Exceptions.InvalidRequestError, + 406: Exceptions.NotAcceptableError, 500: Exceptions.ServerError, } [response.status] || Error; @@ -103,6 +104,7 @@ export function Axios(config) { 401: Exceptions.AuthenticationError, 404: Exceptions.ResourceNotFoundError, 405: Exceptions.InvalidRequestError, + 406: Exceptions.NotAcceptableError, 500: Exceptions.ServerError, } [error.response.status] || Error; if (!_.inRange(error.response.status, 200, 300)) { @@ -193,6 +195,7 @@ export function Axios(config) { 401: Exceptions.AuthenticationError, 404: Exceptions.ResourceNotFoundError, 405: Exceptions.InvalidRequestError, + 406: Exceptions.NotAcceptableError, 500: Exceptions.ServerError, } [response.status] || Error; @@ -219,6 +222,7 @@ export function Axios(config) { 401: Exceptions.AuthenticationError, 404: Exceptions.ResourceNotFoundError, 405: Exceptions.InvalidRequestError, + 406: Exceptions.NotAcceptableError, 500: Exceptions.ServerError, } [error.response.status] || Error; if (!_.inRange(error.response.status, 200, 300)) { @@ -242,6 +246,7 @@ export function Axios(config) { 401: Exceptions.AuthenticationError, 404: Exceptions.ResourceNotFoundError, 405: Exceptions.InvalidRequestError, + 406: Exceptions.NotAcceptableError, 500: Exceptions.ServerError, } [response.status] || Error; @@ -275,6 +280,7 @@ export function Axios(config) { 401: Exceptions.AuthenticationError, 404: Exceptions.ResourceNotFoundError, 405: Exceptions.InvalidRequestError, + 406: Exceptions.NotAcceptableError, 500: Exceptions.ServerError, } [error.response.status] || Error; if (!_.inRange(error.response.status, 200, 300)) { diff --git a/lib/rest/request-test.js b/lib/rest/request-test.js index bd61c565..461481b9 100644 --- a/lib/rest/request-test.js +++ b/lib/rest/request-test.js @@ -1696,7 +1696,8 @@ export function Request(config) { total_amount: '0.00000', total_rate: '0.00350', units: 1, - requester_ip: "192.168.1.1" + requester_ip: "192.168.1.1", + is_domestic: false } }); } @@ -1784,14 +1785,14 @@ export function Request(config) { } }); } - else if (action=='NumberPool/659c7f88-c819-46e2-8af4-2d8a84249099/Shortcode/4444444/' && method == 'GET'){ + else if (action=='NumberPool/659c7f88-c819-46e2-8af4-2d8a84249099/Shortcode/444444/' && method == 'GET'){ resolve({ response: {}, body: { added_on: '2019-09-03T08:50:09.578928Z', country_iso2: 'CA', number_pool_uuid: '659c7f88-c819-46e2-8af4-2d8a84249099', - shortcode: '444444' + shortCode: '444444' } }); } @@ -1938,7 +1939,8 @@ export function Request(config) { total_amount: '0.00000', total_rate: '0.00350', units: 1, - requester_ip: '192.168.1.2' + requester_ip: '192.168.1.2', + is_domestic: false } }); } @@ -1967,7 +1969,8 @@ export function Request(config) { total_amount: '0.00000', total_rate: '0.00350', units: 1, - requester_ip: "192.168.1.1" + requester_ip: "192.168.1.1", + is_domestic: false }, { error_code: '200', @@ -1982,7 +1985,8 @@ export function Request(config) { total_amount: '0.00000', total_rate: '0.00350', units: 1, - requester_ip: "192.168.1.2" + requester_ip: "192.168.1.2", + is_domestic: false } ] } diff --git a/lib/utils/exceptions.js b/lib/utils/exceptions.js index 9d72ae07..caa0bcda 100644 --- a/lib/utils/exceptions.js +++ b/lib/utils/exceptions.js @@ -5,3 +5,4 @@ export class InvalidRequestError extends PlivoRestError { } export class PlivoXMLError extends PlivoRestError { } export class PlivoXMLValidationError extends PlivoRestError { } export class AuthenticationError extends PlivoRestError { } +export class NotAcceptableError extends PlivoRestError { } \ No newline at end of file diff --git a/package.json b/package.json index b5271071..53f51f55 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plivo", - "version": "4.40.0", + "version": "4.43.1", "description": "A Node.js SDK to make voice calls and send SMS using Plivo and to generate Plivo XML", "homepage": "https://github.com/plivo/plivo-node", "files": [ @@ -63,7 +63,7 @@ "https-proxy-agent": "^5.0.0", "build-url": "^1.0.10", "form-data": "^4.0.0", - "jsonwebtoken": "^8.5.1", + "jsonwebtoken": "^9.0.0", "lodash": "^4.17.4", "querystring": "^0.2.0", "uri-parser": "^1.0.0", diff --git a/setup_sdk.sh b/setup_sdk.sh index a1dd08d7..67868d69 100755 --- a/setup_sdk.sh +++ b/setup_sdk.sh @@ -39,13 +39,17 @@ npm init -y npm install $package rm $package -echo -e "\n\nSDK setup complete!" -echo "To test your changes:" -echo -e "\t1. Add your test code in /$testDir/test.js on host (or /usr/src/app/$testDir/test.js in the container)" -echo -e "\t2. Run a terminal in the container using: $GREEN docker exec -it $HOSTNAME /bin/bash$NC" -echo -e "\t3. Navigate to the test directory: $GREEN cd /usr/src/app/$testDir$NC" -echo -e "\t4. Run your test file: $GREEN node test.js$NC" -echo -e "\t5. For running unit tests, run on host: $GREEN make test CONTAINER=$HOSTNAME$NC" +echo -e "\n\nSDK setup complete! You can test changes either on host or inside the docker container:" +echo -e "\ta. To test your changes ON HOST:" +echo -e "\t\t1. Add your test code in /$testDir/test.js" +echo -e "\t\t2. Run your test file using: $GREEN make run CONTAINER=$HOSTNAME$NC" +echo -e "\t\t3. Run unit tests using: $GREEN make test CONTAINER=$HOSTNAME$NC" +echo +echo -e "\tb. To test your changes INSIDE CONTAINER:" +echo -e "\t\t1. Run a terminal in the container using: $GREEN docker exec -it $HOSTNAME /bin/bash$NC" +echo -e "\t\t2. Add your test code in /usr/src/app/$testDir/test.js" +echo -e "\t\t3. Run your test file using: $GREEN make run$NC" +echo -e "\t\t4. Run unit tests using: $GREEN make test$NC" # To keep the container running post setup /bin/bash \ No newline at end of file diff --git a/test/powerpacks.js b/test/powerpacks.js index 949b71ee..dae4ae80 100644 --- a/test/powerpacks.js +++ b/test/powerpacks.js @@ -62,15 +62,15 @@ describe('PowerpackInterface', function () { it('find shortcode via interface', function () { client.powerpacks.get("5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46").then( function (powerpack) { - return powerpack.find_shortcode('4444444') + return powerpack.find_shortcode('444444') }).then(function (ppk) { - assert.equal(ppk.shortcode, "4444444") + assert.equal(ppk.shortCode, "444444") }); }); it('list shortcode via interface', function () { client.powerpacks.get("5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46").then( function (powerpack) { - return powerpack.list_shortcodes('4444444') + return powerpack.list_shortcodes('444444') }) .then(function (result) { assert.notEqual(result.length, 0) diff --git a/types/resources/messages.d.ts b/types/resources/messages.d.ts index 8910dc28..3eb29f1e 100644 --- a/types/resources/messages.d.ts +++ b/types/resources/messages.d.ts @@ -22,6 +22,7 @@ export class MessageGetResponse { units: string; powerpackId: string; requesterIp: string; + isDomestic: boolean; } export class MessageListResponse { constructor(params: object); @@ -39,6 +40,7 @@ export class MessageListResponse { units: string; powerpackId: string; requesterIp: string; + isDomestic: boolean; } export class MMSMediaResponse { constructor(params: object);