From 2dca4a96db88962d78635bac8c9759a99213745e Mon Sep 17 00:00:00 2001 From: kapilp93 Date: Fri, 3 Dec 2021 17:48:36 +0530 Subject: [PATCH] added examples for hostedMessagingNumber and loa --- examples/hostedMessagingNumber.js | 35 ++++++++++++++++++++++++++++++ examples/loa.js | 36 +++++++++++++++++++++++++++++++ lib/rest/client-test.js | 4 ++++ types/rest/client-test.d.ts | 4 ++++ 4 files changed, 79 insertions(+) create mode 100644 examples/hostedMessagingNumber.js create mode 100644 examples/loa.js diff --git a/examples/hostedMessagingNumber.js b/examples/hostedMessagingNumber.js new file mode 100644 index 0000000..332f789 --- /dev/null +++ b/examples/hostedMessagingNumber.js @@ -0,0 +1,35 @@ +var Plivo = require('../dist/rest/client.js'); +var client = new Plivo.Client(); + +var createParams = { + alias:"alias", + applicationId: "applicationId", + loaId:"loaID", + number:"number" +}; + +var listParams = { + alias:"alias", + applicationId: "applicationId", + loaId:"loaID", + number:"number", + hostedStatus: "completed", +}; + + +client.hostedMessagingNumber.create(createParams) + .then(function (hmn) { + console.log("\n============ created ===========\n", hmn) + return client.hostedMessagingNumber.get(hmn.id); + }) + .then(function (hmn) { + console.log("\n============ get ===========\n", hmn) + return client.hostedMessagingNumber.list(listParams) + }) + .then(function (hmns) { + console.log("\n============ list with params ===========\n", hmns) + }) + .catch(function (err) { + console.log("\n============ Error :: ===========\n", err); + }); + diff --git a/examples/loa.js b/examples/loa.js new file mode 100644 index 0000000..3216fe6 --- /dev/null +++ b/examples/loa.js @@ -0,0 +1,36 @@ +var Plivo = require('../dist/rest/client.js'); +var client = new Plivo.Client(); + +var createParams = { + "alias": "Test loa", + "file": "path to file" + +}; + +var listParams = { + alias: "Test loa", + limit: 10, + offset: 5 +}; + + +client.loa.create(createParams) + .then(function (loa) { + console.log("\n============ created ===========\n", loa) + return client.loa.get(loa.id); + }) + .then(function (loa) { + console.log("\n============ get ===========\n", loa) + return client.loa.delete(loa.id); + }) + .then(function (result) { + console.log("\n============ deleted ===========\n", result) + return client.loa.list(listParams) + }) + .then(function (loas) { + console.log("\n============ list with params ===========\n", loas) + }) + .catch(function (err) { + console.log("\n============ Error :: ===========\n", err); + }); + diff --git a/lib/rest/client-test.js b/lib/rest/client-test.js index 0a88610..7dbed8e 100644 --- a/lib/rest/client-test.js +++ b/lib/rest/client-test.js @@ -61,6 +61,8 @@ import { ComplianceDocumentTypeInterface } from "../resources/complianceDocument import { ComplianceDocumentInterface} from "../resources/complianceDocuments"; import { ComplianceRequirementInterface } from "../resources/complianceRequirements"; import { ComplianceApplicationInterface } from "../resources/complianceApplications"; +import { LOAInterface } from "../resources/loa"; +import { HostedMessagingNumberInterface } from "../resources/hostedMessagingNumber"; export class Client { constructor(authId, authToken, proxy) { @@ -111,6 +113,8 @@ export class Client { this.complianceRequirements = new ComplianceRequirementInterface(client); this.complianceApplications = new ComplianceApplicationInterface(client); this.multiPartyCalls = new MultiPartyCallInterface(client); + this.loa = new LOAInterface(client); + this.hostedMessagingNumber = new HostedMessagingNumberInterface(client); } } diff --git a/types/rest/client-test.d.ts b/types/rest/client-test.d.ts index 6e73f73..cd82e78 100644 --- a/types/rest/client-test.d.ts +++ b/types/rest/client-test.d.ts @@ -13,6 +13,8 @@ export class Client { pricings: PricingInterface; recordings: RecordingInterface; media: MediaInterface; + loa: LOAInterface; + hostedMessagingNumber: HostedMessagingNumberInterface; } /** * Plivo API client which can be used to access the Plivo APIs. @@ -37,3 +39,5 @@ import { PricingInterface } from "../resources/pricings.js"; import { RecordingInterface } from "../resources/recordings.js"; import { MediaInterface } from "../resources/media.js"; import { Phlo } from "../resources/phlo.js"; +import { LOAInterface } from "../resources/loa.js"; +import { HostedMessagingNumberInterface } from "../resources/hostedMessagingNumber.js";