HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/fintechfuel/node_modules/pipedrive/dist/api/GoalsApi.js
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _ApiClient = _interopRequireDefault(require("../ApiClient"));
var _AddOrUpdateGoalResponse = _interopRequireDefault(require("../model/AddOrUpdateGoalResponse200"));
var _BasicGoal = _interopRequireDefault(require("../model/BasicGoal"));
var _DeleteGoalResponse = _interopRequireDefault(require("../model/DeleteGoalResponse200"));
var _GetGoalResultResponse = _interopRequireDefault(require("../model/GetGoalResultResponse200"));
var _GetGoalsResponse = _interopRequireDefault(require("../model/GetGoalsResponse200"));
var _NewGoal = _interopRequireDefault(require("../model/NewGoal"));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
/**
* Goals service.
* @module api/GoalsApi
* @version 1.0.0
*/
var GoalsApi = /*#__PURE__*/function () {
  /**
  * Constructs a new GoalsApi. 
  * @alias module:api/GoalsApi
  * @class
  * @param {module:ApiClient} [apiClient] Optional API client implementation to use,
  * default to {@link module:ApiClient#instance} if unspecified.
  */
  function GoalsApi(apiClient) {
    (0, _classCallCheck2["default"])(this, GoalsApi);
    this.apiClient = apiClient;
  }

  /**
   * Add a new goal
   * Adds a new goal. Along with adding a new goal, a report is created to track the progress of your goal.
   * @param {Object} opts Optional parameters
   * @param {module:model/NewGoal} opts.newGoal 
   * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AddOrUpdateGoalResponse200} and HTTP response
   */
  (0, _createClass2["default"])(GoalsApi, [{
    key: "addGoalWithHttpInfo",
    value: function addGoalWithHttpInfo(opts) {
      opts = opts || {};
      var postBody = opts['newGoal'];
      if (opts['assignee'] === undefined || opts['assignee'] === null) {
        throw new Error("Missing the required parameter 'assignee' when calling addGoal");
      }
      if (opts['type'] === undefined || opts['type'] === null) {
        throw new Error("Missing the required parameter 'type' when calling addGoal");
      }
      if (opts['expected_outcome'] === undefined || opts['expected_outcome'] === null) {
        throw new Error("Missing the required parameter 'expected_outcome' when calling addGoal");
      }
      if (opts['duration'] === undefined || opts['duration'] === null) {
        throw new Error("Missing the required parameter 'duration' when calling addGoal");
      }
      if (opts['interval'] === undefined || opts['interval'] === null) {
        throw new Error("Missing the required parameter 'interval' when calling addGoal");
      }
      var pathParams = {};
      var queryParams = {};
      var headerParams = {};
      var formParams = {};
      var formParamArray = [];
      var contentTypes = ['application/json'];
      var isURLEncoded = contentTypes.includes('application/x-www-form-urlencoded');
      var isJSON = contentTypes.includes('application/json');
      if (isJSON) {
        postBody = _objectSpread(_objectSpread({}, postBody), opts);
      } else if (isURLEncoded) {
        for (var key in opts) {
          if (opts.hasOwnProperty(key) && !formParamArray.includes(key)) {
            formParams[key] = opts[key];
          }
        }
      }
      var authNames = ['api_key', 'oauth2'];
      var accepts = ['application/json'];
      var returnType = _AddOrUpdateGoalResponse["default"];
      return this.apiClient.callApi('/goals', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
    }

    /**
     * Add a new goal
     * Adds a new goal. Along with adding a new goal, a report is created to track the progress of your goal.
     * @param {Object} opts Optional parameters
     * @param {module:model/NewGoal} opts.newGoal 
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AddOrUpdateGoalResponse200}
     */
  }, {
    key: "addGoal",
    value: function addGoal(opts) {
      return this.addGoalWithHttpInfo(opts).then(function (response_and_data) {
        return response_and_data;
      });
    }

    /**
     * Delete existing goal
     * Marks a goal as deleted.
     * @param {String} id The ID of the goal
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/DeleteGoalResponse200} and HTTP response
     */
  }, {
    key: "deleteGoalWithHttpInfo",
    value: function deleteGoalWithHttpInfo(id) {
      var opts = {};
      var postBody = null;

      // verify the required parameter 'id' is set
      if (id === undefined || id === null) {
        throw new Error("Missing the required parameter 'id' when calling deleteGoal");
      }
      var pathParams = {
        'id': id
      };
      var queryParams = {};
      var headerParams = {};
      var formParams = {};
      var formParamArray = [];
      var contentTypes = [];
      var isURLEncoded = contentTypes.includes('application/x-www-form-urlencoded');
      var isJSON = contentTypes.includes('application/json');
      if (isJSON) {
        postBody = _objectSpread(_objectSpread({}, postBody), opts);
      } else if (isURLEncoded) {
        for (var key in opts) {
          if (opts.hasOwnProperty(key) && !formParamArray.includes(key)) {
            formParams[key] = opts[key];
          }
        }
      }
      var authNames = ['api_key', 'oauth2'];
      var accepts = ['application/json'];
      var returnType = _DeleteGoalResponse["default"];
      return this.apiClient.callApi('/goals/{id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
    }

    /**
     * Delete existing goal
     * Marks a goal as deleted.
     * @param {String} id The ID of the goal
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/DeleteGoalResponse200}
     */
  }, {
    key: "deleteGoal",
    value: function deleteGoal(id) {
      return this.deleteGoalWithHttpInfo(id).then(function (response_and_data) {
        return response_and_data;
      });
    }

    /**
     * Get result of a goal
     * Gets the progress of a goal for the specified period.
     * @param {String} id The ID of the goal that the results are looked for
     * @param {Date} periodStart The start date of the period for which to find the goal's progress. Format: YYYY-MM-DD. This date must be the same or after the goal duration start date. 
     * @param {Date} periodEnd The end date of the period for which to find the goal's progress. Format: YYYY-MM-DD. This date must be the same or before the goal duration end date. 
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetGoalResultResponse200} and HTTP response
     */
  }, {
    key: "getGoalResultWithHttpInfo",
    value: function getGoalResultWithHttpInfo(id, periodStart, periodEnd) {
      var opts = {};
      var postBody = null;

      // verify the required parameter 'id' is set
      if (id === undefined || id === null) {
        throw new Error("Missing the required parameter 'id' when calling getGoalResult");
      }

      // verify the required parameter 'periodStart' is set
      if (periodStart === undefined || periodStart === null) {
        throw new Error("Missing the required parameter 'periodStart' when calling getGoalResult");
      }

      // verify the required parameter 'periodEnd' is set
      if (periodEnd === undefined || periodEnd === null) {
        throw new Error("Missing the required parameter 'periodEnd' when calling getGoalResult");
      }
      var pathParams = {
        'id': id
      };
      var queryParams = {
        'period.start': periodStart,
        'period.end': periodEnd
      };
      var headerParams = {};
      var formParams = {};
      var formParamArray = [];
      var contentTypes = [];
      var isURLEncoded = contentTypes.includes('application/x-www-form-urlencoded');
      var isJSON = contentTypes.includes('application/json');
      if (isJSON) {
        postBody = _objectSpread(_objectSpread({}, postBody), opts);
      } else if (isURLEncoded) {
        for (var key in opts) {
          if (opts.hasOwnProperty(key) && !formParamArray.includes(key)) {
            formParams[key] = opts[key];
          }
        }
      }
      var authNames = ['api_key', 'oauth2'];
      var accepts = ['application/json'];
      var returnType = _GetGoalResultResponse["default"];
      return this.apiClient.callApi('/goals/{id}/results', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
    }

    /**
     * Get result of a goal
     * Gets the progress of a goal for the specified period.
     * @param {String} id The ID of the goal that the results are looked for
     * @param {Date} periodStart The start date of the period for which to find the goal's progress. Format: YYYY-MM-DD. This date must be the same or after the goal duration start date. 
     * @param {Date} periodEnd The end date of the period for which to find the goal's progress. Format: YYYY-MM-DD. This date must be the same or before the goal duration end date. 
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetGoalResultResponse200}
     */
  }, {
    key: "getGoalResult",
    value: function getGoalResult(id, periodStart, periodEnd) {
      return this.getGoalResultWithHttpInfo(id, periodStart, periodEnd).then(function (response_and_data) {
        return response_and_data;
      });
    }

    /**
     * Find goals
     * Returns data about goals based on criteria. For searching, append `{searchField}={searchValue}` to the URL, where `searchField` can be any one of the lowest-level fields in dot-notation (e.g. `type.params.pipeline_id`; `title`). `searchValue` should be the value you are looking for on that field. Additionally, `is_active=<true|false>` can be provided to search for only active/inactive goals. When providing `period.start`, `period.end` must also be provided and vice versa.
     * @param {Object} opts Optional parameters
     * @param {module:model/String} opts.typeName The type of the goal. If provided, everyone's goals will be returned.
     * @param {String} opts.title The title of the goal
     * @param {Boolean} opts.isActive Whether the goal is active or not (default to true)
     * @param {Number} opts.assigneeId The ID of the user who's goal to fetch. When omitted, only your goals will be returned.
     * @param {module:model/String} opts.assigneeType The type of the goal's assignee. If provided, everyone's goals will be returned.
     * @param {Number} opts.expectedOutcomeTarget The numeric value of the outcome. If provided, everyone's goals will be returned.
     * @param {module:model/String} opts.expectedOutcomeTrackingMetric The tracking metric of the expected outcome of the goal. If provided, everyone's goals will be returned.
     * @param {Number} opts.expectedOutcomeCurrencyId The numeric ID of the goal's currency. Only applicable to goals with `expected_outcome.tracking_metric` with value `sum`. If provided, everyone's goals will be returned.
     * @param {Array.<Number>} opts.typeParamsPipelineId An array of pipeline IDs or `null` for all pipelines. If provided, everyone's goals will be returned.
     * @param {Number} opts.typeParamsStageId The ID of the stage. Applicable to only `deals_progressed` type of goals. If provided, everyone's goals will be returned.
     * @param {Array.<Number>} opts.typeParamsActivityTypeId An array of IDs or `null` for all activity types. Only applicable for `activities_completed` and/or `activities_added` types of goals. If provided, everyone's goals will be returned.
     * @param {Date} opts.periodStart The start date of the period for which to find goals. Date in format of YYYY-MM-DD. When `period.start` is provided, `period.end` must be provided too.
     * @param {Date} opts.periodEnd The end date of the period for which to find goals. Date in format of YYYY-MM-DD.
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetGoalsResponse200} and HTTP response
     */
  }, {
    key: "getGoalsWithHttpInfo",
    value: function getGoalsWithHttpInfo(opts) {
      opts = opts || {};
      var postBody = null;
      var pathParams = {};
      var queryParams = {
        'type.name': opts['type.name'] === undefined ? opts['typeName'] : opts['type.name'],
        'title': opts['title'] === undefined ? opts['title'] : opts['title'],
        'is_active': opts['is_active'] === undefined ? opts['isActive'] : opts['is_active'],
        'assignee.id': opts['assignee.id'] === undefined ? opts['assigneeId'] : opts['assignee.id'],
        'assignee.type': opts['assignee.type'] === undefined ? opts['assigneeType'] : opts['assignee.type'],
        'expected_outcome.target': opts['expected_outcome.target'] === undefined ? opts['expectedOutcomeTarget'] : opts['expected_outcome.target'],
        'expected_outcome.tracking_metric': opts['expected_outcome.tracking_metric'] === undefined ? opts['expectedOutcomeTrackingMetric'] : opts['expected_outcome.tracking_metric'],
        'expected_outcome.currency_id': opts['expected_outcome.currency_id'] === undefined ? opts['expectedOutcomeCurrencyId'] : opts['expected_outcome.currency_id'],
        'type.params.pipeline_id': this.apiClient.buildCollectionParam(opts['typeParamsPipelineId'], 'csv'),
        'type.params.stage_id': opts['type.params.stage_id'] === undefined ? opts['typeParamsStageId'] : opts['type.params.stage_id'],
        'type.params.activity_type_id': this.apiClient.buildCollectionParam(opts['typeParamsActivityTypeId'], 'csv'),
        'period.start': opts['period.start'] === undefined ? opts['periodStart'] : opts['period.start'],
        'period.end': opts['period.end'] === undefined ? opts['periodEnd'] : opts['period.end']
      };
      var headerParams = {};
      var formParams = {};
      var formParamArray = [];
      var contentTypes = [];
      var isURLEncoded = contentTypes.includes('application/x-www-form-urlencoded');
      var isJSON = contentTypes.includes('application/json');
      if (isJSON) {
        postBody = _objectSpread(_objectSpread({}, postBody), opts);
      } else if (isURLEncoded) {
        for (var key in opts) {
          if (opts.hasOwnProperty(key) && !formParamArray.includes(key)) {
            formParams[key] = opts[key];
          }
        }
      }
      var authNames = ['api_key', 'oauth2'];
      var accepts = ['application/json'];
      var returnType = _GetGoalsResponse["default"];
      return this.apiClient.callApi('/goals/find', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
    }

    /**
     * Find goals
     * Returns data about goals based on criteria. For searching, append `{searchField}={searchValue}` to the URL, where `searchField` can be any one of the lowest-level fields in dot-notation (e.g. `type.params.pipeline_id`; `title`). `searchValue` should be the value you are looking for on that field. Additionally, `is_active=<true|false>` can be provided to search for only active/inactive goals. When providing `period.start`, `period.end` must also be provided and vice versa.
     * @param {Object} opts Optional parameters
     * @param {module:model/String} opts.typeName The type of the goal. If provided, everyone's goals will be returned.
     * @param {String} opts.title The title of the goal
     * @param {Boolean} opts.isActive Whether the goal is active or not (default to true)
     * @param {Number} opts.assigneeId The ID of the user who's goal to fetch. When omitted, only your goals will be returned.
     * @param {module:model/String} opts.assigneeType The type of the goal's assignee. If provided, everyone's goals will be returned.
     * @param {Number} opts.expectedOutcomeTarget The numeric value of the outcome. If provided, everyone's goals will be returned.
     * @param {module:model/String} opts.expectedOutcomeTrackingMetric The tracking metric of the expected outcome of the goal. If provided, everyone's goals will be returned.
     * @param {Number} opts.expectedOutcomeCurrencyId The numeric ID of the goal's currency. Only applicable to goals with `expected_outcome.tracking_metric` with value `sum`. If provided, everyone's goals will be returned.
     * @param {Array.<Number>} opts.typeParamsPipelineId An array of pipeline IDs or `null` for all pipelines. If provided, everyone's goals will be returned.
     * @param {Number} opts.typeParamsStageId The ID of the stage. Applicable to only `deals_progressed` type of goals. If provided, everyone's goals will be returned.
     * @param {Array.<Number>} opts.typeParamsActivityTypeId An array of IDs or `null` for all activity types. Only applicable for `activities_completed` and/or `activities_added` types of goals. If provided, everyone's goals will be returned.
     * @param {Date} opts.periodStart The start date of the period for which to find goals. Date in format of YYYY-MM-DD. When `period.start` is provided, `period.end` must be provided too.
     * @param {Date} opts.periodEnd The end date of the period for which to find goals. Date in format of YYYY-MM-DD.
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetGoalsResponse200}
     */
  }, {
    key: "getGoals",
    value: function getGoals(opts) {
      return this.getGoalsWithHttpInfo(opts).then(function (response_and_data) {
        return response_and_data;
      });
    }

    /**
     * Update existing goal
     * Updates an existing goal.
     * @param {String} id The ID of the goal
     * @param {Object} opts Optional parameters
     * @param {module:model/BasicGoal} opts.basicGoal 
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AddOrUpdateGoalResponse200} and HTTP response
     */
  }, {
    key: "updateGoalWithHttpInfo",
    value: function updateGoalWithHttpInfo(id, opts) {
      opts = opts || {};
      var postBody = opts['basicGoal'];

      // verify the required parameter 'id' is set
      if (id === undefined || id === null) {
        throw new Error("Missing the required parameter 'id' when calling updateGoal");
      }
      var pathParams = {
        'id': id
      };
      var queryParams = {};
      var headerParams = {};
      var formParams = {};
      var formParamArray = [];
      var contentTypes = ['application/json'];
      var isURLEncoded = contentTypes.includes('application/x-www-form-urlencoded');
      var isJSON = contentTypes.includes('application/json');
      if (isJSON) {
        postBody = _objectSpread(_objectSpread({}, postBody), opts);
      } else if (isURLEncoded) {
        for (var key in opts) {
          if (opts.hasOwnProperty(key) && !formParamArray.includes(key)) {
            formParams[key] = opts[key];
          }
        }
      }
      var authNames = ['api_key', 'oauth2'];
      var accepts = ['application/json'];
      var returnType = _AddOrUpdateGoalResponse["default"];
      return this.apiClient.callApi('/goals/{id}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
    }

    /**
     * Update existing goal
     * Updates an existing goal.
     * @param {String} id The ID of the goal
     * @param {Object} opts Optional parameters
     * @param {module:model/BasicGoal} opts.basicGoal 
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AddOrUpdateGoalResponse200}
     */
  }, {
    key: "updateGoal",
    value: function updateGoal(id, opts) {
      return this.updateGoalWithHttpInfo(id, opts).then(function (response_and_data) {
        return response_and_data;
      });
    }
  }]);
  return GoalsApi;
}();
exports["default"] = GoalsApi;