Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new params #287

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unitTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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"
@[ "${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)
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,10 @@ export PLIVO_API_PROD_HOST=<plivoapi_public_endpoint>
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=<cont_id>` in host, where `<cont_id>` is the docker container id created in 2.
(The docker container should be running)
6. To run test code, run `make run CONTAINER=<cont_id>` in host.
7. To run unit tests, run `make test CONTAINER=<cont_id>` in host.
> `<cont_id>` 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)
1 change: 0 additions & 1 deletion lib/resources/hostedMessagingNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions lib/resources/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class MessageGetResponse {
this.tendlcRegistrationStatus = params.tendlcRegistrationStatus;
this.destinationCountryIso2 = params.destinationCountryIso2;
this.requesterIP = params.requesterIp;
this.isDomestic = params.isDomestic;
}
}

Expand All @@ -72,6 +73,7 @@ export class MessageListResponse {
this.tendlcRegistrationStatus = params.tendlcRegistrationStatus;
this.destinationCountryIso2 = params.destinationCountryIso2;
this.requesterIP = params.requesterIp;
this.isDomestic = params.isDomestic;
}
}

Expand Down Expand Up @@ -210,11 +212,6 @@ export class MessageInterface extends PlivoResourceInterface {
value: dst,
validators: ['isRequired']
},
{
field: 'text',
value: text,
validators: ['isRequired']
},
]);

if (errors) {
Expand Down
9 changes: 9 additions & 0 deletions lib/resources/recordings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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;
}
}

Expand Down Expand Up @@ -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';
Expand Down
8 changes: 7 additions & 1 deletion lib/rest/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;

Expand All @@ -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)) {
Expand All @@ -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;

Expand Down Expand Up @@ -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)) {
Expand Down
16 changes: 10 additions & 6 deletions lib/rest/request-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
});
}
Expand Down Expand Up @@ -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'
}
});
}
Expand Down Expand Up @@ -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
}
});
}
Expand Down Expand Up @@ -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',
Expand All @@ -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
}
]
}
Expand Down
1 change: 1 addition & 0 deletions lib/utils/exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -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",
Expand Down
18 changes: 11 additions & 7 deletions setup_sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path_to_cloned_sdk>/$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 <path_to_cloned_sdk>/$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
6 changes: 3 additions & 3 deletions test/powerpacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions types/resources/messages.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class MessageGetResponse {
units: string;
powerpackId: string;
requesterIp: string;
isDomestic: boolean;
}
export class MessageListResponse {
constructor(params: object);
Expand All @@ -39,6 +40,7 @@ export class MessageListResponse {
units: string;
powerpackId: string;
requesterIp: string;
isDomestic: boolean;
}
export class MMSMediaResponse {
constructor(params: object);
Expand Down