From bb14815c9e76b2ec369f7056a8cf8303a297f30b Mon Sep 17 00:00:00 2001 From: Shubham Prasad Date: Thu, 5 Dec 2019 10:52:52 +0530 Subject: [PATCH 1/4] Send Call Feedback --- examples/callFeedback.js | 9 ++++++ lib/resources/callFeedback.js | 61 +++++++++++++++++++++++++++++++++++ lib/rest/client.js | 2 ++ lib/rest/request.js | 9 ++++++ 4 files changed, 81 insertions(+) create mode 100644 examples/callFeedback.js create mode 100644 lib/resources/callFeedback.js diff --git a/examples/callFeedback.js b/examples/callFeedback.js new file mode 100644 index 0000000..187d662 --- /dev/null +++ b/examples/callFeedback.js @@ -0,0 +1,9 @@ +var Plivo = require('../dist/rest/client.js'); +var client = new Plivo.Client(); + +client.callFeedback.create('call_uuid', 4, ["ISSUE"], "User Feedback").then(function(call_feedback) { + console.log("\n============ send feedback ===========\n", call_feedback) +}) +.catch(function(response) { + console.log("\n============ Error :: ===========\n", response); +}); \ No newline at end of file diff --git a/lib/resources/callFeedback.js b/lib/resources/callFeedback.js new file mode 100644 index 0000000..0bfa535 --- /dev/null +++ b/lib/resources/callFeedback.js @@ -0,0 +1,61 @@ +import {extend, validate} from '../utils/common.js'; +import {PlivoResource, PlivoResourceInterface} from '../base'; +import * as _ from "lodash"; + +const clientKey = Symbol(); +const action = 'Call/'; +const idField = 'callUuid'; +const CALLINSIGHTS_BASE_URL = 'https://stats.plivo.com/' + +export class CallFeedback extends PlivoResource { + constructor(client, data = {}) { + super(action, Call, idField, client); + + if (idField in data) { + this.id = data[idField]; + } + + extend(this, data); + this[clientKey] = client; + } +} + +/** + * Represents a CallFeedback Interface + * @constructor + * @param {function} client - make api call + * @param {object} [data] - data of call + */ +export class CallFeedbackInterface extends PlivoResourceInterface { + constructor(client, data = {}) { + super(action, CallFeedback, idField, client); + extend(this, data); + + this[clientKey] = client; + } + + create(callUUID, rating, issues=[], notes="") { + let errors = validate([ + {field: 'callUUId', value: callUUID, validators: ['isRequired']}, + {field: 'rating', value: rating, validators: ['isRequired']} + ]); + + if (errors) { + return errors; + } + + var params = {}; + params.rating = rating; + if (issues.length > 0) { + params.issues = issues; + } + if (notes.length > 0) { + params.notes = notes; + } + params.isCallInsightsRequest = ""; + params.CallInsightsBaseUrl = CALLINSIGHTS_BASE_URL; + params.CallInsightsRequestPath = `v1/Call/${callUUID}/Feedback/`; + return super.create(params); + } + +} \ No newline at end of file diff --git a/lib/rest/client.js b/lib/rest/client.js index 870cbc9..f2cb2f0 100644 --- a/lib/rest/client.js +++ b/lib/rest/client.js @@ -14,6 +14,7 @@ import { RecordingInterface } from "../resources/recordings"; import { Response } from "../utils/plivoxml"; import { validateSignature } from "../utils/security"; import { stringify } from "./../utils/jsonStrinfigier"; +import { CallFeedbackInterface } from "../resources/callFeedback"; exports.Response = function () { return new Response(); @@ -63,6 +64,7 @@ export class Client { this.numbers = new NumberInterface(client); this.pricings = new PricingInterface(client); this.recordings = new RecordingInterface(client); + this.callFeedback = new CallFeedbackInterface(client); } toJSON() { diff --git a/lib/rest/request.js b/lib/rest/request.js index 51f4227..9096bf7 100644 --- a/lib/rest/request.js +++ b/lib/rest/request.js @@ -21,6 +21,15 @@ export function Request(config) { headers: headers, json: true }; + + if (params.hasOwnProperty('is_call_insights_request')) { + options.url = params.call_insights_base_url + params.call_insights_request_path; + delete params.is_call_insights_request; + delete params.call_insights_base_url; + delete params.call_insights_request_path; + delete options.formData; + options.json = params; + } if (method === 'GET' && options.formData !== '') { let query = '?' + queryString.stringify(params); From 2773aef9755ea623d16dd23ae6cf486281c67f79 Mon Sep 17 00:00:00 2001 From: Shubham Prasad Date: Wed, 29 Jan 2020 17:02:06 +0530 Subject: [PATCH 2/4] edited changelog --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1db41f3..0885942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## [4.1.9](https://github.com/plivo/plivo-node/releases/tag/v4.1.9)(2020-01-29) +- Add Powerpack support. + ## [4.1.8](https://github.com/plivo/plivo-node/releases/tag/v4.1.8)(2019-12-20) - Add Powerpack support. diff --git a/package.json b/package.json index 27f0b5c..feaf2ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plivo", - "version": "4.1.8", + "version": "4.1.9", "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": [ From ab6478b5db40d8f3f078981127e17c064178f388 Mon Sep 17 00:00:00 2001 From: Shubham Prasad Date: Wed, 29 Jan 2020 17:46:43 +0530 Subject: [PATCH 3/4] edited changelod --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0885942..61932c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Change Log ## [4.1.9](https://github.com/plivo/plivo-node/releases/tag/v4.1.9)(2020-01-29) -- Add Powerpack support. +- Send feedback for a Call. ## [4.1.8](https://github.com/plivo/plivo-node/releases/tag/v4.1.8)(2019-12-20) - Add Powerpack support. From 00fc70c5dfd18550af53cb34dfd78ac769bb835e Mon Sep 17 00:00:00 2001 From: nixonsamuel Date: Fri, 27 Mar 2020 13:34:57 +0530 Subject: [PATCH 4/4] bump version to 4.3.0 --- CHANGELOG.md | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9990d85..7626d80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ # Change Log -## [4.2.0](https://github.com/plivo/plivo-node/releases/tag/v4.2.0)(2020-02-25) +## [4.3.0](https://github.com/plivo/plivo-node/releases/tag/v4.3.0)(2020-03-27) +- Add post call quality feedback API support. +## [4.2.0](https://github.com/plivo/plivo-node/releases/tag/v4.2.0)(2020-02-25) - Add Media support. ## [4.1.9](https://github.com/plivo/plivo-node/releases/tag/v4.1.9)(2020-02-12) diff --git a/package.json b/package.json index 1c2c074..ad0297d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plivo", - "version": "4.2.0", + "version": "4.3.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": [