version bump

This commit is contained in:
narayana 2021-10-31 10:51:18 +05:30
parent dbafd8924e
commit cba8ea4298
10 changed files with 529 additions and 1 deletions

View file

@ -1,5 +1,8 @@
# Change Log
## [v4.24.0](https://github.com/plivo/plivo-node/tree/v4.24.0) (2021-12-02)
-- 10dlc Api support.
## [v4.23.1](https://github.com/plivo/plivo-node/tree/v4.23.1) (2021-10-13)
**Bug Fix**
- LiveCallInterface.

134
lib/resources/brand.js Normal file
View file

@ -0,0 +1,134 @@
import * as _ from "lodash";
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
} from '../utils/common.js';
const action = '10dlc/Brand/';
const idField = 'brand_id';
let clientKey = Symbol();
let idKey = Symbol('id filed');
/**
* Represents a Brand
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class Brand extends PlivoResource {
constructor(client, data = {}) {
super(action, Brand, idField, client);
this[actionKey] = action;
this[clientKey] = client;
extend(this, data);
}
}
export class BrandCreationResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.brand = params.brand;
}
}
/**
* Represents a Brand Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class BrandInterface extends PlivoResource {
constructor(client, data = {}) {
super(action, Brand, idField, client);
extend(this, data);
this[clientKey] = client;
}
/**
* get Brand by given id
* @method
* @param {string} brandID - id of brand
* @promise {object} return {@link Brand} object
* @fail {Error} return Error
*/
get(brandId) {
let params = {}
return super.customexecuteAction(action+brandId+'/', 'GET', params);
}
/**
* Get All Brand Detail
* @method
* @param {object} params - params type and status to get all brand details.
* @promise {object[]} returns list of Brand Object
* @fail {Error} returns Error
*/
list(params) {
return super.customexecuteAction(action, 'GET', params);
}
/**
* Brand Registration
* @method
* @param {object} params
* @param {string} city
* @param {string} company_name
* @param {string} country
* @param {string} ein
* @param {string} ein_issuing_country
* @param {string} email
* @param {string} entity_type
* @param {string} postal_code
* @param {string} registration_status
* @param {string} state
* @param {string} stock_exchange
* @param {string} stock_symbol
* @param {string} street
* @param {string} vertical
* @param {string} [params.website] -
* @param {string} [params.secondary_vetting]
* @param {string} [params.first_name]
* @param {string} [params.last_name]
* @param {string} [params.alt_business_id_type]
* @param {string} [params.alt_business_id]
* @promise {object} return {@link PlivoGenericResponse} object
* @fail {Error} return Error
*/
create(city,company_name,country,ein,ein_issuing_country,email,entity_type,phone,postal_code,registration_status,state,stock_exchange,stock_symbol,street,vertical, params = {}) {
params.city=city;
params.company_name=company_name;
params.country=country;
params.ein=ein;
params.ein_issuing_country=ein_issuing_country;
params.email=email;
params.entity_type=entity_type;
params.phone=phone;
params.postal_code=postal_code;
params.registration_status=registration_status;
params.state=state;
params.stock_exchange=stock_exchange;
params.stock_symbol=stock_symbol;
params.street=street;
params.vertical=vertical;
let client = this[clientKey];
let idField = this[idKey];
return new Promise((resolve, reject) => {
client('POST', action, params)
.then(response => {
resolve(new BrandCreationResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
}

139
lib/resources/campaign.js Normal file
View file

@ -0,0 +1,139 @@
import * as _ from "lodash";
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
} from '../utils/common.js';
const action = '10dlc/Campaign/';
const idField = 'brandID';
let actionKey = Symbol('api action');
let klassKey = Symbol('constructor');
let idKey = Symbol('id filed');
let clientKey = Symbol('make api call');
/**
* Represents a Campaign
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class Campaign extends PlivoResource {
constructor(client, data = {}) {
super(action, Campaign, idField, client);
this[actionKey] = action;
this[clientKey] = client;
if (idField in data) {
this.id = data[idField];
};
extend(this, data);
}
}
export class CampaignCreateResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.campaign = params.campaign;
}
}
/**
* Represents a Campaign Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class CampaignInterface extends PlivoResource {
constructor(client, data = {}) {
super(action, Campaign, idField, client);
extend(this, data);
this[clientKey] = client;
this[actionKey] = action;
this[klassKey] = Campaign;
this[idKey] = idField;
}
/**
* get Campaign by given id
* @method
* @param {string} campaignID - id of Campaign
* @promise {object} return {@link Campaign} object
* @fail {Error} return Error
*/
get(campaignID) {
let params = {};
return super.customexecuteAction(action+campaignID+'/', 'GET', params);
}
/**
* Get All Campaign Detail
* @method
* @param {object} params - params brand and usecase to get all campaign details.
* @promise {object[]} returns list of campaign Object
* @fail {Error} returns Error
*/
list(params) {
return super.customexecuteAction(action,'GET', params);
}
/**
* create Campaign
* @method
* @param {string} brand_id
* @param {string} campaign_alias
* @param {string} vertical
* @param {string} usecase
* @param {list} sub_usecases
* @param {string} description
* @param {boolean} embedded_link
* @param {boolean} embedded_phone
* @param {boolean} age_gated
* @param {boolean} direct_lending
* @param {boolean} subscriber_optin
* @param {boolean} subscriber_optout
* @param {boolean} subscriber_help
* @param {string} sample1
* @param {string} sample2
* @promise {object} return {@link PlivoGenericResponse} object
* @fail {Error} return Error
*/
create(brand_id,campaign_alias,vertical,usecase,sub_usecases,description,embedded_link,embedded_phone,age_gated,direct_lending,subscriber_optin,subscriber_optout,subscriber_help,sample1,sample2) {
let params = {}
params.brand_id=brand_id;
params.campaign_alias=campaign_alias;
params.vertical=vertical;
params.usecase=usecase;
params.sub_usecases=sub_usecases;
params.description=description;
params.embedded_link=embedded_link;
params.embedded_phone=embedded_phone;
params.age_gated=age_gated;
params.direct_lending=direct_lending;
params.subscriber_optin=subscriber_optin;
params.subscriber_optout=subscriber_optout;
params.subscriber_help=subscriber_help;
params.sample1=sample1;
params.sample2=sample2;
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('POST', action, params)
.then(response => {
resolve(new CampaignCreateResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
}

View file

@ -33,6 +33,12 @@ import {
import {
PowerpackInterface
} from '../resources/powerpacks.js';
import {
BrandInterface
} from '../resources/brand.js';
import{
CampaignInterface
} from '../resources/campaign.js';
import {
NumberInterface
} from '../resources/numbers.js';
@ -91,6 +97,8 @@ export class Client {
this.conferences = new ConferenceInterface(client);
this.endpoints = new EndpointInterface(client);
this.messages = new MessageInterface(client);
this.brand = new BrandInterface(client);
this.campaign = new CampaignInterface(client);
this.lookup = new LookupInterface(client);
this.powerpacks = new PowerpackInterface(client);
this.numbers = new NumberInterface(client);

View file

@ -10,6 +10,8 @@ import { EndpointInterface } from "../resources/endpoints";
import { MessageInterface } from "../resources/messages";
import { LookupInterface } from "../resources/lookup";
import { PowerpackInterface } from "../resources/powerpacks";
import { BrandInterface } from "../resources/brand.js";
import { CampaignInterface } from "../resources/campaign.js";
import { NumberInterface } from "../resources/numbers";
import { PricingInterface } from "../resources/pricings";
import { RecordingInterface } from "../resources/recordings";
@ -87,6 +89,8 @@ export class Client {
this.messages = new MessageInterface(client);
this.lookup = new LookupInterface(client);
this.powerpacks = new PowerpackInterface(client);
this.brand = new BrandInterface(client);
this.campaign = new CampaignInterface(client);
this.numbers = new NumberInterface(client);
this.pricings = new PricingInterface(client);
this.recordings = new RecordingInterface(client);

View file

@ -1158,6 +1158,172 @@ export function Request(config) {
}
});
}
else if (action == '10dlc/Brand/BRPXS6E/' && method == 'GET'){
resolve({
response: {},
body: {
api_id: "71aa47e0-3750-11ec-8e4c-0242ac110002",
brand: {
brand_id: "BRPXS6E",
company_name: "ABC Inc.",
ein: "111111111",
ein_issuing_country: "US",
email: "johndoe@abc.com",
entity_type: "PRIVATE_PROFIT",
registration_status: "COMPLETED",
vertical: "RETAIL",
website: "http://www.abcmobile.com"
}
}
});
}
else if (action == '10dlc/Campaign/CMPT4EP/' && method == 'GET'){
resolve({
response: {},
body: {
api_id: "12ae5a32-3751-11ec-8e4c-0242ac110002",
campaign: {
brand_id: "BHYYNCK",
campaign_id: "CMPT4EP",
mno_metadata: {
AT_T: {
tpm: 4500
},
T_Mobile: {
brand_tier: "TOP"
},
Verizon_Wireless: {}
},
reseller_id: "RPDPPUM",
usecase: "ACCOUNT_NOTIFICATION"
}
}
});
}
else if (action == '10dlc/Brand/' && method == 'GET'){
resolve({
response: {},
body: {
api_id: "b9df43c0-374c-11ec-97b3-0242ac110002",
brands: [
{
brand_id: "ABCDEFG",
company_name: "ABC Inc.",
ein: "111111111",
ein_issuing_country: "US",
email: "johndoe@abc.com",
entity_type: "PRIVATE_PROFIT",
registration_status: "COMPLETED",
vertical: "RETAIL",
website: "http://www.abcmobile.com"
},
{
brand_id: "QWERTYU",
company_name: "ABC Inc.",
ein: "111111111",
ein_issuing_country: "US",
email: "johndoe@abc.com",
entity_type: "PRIVATE_PROFIT",
registration_status: "COMPLETED",
vertical: "RETAIL",
website: "http://www.abcmobile.com"
}
]
}
});
}
else if (action == '10dlc/Campaign/' && method == 'GET'){
resolve({
response: {},
body: {
api_id: "5e639fd0-374e-11ec-8e4c-0242ac110002",
campaigns: [
{
brand_id: "BHYYNCK",
campaign_id: "CMPT4EP",
mno_metadata: {
AT_T: {
tpm: 4500
},
T_Mobile: {
brand_tier: "TOP"
},
Verizon_Wireless: {}
},
reseller_id: "RPDPPUM",
usecase: "ACCOUNT_NOTIFICATION"
},
{
brand_id: "B8OD95Z",
campaign_id: "CAIKXXT",
mno_metadata: {
AT_T: {
tpm: 4500
},
T_Mobile: {
brand_tier: "TOP"
},
US_Cellular: {},
Verizon_Wireless: {}
},
reseller_id: "",
usecase: "MIXED"
}
]
}
});
}
else if (action == '10dlc/Brand/' && method == 'POST'){
resolve({
response: {},
body: {
api_id: "a52a5398-3751-11ec-8e4c-0242ac110002",
brand: {
alt_business_id_type: "GIIN",
brand_id: "BVI0UQA",
city: "New York",
country: "US",
ein_issuing_country: "US",
email: "johndoe@abc.com",
entity_type: "SOLE_PROPRIETOR",
first_name: "John",
last_name: "Doe",
phone: "+11234567890",
postal_code: "10001",
registration_status: "PENDING",
state: "NY",
stock_exchange: "NASDAQ",
stock_symbol: "ABC",
street: "123",
vertical: "RETAIL",
website: "http://www.abcmobile.com"
}
}
});
}
else if (action == '10dlc/Campaign/' && method == 'POST'){
resolve({
response: {},
body: {
api_id: "12ae5a32-3751-11ec-8e4c-0242ac110002",
campaign: {
brand_id: "BHYYNCK",
campaign_id: "CMPT4EP",
mno_metadata: {
AT_T: {
tpm: 4500
},
T_Mobile: {
brand_tier: "TOP"
},
Verizon_Wireless: {}
},
reseller_id: "RPDPPUM",
usecase: "ACCOUNT_NOTIFICATION"
}
}
});
}
else if (action == 'Powerpack/5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46/' && method == 'GET'){
resolve({
response: {},

View file

@ -53,6 +53,8 @@ export function camelCaseRequestWrapper(requestFunc) {
.replace('priority_1', 'priority1')
.replace('priority_2', 'priority2')
.replace('priority_3', 'priority3')
.replace('sample_1', 'sample1')
.replace('sample_2', 'sample2')
.replace('country_iso_2', 'country_iso2');
});

View file

@ -1,6 +1,6 @@
{
"name": "plivo",
"version": "4.23.1",
"version": "4.24.0",
"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": [

36
test/brand.js Normal file
View file

@ -0,0 +1,36 @@
import {
Client
} from '../lib/rest/client-test';
import {
PlivoGenericResponse
} from '../lib/base.js';
import assert from 'assert';
import sinon from 'sinon';
let client = new Client('sampleid', 'sammpletoken', 'sampleproxy');
describe('brand', function () {
it('should get brand', function () {
return client.brand.get('BRPXS6E')
.then(function (brand) {
assert.equal(brand.brand.brandId, 'BRPXS6E')
})
});
it('list brand', function () {
return client.brand.list()
.then(function (brand) {
assert.equal(brand.brands.length, 2)
})
});
it('create brand', function () {
return client.brand.create("New York","ABC Inc.", "US", "111111111","US","johndoe@abc.com","PRIVATE_PROFIT","+11234567890","10001","PENDING",
"NY", "NASDAQ","ABC","123", "RETAIL")
.then(function (brand) {
assert.equal(brand.brand.brandId, 'BVI0UQA')
})
});
});

36
test/campaign.js Normal file
View file

@ -0,0 +1,36 @@
import {
Client
} from '../lib/rest/client-test';
import {
PlivoGenericResponse
} from '../lib/base.js';
import assert from 'assert';
import sinon from 'sinon';
let client = new Client('sampleid', 'sammpletoken', 'sampleproxy');
describe('campaign', function () {
it('should get campaign', function () {
return client.campaign.get("CMPT4EP")
.then(function (response) {
assert.equal(response.campaign.campaignId, "CMPT4EP")
})
});
it('list campaign', function () {
return client.campaign.list()
.then(function (response) {
assert.equal(response.campaigns.length, 2)
})
});
it('create campaign', function () {
return client.campaign.create("B8OD95Z","campaign name sssample","INSURANCE","MIXED",[
"CUSTOMER_CARE",
"2FA"
],"sample description text",false,false,false,false,true,true,true,"sample1","sample2")
.then(function (campaign) {
assert.equal(campaign.campaign.brandId, 'BHYYNCK')
})
});
});