/**
 * Copyright 2014 IBM Corp. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

var extend         = require('extend');
var requestFactory = require('../../lib/requestwrapper');
var omit           = require('object.omit');

/**
 *
 * @param options
 * @constructor
 */
function TradeoffAnalytics(options) {
  // Default URL
  var defaultOptions = {
    url: 'https://gateway.watsonplatform.net/tradeoff-analytics/api'
  };

  // Replace default options with user provided
  this._options = extend(defaultOptions, options);
}

/**
 * Returns a dilemma that contains the problem and a resolution.
 * The problem contains a set of options and objectives.
 * The resolution contains a set of optimal options,
 * their analytical characteristics, and representation on a 2D space.
 *
 * @param  {Array}  params.columns List of possible objectives
 * @param  {String} params.subject Name of the decision problem
 * @param  {String} params.options A list of options. Typically, the rows in a
 *                                 table representation of your data
 * @param  {String} params.metadataHeader Value of the x-watson-metadata header to be forwarded
 * 								                        for analytics purposes
 * @param  {String} params.generate_visualization Boolean (default = true). if false, the algorithm 
 *                                                will not create the "map" visualization, and will typically run much faster 
 */
TradeoffAnalytics.prototype.dilemmas = function(params, callback) {
  params = params || {};

  var parameters = {
    options: {
      method: 'POST',
      url: '/v1/dilemmas',
      body: omit(params,['metadata_header','generate_visualization']),
      headers: {
        'x-watson-metadata' : params.metadata_header
      },
      qs: params.generate_visualization === false ? {'generate_visualization': false} : undefined,
      json: true
    },
    requiredParams: ['columns', 'subject', 'options'],
    defaultOptions: this._options
  };
  return requestFactory(parameters, callback);
};

 /**
 * Forward events from the Tradeoff Analytics widget to the service
 *
 * @param  {String} params - the array of events to forward to the service
 * @param  {String} params.metadataHeader Value of the x-watson-metadata header to be forwarded
 * 								   for analytics purposes
 */
TradeoffAnalytics.prototype.events = function(params, callback) {
  params = params || {};

  var parameters = {
    options: {
      method: 'POST',
      url: '/v1/events',
      body: omit(params,['metadata_header']),
      headers: {
        'x-watson-metadata' : params.metadata_header
      },
      json: true
    },
    defaultOptions: this._options
  };
  return requestFactory(parameters, callback);
};

module.exports = TradeoffAnalytics;

@@ -2207,16 +2207,17 @@
 header',
+ 
 'generat
@@ -2330,50 +2330,21 @@
 s: p
-arams.generate_visualization === false ? %7B
+ick(params, %5B
 'gen
@@ -2367,28 +2367,10 @@
 ion'
-: false%7D : undefined
+%5D)
 ,%0A  
@@ -3041,16 +3041,42 @@
 _header'
+, 'generate_visualization'
 %5D),%0A    
@@ -3146,24 +3146,76 @@
 er%0A      %7D,%0A
+      qs: pick(params, %5B'generate_visualization'%5D),%0A
       json: 

Update v1.js