Skip to content

Commit

Permalink
merged with master
Browse files Browse the repository at this point in the history
  • Loading branch information
anindya-plivo committed Jun 28, 2023
2 parents 45fd503 + 248d8b3 commit cb1128f
Show file tree
Hide file tree
Showing 20 changed files with 197 additions and 50 deletions.
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
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,21 @@ node_modules
coverage
dist
node-sdk-test/

# Logs
logs
*.log
npm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Coverage directory used by tools like istanbul
*.lcov

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
54 changes: 52 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,60 @@
# Change Log

## [v4.40.0](https://github.com/plivo/plivo-go/tree/v4.40.0) (2022-02-10)
## [v4.50.0](https://github.com/plivo/plivo-go/tree/v4.50.0) (2023-06-28)
**Feature - Audio Streaming**
- `Audio Stream over Call` added API to start and stop streaming on a live call and get details of running or stopped streams. Also implemented the ability to generate stream XML.

## [4.39.0](https://github.com/plivo/plivo-node/tree/v4.39.0) (2022-01-25)
## [4.49.0](https://github.com/plivo/plivo-node/tree/v4.49.0) (2023-06-02)
**Feature - CNAM Lookup**
- Added New Param `cnam_lookup` in to the response of the [list all numbers API], [list single number API]
- Added `cnam_lookup` filter to AccountPhoneNumber - list all my numbers API.
- Added `cnam_lookup` parameter to buy number[Buy a Phone Number] to configure CNAM Lookup while buying a US number
- Added `cnam_lookup` parameter to update number[Update an account phone number] to configure CNAM Lookup while buying a US number

## [4.48.0](https://github.com/plivo/plivo-node/tree/v4.43.1) (2023-03-16)
**Feature : Adding new param in getCallDetails API**
- Added CNAM (Caller_id Name) details at CDR level.

## [v4.47.0](https://github.com/plivo/plivo-node/tree/v4.47.0) (2023-05-29)
- 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)

## [v4.46.1](https://github.com/plivo/plivo-node/tree/v4.46.1) (2023-05-08)
**Chore - Bump xml2js from 0.4.19 to 0.5.0**
- Resolves [xml2js is vulnerable to prototype pollution](https://github.com/advisories/GHSA-776f-qx25-q3cc)

## [4.46.0](https://github.com/plivo/plivo-node/tree/v4.46.0) (2023-05-04)
**Adding new attribute - 'renewalDate' in Get Number and List Numbers APIs**
- Add New Param `renewalDate` to the response of the [list all numbers API], [list single number API]
- Add 3 new filters to AccountPhoneNumber - list all my numbers API:`renewal_date`, `renewal_date__gt`, `renewal_date__gte`,`renewal_date__lt` and `renewal_date__lte` (https://www.plivo.com/docs/numbers/api/account-phone-number#list-all-my-numbers)

## [4.45.0](https://github.com/plivo/plivo-node/tree/v4.45.0) (2023-04-25)
**Adding new attribute - 'isDomestic' in Get Message and List Message APIs**
- Add `replacedSender` 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)
- Add `apiId` to the response for the list all messages API

## [v4.44.0](https://github.com/plivo/plivo-node/tree/v4.44.0) (2023-04-11)
**Feature - Added New Param 'source_ip' in GetCall and ListCalls**
- Add `source_ip` to the response for the [retrieve a call details API](https://www.plivo.com/docs/voice/api/call#retrieve-a-call) and the [retreive all call details API](https://www.plivo.com/docs/voice/api/call#retrieve-all-calls)

## [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

## [v4.39.0](https://github.com/plivo/plivo-node/tree/v4.39.0) (2022-01-25)
**Feature - Added New Param(requesterIP) in Get Message and List Mssage APIs**
- Add `requesterIP` 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)

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)
8 changes: 6 additions & 2 deletions lib/resources/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export class RetrieveCallResponse {
this.totalAmount = params.totalAmount;
this.totalRate = params.totalRate;
this.stirVerification = params.stirVerification;
this.stirAttestation = params.stirAttestation
this.stirAttestation = params.stirAttestation;
this.sourceIp = params.sourceIp;
this.cnamLookup = params.cnamLookup;
}
}

Expand All @@ -129,7 +131,9 @@ export class ListAllCallsResponse {
this.totalAmount = params.totalAmount;
this.totalRate = params.totalRate;
this.stirVerification = params.stirVerification;
this.stirAttestation = params.stirAttestation
this.stirAttestation = params.stirAttestation;
this.sourceIp = params.sourceIp;
this.cnamLookup = params.cnamLookup;
}
}

Expand Down
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
21 changes: 15 additions & 6 deletions lib/resources/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ export class MessageGetResponse {
this.totalAmount = params.totalAmount;
this.totalRate = params.totalRate;
this.units = params.units;
this.powerpackID = params.powerpackId;
this.powerpackID = params.powerpackId
this.tendlcCampaignId = params.tendlcCampaignId;
this.tendlcRegistrationStatus = params.tendlcRegistrationStatus;
this.destinationCountryIso2 = params.destinationCountryIso2;
this.requesterIP = params.requesterIp;
this.isDomestic = params.isDomestic;
this.replacedSender = params.replacedSender;
}
}

Expand All @@ -65,7 +70,12 @@ export class MessageListResponse {
this.totalRate = params.totalRate;
this.units = params.units;
this.powerpackID = params.powerpackId;
this.tendlcCampaignId = params.tendlcCampaignId;
this.tendlcRegistrationStatus = params.tendlcRegistrationStatus;
this.destinationCountryIso2 = params.destinationCountryIso2;
this.requesterIP = params.requesterIp;
this.isDomestic = params.isDomestic;
this.replacedSender = params.replacedSender;
}
}

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

if (errors) {
Expand Down Expand Up @@ -328,6 +333,10 @@ export class MessageInterface extends PlivoResourceInterface {
value: response.body.meta,
enumerable: true
});
Object.defineProperty(objects, 'apiId', {
value: response.body.apiId,
enumerable: true
})
response.body.objects.forEach(item => {
objects.push(new MessageListResponse(item, client));
});
Expand Down
27 changes: 18 additions & 9 deletions lib/resources/numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ const idField = 'number';


export class BuyNumberResponse {
constructor(params) {
constructor(params, statusCode) {
params = params || {};
this.apiId = params.apiId;
this.numbers = params.numbers;
this.status = params.status;

this.message = params.message;
this.statusCode = statusCode;
}
}

Expand Down Expand Up @@ -77,13 +78,14 @@ export class PhoneNumber extends PlivoResource {
* Buy Phone Number
* @method
* @param {string} appId - app id
* @param {string} cnamLookup - cnam lookup
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(number,appId) {
buy(number,appId,cnamLookup) {
return new PhoneNumberInterface(this[clientKey], {
id: this.id
}).buy(number,appId);
}).buy(number,appId,cnamLookup);
}
}

Expand All @@ -106,20 +108,24 @@ export class PhoneNumberInterface extends PlivoResourceInterface {
* Buy Phone Number
* @method
* @param {string} appId - app id
* @param {string} cnamLookup - cnam lookup
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(number, appId) {
buy(number, appId,cnamLookup) {
let params = {};
if (appId) {
params.app_id = appId;
}
if (cnamLookup) {
params.cnam_lookup = cnamLookup;
}
let client = this[clientKey];

return new Promise((resolve, reject) => {
client('POST', 'PhoneNumber/' + number + '/', params)
.then(response => {
resolve(new BuyNumberResponse(response.body, idField));
resolve(new BuyNumberResponse(response.body, response.response.status, idField));
})
.catch(error => {
reject(error);
Expand Down Expand Up @@ -172,6 +178,7 @@ export class NumberResource extends PlivoResource {
* @param {string} [params.appId] - app id
* @param {string} [params.subAccount] - auth_id of subaccount
* @param {string} [params.alias] - textual name of number
* @param {string} [params.cnamLookup] - cnam lookup of number
* @promise {@link NumberResource} return NumberResource Object if success
* @fail {Error} return Error
*/
Expand Down Expand Up @@ -217,10 +224,11 @@ export class NumberInterface extends PlivoResourceInterface {
* @method
* @param {string} number - number to buy
* @param {string} appId - app id
* @param {string} cnamLookup - cnam lookup
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(number, appId) {
buy(number, appId, cnamLookup) {
let errors = validate([{
field: 'number',
value: number,
Expand All @@ -232,7 +240,7 @@ export class NumberInterface extends PlivoResourceInterface {
}
return new PhoneNumber(this[clientKey], {
id: number
}).buy(number, appId);
}).buy(number, appId, cnamLookup);
}

/**
Expand Down Expand Up @@ -271,7 +279,7 @@ export class NumberInterface extends PlivoResourceInterface {
params.numbers = numbers;
params.carrier = carrier;
params.region = region;

let client = this[clientKey];
return new Promise((resolve, reject) => {
client('POST', action, params)
Expand Down Expand Up @@ -316,6 +324,7 @@ export class NumberInterface extends PlivoResourceInterface {
* @param {string} [params.appId] - app id
* @param {string} [params.subAccount] - auth_id of subaccount
* @param {string} [params.alias] - textual name of number
* @param {string} [params.cnamLookup] - cnam lookup of number
* @promise {@link NumberResource} return NumberResource Object if success
* @fail {Error} return Error
*/
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
Loading

0 comments on commit cb1128f

Please sign in to comment.