-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from plivo/post-feedback
Post feedback
- Loading branch information
Showing
6 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters