Skip to content

Commit 6b0c3a8

Browse files
author
Dolev Dotan
committed
align with coding patterns
1 parent 099032c commit 6b0c3a8

File tree

1 file changed

+20
-10
lines changed
  • services/tradeoff_analytics

1 file changed

+20
-10
lines changed

services/tradeoff_analytics/v1.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
var extend = require('extend');
2020
var requestFactory = require('../../lib/requestwrapper');
21+
var omit = require('object.omit');
22+
var pick = require('object.pick');
2123

2224
function TradeoffAnalytics(options) {
2325
// Default URL
@@ -35,21 +37,21 @@ function TradeoffAnalytics(options) {
3537
* The resolution contains a set of optimal options,
3638
* their analytical characteristics, and representation on a 2D space.
3739
*
38-
* @param {Array} requestBody.columns List of possible objectives
39-
* @param {String} requestBody.subject Name of the decision problem
40-
* @param {String} requestBody.options A list of options. Typically, the rows in a
40+
* @param {Array} params.columns List of possible objectives
41+
* @param {String} params.subject Name of the decision problem
42+
* @param {String} params.options A list of options. Typically, the rows in a
4143
* table representation of your data
42-
* @param {String} metadataHeader Value of the x-watson-metadata header to be forwarded
44+
* @param {String} params.metadataHeader Value of the x-watson-metadata header to be forwarded
4345
* for analytics purposes
4446
*/
45-
TradeoffAnalytics.prototype.dilemmas = function(requestBody, callback, metadataHeader) {
47+
TradeoffAnalytics.prototype.dilemmas = function(params, callback) {
4648
var parameters = {
4749
options: {
4850
method: 'POST',
4951
url: '/v1/dilemmas',
50-
body: requestBody,
52+
body: omit(params,['metadataHeader']),
5153
headers: {
52-
'x-watson-metadata' : metadataHeader
54+
'x-watson-metadata' : pick(params,['metadataHeader'])
5355
},
5456
json: true
5557
},
@@ -60,16 +62,24 @@ TradeoffAnalytics.prototype.dilemmas = function(requestBody, callback, metadataH
6062
};
6163

6264
/**
65+
*
66+
*/
67+
68+
/**
6369
* Forward events from the Tradeoff Analytics widget to the service
70+
*
71+
* @param {String} params - the array of events to forward to the service
72+
* @param {String} params.metadataHeader Value of the x-watson-metadata header to be forwarded
73+
* for analytics purposes
6474
*/
65-
TradeoffAnalytics.prototype.events = function(requestBody, callback, metadataHeader) {
75+
TradeoffAnalytics.prototype.events = function(params, callback) {
6676
var parameters = {
6777
options: {
6878
method: 'POST',
6979
url: '/v1/events',
70-
body: requestBody,
80+
body: omit(params,['metadataHeader']),
7181
headers: {
72-
'x-watson-metadata' : metadataHeader
82+
'x-watson-metadata' : pick(params,['metadataHeader'])
7383
},
7484
json: true
7585
},

0 commit comments

Comments
 (0)