File: /var/www/quadcode.com/node_modules/pipedrive/dist/api/ProductsApi.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 _AddProductFollowerRequest = _interopRequireDefault(require("../model/AddProductFollowerRequest"));
var _AddProductRequestBody = _interopRequireDefault(require("../model/AddProductRequestBody"));
var _DeleteProductFollowerResponse = _interopRequireDefault(require("../model/DeleteProductFollowerResponse"));
var _DeleteProductResponse = _interopRequireDefault(require("../model/DeleteProductResponse"));
var _ListDealsResponse = _interopRequireDefault(require("../model/ListDealsResponse"));
var _ListProductFilesResponse = _interopRequireDefault(require("../model/ListProductFilesResponse"));
var _ListProductFollowersResponse = _interopRequireDefault(require("../model/ListProductFollowersResponse"));
var _NewFollowerResponse = _interopRequireDefault(require("../model/NewFollowerResponse"));
var _ProductResponse = _interopRequireDefault(require("../model/ProductResponse"));
var _ProductSearchResponse = _interopRequireDefault(require("../model/ProductSearchResponse"));
var _ProductsResponse = _interopRequireDefault(require("../model/ProductsResponse"));
var _UpdateProductRequestBody = _interopRequireDefault(require("../model/UpdateProductRequestBody"));
var _UpdateProductResponse = _interopRequireDefault(require("../model/UpdateProductResponse"));
var _UserIDs = _interopRequireDefault(require("../model/UserIDs"));
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; } /**
* Pipedrive API v1
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*
*/
/**
* Products service.
* @module api/ProductsApi
* @version 1.0.0
*/
var ProductsApi = /*#__PURE__*/function () {
/**
* Constructs a new ProductsApi.
* @alias module:api/ProductsApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
function ProductsApi(apiClient) {
(0, _classCallCheck2["default"])(this, ProductsApi);
this.apiClient = apiClient;
}
/**
* Add a product
* Adds a new product to the Products inventory. For more information, see the tutorial for <a href=\"https://pipedrive.readme.io/docs/adding-a-product\" target=\"_blank\" rel=\"noopener noreferrer\">adding a product</a>.
* @param {Object} opts Optional parameters
* @param {module:model/AddProductRequestBody} opts.addProductRequestBody
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ProductResponse} and HTTP response
*/
(0, _createClass2["default"])(ProductsApi, [{
key: "addProductWithHttpInfo",
value: function addProductWithHttpInfo(opts) {
opts = opts || {};
var postBody = opts['addProductRequestBody'];
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 = _ProductResponse["default"];
return this.apiClient.callApi('/products', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Add a product
* Adds a new product to the Products inventory. For more information, see the tutorial for <a href=\"https://pipedrive.readme.io/docs/adding-a-product\" target=\"_blank\" rel=\"noopener noreferrer\">adding a product</a>.
* @param {Object} opts Optional parameters
* @param {module:model/AddProductRequestBody} opts.addProductRequestBody
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ProductResponse}
*/
}, {
key: "addProduct",
value: function addProduct(opts) {
return this.addProductWithHttpInfo(opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Add a follower to a product
* Adds a follower to a product.
* @param {Number} id The ID of the product
* @param {Object} opts Optional parameters
* @param {module:model/AddProductFollowerRequest} opts.addProductFollowerRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/NewFollowerResponse} and HTTP response
*/
}, {
key: "addProductFollowerWithHttpInfo",
value: function addProductFollowerWithHttpInfo(id, opts) {
opts = opts || {};
var postBody = opts['addProductFollowerRequest'];
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling addProductFollower");
}
if (opts['user_id'] === undefined || opts['user_id'] === null) {
throw new Error("Missing the required parameter 'user_id' when calling addProductFollower");
}
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 = _NewFollowerResponse["default"];
return this.apiClient.callApi('/products/{id}/followers', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Add a follower to a product
* Adds a follower to a product.
* @param {Number} id The ID of the product
* @param {Object} opts Optional parameters
* @param {module:model/AddProductFollowerRequest} opts.addProductFollowerRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/NewFollowerResponse}
*/
}, {
key: "addProductFollower",
value: function addProductFollower(id, opts) {
return this.addProductFollowerWithHttpInfo(id, opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Delete a product
* Marks a product as deleted. After 30 days, the product will be permanently deleted.
* @param {Number} id The ID of the product
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/DeleteProductResponse} and HTTP response
*/
}, {
key: "deleteProductWithHttpInfo",
value: function deleteProductWithHttpInfo(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 deleteProduct");
}
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 = _DeleteProductResponse["default"];
return this.apiClient.callApi('/products/{id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Delete a product
* Marks a product as deleted. After 30 days, the product will be permanently deleted.
* @param {Number} id The ID of the product
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/DeleteProductResponse}
*/
}, {
key: "deleteProduct",
value: function deleteProduct(id) {
return this.deleteProductWithHttpInfo(id).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Delete a follower from a product
* Deletes a follower from a product.
* @param {Number} id The ID of the product
* @param {Number} followerId The ID of the relationship between the follower and the product
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/DeleteProductFollowerResponse} and HTTP response
*/
}, {
key: "deleteProductFollowerWithHttpInfo",
value: function deleteProductFollowerWithHttpInfo(id, followerId) {
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 deleteProductFollower");
}
// verify the required parameter 'followerId' is set
if (followerId === undefined || followerId === null) {
throw new Error("Missing the required parameter 'followerId' when calling deleteProductFollower");
}
var pathParams = {
'id': id,
'follower_id': followerId
};
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 = _DeleteProductFollowerResponse["default"];
return this.apiClient.callApi('/products/{id}/followers/{follower_id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Delete a follower from a product
* Deletes a follower from a product.
* @param {Number} id The ID of the product
* @param {Number} followerId The ID of the relationship between the follower and the product
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/DeleteProductFollowerResponse}
*/
}, {
key: "deleteProductFollower",
value: function deleteProductFollower(id, followerId) {
return this.deleteProductFollowerWithHttpInfo(id, followerId).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Get one product
* Returns data about a specific product.
* @param {Number} id The ID of the product
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ProductResponse} and HTTP response
*/
}, {
key: "getProductWithHttpInfo",
value: function getProductWithHttpInfo(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 getProduct");
}
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 = _ProductResponse["default"];
return this.apiClient.callApi('/products/{id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Get one product
* Returns data about a specific product.
* @param {Number} id The ID of the product
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ProductResponse}
*/
}, {
key: "getProduct",
value: function getProduct(id) {
return this.getProductWithHttpInfo(id).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Get deals where a product is attached to
* Returns data about deals that have a product attached to it.
* @param {Number} id The ID of the product
* @param {Object} opts Optional parameters
* @param {Number} opts.start Pagination start (default to 0)
* @param {Number} opts.limit Items shown per page
* @param {module:model/String} opts.status Only fetch deals with a specific status. If omitted, all not deleted deals are returned. If set to deleted, deals that have been deleted up to 30 days ago will be included. (default to 'all_not_deleted')
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ListDealsResponse} and HTTP response
*/
}, {
key: "getProductDealsWithHttpInfo",
value: function getProductDealsWithHttpInfo(id, opts) {
opts = 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 getProductDeals");
}
var pathParams = {
'id': id
};
var queryParams = {
'start': opts['start'] === undefined ? opts['start'] : opts['start'],
'limit': opts['limit'] === undefined ? opts['limit'] : opts['limit'],
'status': opts['status'] === undefined ? opts['status'] : opts['status']
};
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 = _ListDealsResponse["default"];
return this.apiClient.callApi('/products/{id}/deals', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Get deals where a product is attached to
* Returns data about deals that have a product attached to it.
* @param {Number} id The ID of the product
* @param {Object} opts Optional parameters
* @param {Number} opts.start Pagination start (default to 0)
* @param {Number} opts.limit Items shown per page
* @param {module:model/String} opts.status Only fetch deals with a specific status. If omitted, all not deleted deals are returned. If set to deleted, deals that have been deleted up to 30 days ago will be included. (default to 'all_not_deleted')
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ListDealsResponse}
*/
}, {
key: "getProductDeals",
value: function getProductDeals(id, opts) {
return this.getProductDealsWithHttpInfo(id, opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* List files attached to a product
* Lists files associated with a product.
* @param {Number} id The ID of the product
* @param {Object} opts Optional parameters
* @param {Number} opts.start Pagination start (default to 0)
* @param {Number} opts.limit Items shown per page
* @param {String} opts.sort The field name and sorting mode (`field_name_1 ASC` or `field_name_1 DESC`). Supported fields: `update_time`, `id`.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ListProductFilesResponse} and HTTP response
*/
}, {
key: "getProductFilesWithHttpInfo",
value: function getProductFilesWithHttpInfo(id, opts) {
opts = 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 getProductFiles");
}
var pathParams = {
'id': id
};
var queryParams = {
'start': opts['start'] === undefined ? opts['start'] : opts['start'],
'limit': opts['limit'] === undefined ? opts['limit'] : opts['limit'],
'sort': opts['sort'] === undefined ? opts['sort'] : opts['sort']
};
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 = _ListProductFilesResponse["default"];
return this.apiClient.callApi('/products/{id}/files', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* List files attached to a product
* Lists files associated with a product.
* @param {Number} id The ID of the product
* @param {Object} opts Optional parameters
* @param {Number} opts.start Pagination start (default to 0)
* @param {Number} opts.limit Items shown per page
* @param {String} opts.sort The field name and sorting mode (`field_name_1 ASC` or `field_name_1 DESC`). Supported fields: `update_time`, `id`.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ListProductFilesResponse}
*/
}, {
key: "getProductFiles",
value: function getProductFiles(id, opts) {
return this.getProductFilesWithHttpInfo(id, opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* List followers of a product
* Lists the followers of a product.
* @param {Number} id The ID of the product
* @param {Object} opts Optional parameters
* @param {Number} opts.start Pagination start (default to 0)
* @param {Number} opts.limit Items shown per page
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ListProductFollowersResponse} and HTTP response
*/
}, {
key: "getProductFollowersWithHttpInfo",
value: function getProductFollowersWithHttpInfo(id, opts) {
opts = 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 getProductFollowers");
}
var pathParams = {
'id': id
};
var queryParams = {
'start': opts['start'] === undefined ? opts['start'] : opts['start'],
'limit': opts['limit'] === undefined ? opts['limit'] : opts['limit']
};
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 = _ListProductFollowersResponse["default"];
return this.apiClient.callApi('/products/{id}/followers', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* List followers of a product
* Lists the followers of a product.
* @param {Number} id The ID of the product
* @param {Object} opts Optional parameters
* @param {Number} opts.start Pagination start (default to 0)
* @param {Number} opts.limit Items shown per page
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ListProductFollowersResponse}
*/
}, {
key: "getProductFollowers",
value: function getProductFollowers(id, opts) {
return this.getProductFollowersWithHttpInfo(id, opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* List permitted users
* Lists users permitted to access a product.
* @param {Number} id The ID of the product
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/UserIDs} and HTTP response
*/
}, {
key: "getProductUsersWithHttpInfo",
value: function getProductUsersWithHttpInfo(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 getProductUsers");
}
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 = _UserIDs["default"];
return this.apiClient.callApi('/products/{id}/permittedUsers', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* List permitted users
* Lists users permitted to access a product.
* @param {Number} id The ID of the product
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/UserIDs}
*/
}, {
key: "getProductUsers",
value: function getProductUsers(id) {
return this.getProductUsersWithHttpInfo(id).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Get all products
* Returns data about all products.
* @param {Object} opts Optional parameters
* @param {Number} opts.userId If supplied, only products owned by the given user will be returned
* @param {Number} opts.filterId The ID of the filter to use
* @param {Array.<Number>} opts.ids An array of integers with the IDs of the products that should be returned in the response
* @param {String} opts.firstChar If supplied, only products whose name starts with the specified letter will be returned (case-insensitive)
* @param {Boolean} opts.getSummary If supplied, the response will return the total numbers of products in the `additional_data.summary.total_count` property
* @param {Number} opts.start Pagination start (default to 0)
* @param {Number} opts.limit Items shown per page
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ProductsResponse} and HTTP response
*/
}, {
key: "getProductsWithHttpInfo",
value: function getProductsWithHttpInfo(opts) {
opts = opts || {};
var postBody = null;
var pathParams = {};
var queryParams = {
'user_id': opts['user_id'] === undefined ? opts['userId'] : opts['user_id'],
'filter_id': opts['filter_id'] === undefined ? opts['filterId'] : opts['filter_id'],
'ids': this.apiClient.buildCollectionParam(opts['ids'], 'csv'),
'first_char': opts['first_char'] === undefined ? opts['firstChar'] : opts['first_char'],
'get_summary': opts['get_summary'] === undefined ? opts['getSummary'] : opts['get_summary'],
'start': opts['start'] === undefined ? opts['start'] : opts['start'],
'limit': opts['limit'] === undefined ? opts['limit'] : opts['limit']
};
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 = _ProductsResponse["default"];
return this.apiClient.callApi('/products', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Get all products
* Returns data about all products.
* @param {Object} opts Optional parameters
* @param {Number} opts.userId If supplied, only products owned by the given user will be returned
* @param {Number} opts.filterId The ID of the filter to use
* @param {Array.<Number>} opts.ids An array of integers with the IDs of the products that should be returned in the response
* @param {String} opts.firstChar If supplied, only products whose name starts with the specified letter will be returned (case-insensitive)
* @param {Boolean} opts.getSummary If supplied, the response will return the total numbers of products in the `additional_data.summary.total_count` property
* @param {Number} opts.start Pagination start (default to 0)
* @param {Number} opts.limit Items shown per page
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ProductsResponse}
*/
}, {
key: "getProducts",
value: function getProducts(opts) {
return this.getProductsWithHttpInfo(opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Search products
* Searches all products by name, code and/or custom fields. This endpoint is a wrapper of <a href=\"https://developers.pipedrive.com/docs/api/v1/ItemSearch#searchItem\">/v1/itemSearch</a> with a narrower OAuth scope.
* @param {String} term The search term to look for. Minimum 2 characters (or 1 if using `exact_match`). Please note that the search term has to be URL encoded.
* @param {Object} opts Optional parameters
* @param {module:model/String} opts.fields A comma-separated string array. The fields to perform the search from. Defaults to all of them. Only the following custom field types are searchable: `address`, `varchar`, `text`, `varchar_auto`, `double`, `monetary` and `phone`. Read more about searching by custom fields <a href=\"https://support.pipedrive.com/en/article/search-finding-what-you-need#searching-by-custom-fields\" target=\"_blank\" rel=\"noopener noreferrer\">here</a>.
* @param {Boolean} opts.exactMatch When enabled, only full exact matches against the given term are returned. It is <b>not</b> case sensitive.
* @param {module:model/String} opts.includeFields Supports including optional fields in the results which are not provided by default
* @param {Number} opts.start Pagination start. Note that the pagination is based on main results and does not include related items when using `search_for_related_items` parameter. (default to 0)
* @param {Number} opts.limit Items shown per page
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ProductSearchResponse} and HTTP response
*/
}, {
key: "searchProductsWithHttpInfo",
value: function searchProductsWithHttpInfo(term, opts) {
opts = opts || {};
var postBody = null;
// verify the required parameter 'term' is set
if (term === undefined || term === null) {
throw new Error("Missing the required parameter 'term' when calling searchProducts");
}
var pathParams = {};
var queryParams = {
'term': term,
'fields': opts['fields'] === undefined ? opts['fields'] : opts['fields'],
'exact_match': opts['exact_match'] === undefined ? opts['exactMatch'] : opts['exact_match'],
'include_fields': opts['include_fields'] === undefined ? opts['includeFields'] : opts['include_fields'],
'start': opts['start'] === undefined ? opts['start'] : opts['start'],
'limit': opts['limit'] === undefined ? opts['limit'] : opts['limit']
};
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 = _ProductSearchResponse["default"];
return this.apiClient.callApi('/products/search', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Search products
* Searches all products by name, code and/or custom fields. This endpoint is a wrapper of <a href=\"https://developers.pipedrive.com/docs/api/v1/ItemSearch#searchItem\">/v1/itemSearch</a> with a narrower OAuth scope.
* @param {String} term The search term to look for. Minimum 2 characters (or 1 if using `exact_match`). Please note that the search term has to be URL encoded.
* @param {Object} opts Optional parameters
* @param {module:model/String} opts.fields A comma-separated string array. The fields to perform the search from. Defaults to all of them. Only the following custom field types are searchable: `address`, `varchar`, `text`, `varchar_auto`, `double`, `monetary` and `phone`. Read more about searching by custom fields <a href=\"https://support.pipedrive.com/en/article/search-finding-what-you-need#searching-by-custom-fields\" target=\"_blank\" rel=\"noopener noreferrer\">here</a>.
* @param {Boolean} opts.exactMatch When enabled, only full exact matches against the given term are returned. It is <b>not</b> case sensitive.
* @param {module:model/String} opts.includeFields Supports including optional fields in the results which are not provided by default
* @param {Number} opts.start Pagination start. Note that the pagination is based on main results and does not include related items when using `search_for_related_items` parameter. (default to 0)
* @param {Number} opts.limit Items shown per page
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ProductSearchResponse}
*/
}, {
key: "searchProducts",
value: function searchProducts(term, opts) {
return this.searchProductsWithHttpInfo(term, opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Update a product
* Updates product data.
* @param {Number} id The ID of the product
* @param {Object} opts Optional parameters
* @param {module:model/UpdateProductRequestBody} opts.updateProductRequestBody
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/UpdateProductResponse} and HTTP response
*/
}, {
key: "updateProductWithHttpInfo",
value: function updateProductWithHttpInfo(id, opts) {
opts = opts || {};
var postBody = opts['updateProductRequestBody'];
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling updateProduct");
}
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 = _UpdateProductResponse["default"];
return this.apiClient.callApi('/products/{id}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Update a product
* Updates product data.
* @param {Number} id The ID of the product
* @param {Object} opts Optional parameters
* @param {module:model/UpdateProductRequestBody} opts.updateProductRequestBody
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/UpdateProductResponse}
*/
}, {
key: "updateProduct",
value: function updateProduct(id, opts) {
return this.updateProductWithHttpInfo(id, opts).then(function (response_and_data) {
return response_and_data;
});
}
}]);
return ProductsApi;
}();
exports["default"] = ProductsApi;