File: /var/www/fintechfuel/node_modules/pipedrive/dist/api/FilesApi.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 _AddFile = _interopRequireDefault(require("../model/AddFile"));
var _CreateRemoteFileAndLinkItToItem = _interopRequireDefault(require("../model/CreateRemoteFileAndLinkItToItem"));
var _DeleteFile = _interopRequireDefault(require("../model/DeleteFile"));
var _GetAllFiles = _interopRequireDefault(require("../model/GetAllFiles"));
var _GetOneFile = _interopRequireDefault(require("../model/GetOneFile"));
var _LinkRemoteFileToItem = _interopRequireDefault(require("../model/LinkRemoteFileToItem"));
var _UpdateFile = _interopRequireDefault(require("../model/UpdateFile"));
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; }
/**
* Files service.
* @module api/FilesApi
* @version 1.0.0
*/
var FilesApi = /*#__PURE__*/function () {
/**
* Constructs a new FilesApi.
* @alias module:api/FilesApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
function FilesApi(apiClient) {
(0, _classCallCheck2["default"])(this, FilesApi);
this.apiClient = apiClient;
}
/**
* Add file
* Lets you upload a file and associate it with a deal, person, organization, activity, product or lead. For more information, see the tutorial for <a href=\"https://pipedrive.readme.io/docs/adding-a-file\" target=\"_blank\" rel=\"noopener noreferrer\">adding a file</a>.
* @param {File} file A single file, supplied in the multipart/form-data encoding and contained within the given boundaries
* @param {Object} opts Optional parameters
* @param {Number} opts.dealId The ID of the deal to associate file(s) with
* @param {Number} opts.personId The ID of the person to associate file(s) with
* @param {Number} opts.orgId The ID of the organization to associate file(s) with
* @param {Number} opts.productId The ID of the product to associate file(s) with
* @param {Number} opts.activityId The ID of the activity to associate file(s) with
* @param {String} opts.leadId The ID of the lead to associate file(s) with
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AddFile} and HTTP response
*/
(0, _createClass2["default"])(FilesApi, [{
key: "addFileWithHttpInfo",
value: function addFileWithHttpInfo(file, opts) {
opts = opts || {};
var postBody = null;
// verify the required parameter 'file' is set
if (file === undefined || file === null) {
throw new Error("Missing the required parameter 'file' when calling addFile");
}
var pathParams = {};
var queryParams = {};
var headerParams = {};
var formParams = {
'file': file,
'deal_id': opts['dealId'],
'person_id': opts['personId'],
'org_id': opts['orgId'],
'product_id': opts['productId'],
'activity_id': opts['activityId'],
'lead_id': opts['leadId']
};
var formParamArray = ['file', 'dealId', 'personId', 'orgId', 'productId', 'activityId', 'leadId'];
var contentTypes = ['multipart/form-data'];
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 = _AddFile["default"];
return this.apiClient.callApi('/files', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Add file
* Lets you upload a file and associate it with a deal, person, organization, activity, product or lead. For more information, see the tutorial for <a href=\"https://pipedrive.readme.io/docs/adding-a-file\" target=\"_blank\" rel=\"noopener noreferrer\">adding a file</a>.
* @param {File} file A single file, supplied in the multipart/form-data encoding and contained within the given boundaries
* @param {Object} opts Optional parameters
* @param {Number} opts.dealId The ID of the deal to associate file(s) with
* @param {Number} opts.personId The ID of the person to associate file(s) with
* @param {Number} opts.orgId The ID of the organization to associate file(s) with
* @param {Number} opts.productId The ID of the product to associate file(s) with
* @param {Number} opts.activityId The ID of the activity to associate file(s) with
* @param {String} opts.leadId The ID of the lead to associate file(s) with
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AddFile}
*/
}, {
key: "addFile",
value: function addFile(file, opts) {
return this.addFileWithHttpInfo(file, opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Create a remote file and link it to an item
* Creates a new empty file in the remote location (`googledrive`) that will be linked to the item you supply. For more information, see the tutorial for <a href=\"https://pipedrive.readme.io/docs/adding-a-remote-file\" target=\"_blank\" rel=\"noopener noreferrer\">adding a remote file</a>.
* @param {module:model/String} fileType The file type
* @param {String} title The title of the file
* @param {module:model/String} itemType The item type
* @param {Number} itemId The ID of the item to associate the file with
* @param {module:model/String} remoteLocation The location type to send the file to. Only `googledrive` is supported at the moment.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/CreateRemoteFileAndLinkItToItem} and HTTP response
*/
}, {
key: "addFileAndLinkItWithHttpInfo",
value: function addFileAndLinkItWithHttpInfo(fileType, title, itemType, itemId, remoteLocation) {
var opts = {};
var postBody = null;
// verify the required parameter 'fileType' is set
if (fileType === undefined || fileType === null) {
throw new Error("Missing the required parameter 'fileType' when calling addFileAndLinkIt");
}
// verify the required parameter 'title' is set
if (title === undefined || title === null) {
throw new Error("Missing the required parameter 'title' when calling addFileAndLinkIt");
}
// verify the required parameter 'itemType' is set
if (itemType === undefined || itemType === null) {
throw new Error("Missing the required parameter 'itemType' when calling addFileAndLinkIt");
}
// verify the required parameter 'itemId' is set
if (itemId === undefined || itemId === null) {
throw new Error("Missing the required parameter 'itemId' when calling addFileAndLinkIt");
}
// verify the required parameter 'remoteLocation' is set
if (remoteLocation === undefined || remoteLocation === null) {
throw new Error("Missing the required parameter 'remoteLocation' when calling addFileAndLinkIt");
}
var pathParams = {};
var queryParams = {};
var headerParams = {};
var formParams = {
'file_type': fileType,
'title': title,
'item_type': itemType,
'item_id': itemId,
'remote_location': remoteLocation
};
var formParamArray = ['fileType', 'title', 'itemType', 'itemId', 'remoteLocation'];
var contentTypes = ['application/x-www-form-urlencoded'];
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 = _CreateRemoteFileAndLinkItToItem["default"];
return this.apiClient.callApi('/files/remote', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Create a remote file and link it to an item
* Creates a new empty file in the remote location (`googledrive`) that will be linked to the item you supply. For more information, see the tutorial for <a href=\"https://pipedrive.readme.io/docs/adding-a-remote-file\" target=\"_blank\" rel=\"noopener noreferrer\">adding a remote file</a>.
* @param {module:model/String} fileType The file type
* @param {String} title The title of the file
* @param {module:model/String} itemType The item type
* @param {Number} itemId The ID of the item to associate the file with
* @param {module:model/String} remoteLocation The location type to send the file to. Only `googledrive` is supported at the moment.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/CreateRemoteFileAndLinkItToItem}
*/
}, {
key: "addFileAndLinkIt",
value: function addFileAndLinkIt(fileType, title, itemType, itemId, remoteLocation) {
return this.addFileAndLinkItWithHttpInfo(fileType, title, itemType, itemId, remoteLocation).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Delete a file
* Marks a file as deleted. After 30 days, the file will be permanently deleted.
* @param {Number} id The ID of the file
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/DeleteFile} and HTTP response
*/
}, {
key: "deleteFileWithHttpInfo",
value: function deleteFileWithHttpInfo(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 deleteFile");
}
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 = _DeleteFile["default"];
return this.apiClient.callApi('/files/{id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Delete a file
* Marks a file as deleted. After 30 days, the file will be permanently deleted.
* @param {Number} id The ID of the file
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/DeleteFile}
*/
}, {
key: "deleteFile",
value: function deleteFile(id) {
return this.deleteFileWithHttpInfo(id).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Download one file
* Initializes a file download.
* @param {Number} id The ID of the file
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Blob} and HTTP response
*/
}, {
key: "downloadFileWithHttpInfo",
value: function downloadFileWithHttpInfo(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 downloadFile");
}
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/octet-stream'];
var returnType = 'Blob';
return this.apiClient.callApi('/files/{id}/download', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Download one file
* Initializes a file download.
* @param {Number} id The ID of the file
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Blob}
*/
}, {
key: "downloadFile",
value: function downloadFile(id) {
return this.downloadFileWithHttpInfo(id).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Get one file
* Returns data about a specific file.
* @param {Number} id The ID of the file
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetOneFile} and HTTP response
*/
}, {
key: "getFileWithHttpInfo",
value: function getFileWithHttpInfo(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 getFile");
}
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 = _GetOneFile["default"];
return this.apiClient.callApi('/files/{id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Get one file
* Returns data about a specific file.
* @param {Number} id The ID of the file
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetOneFile}
*/
}, {
key: "getFile",
value: function getFile(id) {
return this.getFileWithHttpInfo(id).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Get all files
* Returns data about all files.
* @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 names and sorting mode separated by a comma (`field_name_1 ASC`, `field_name_2 DESC`). Only first-level field keys are supported (no nested keys). Supported fields: `id`, `user_id`, `deal_id`, `person_id`, `org_id`, `product_id`, `add_time`, `update_time`, `file_name`, `file_type`, `file_size`, `comment`.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetAllFiles} and HTTP response
*/
}, {
key: "getFilesWithHttpInfo",
value: function getFilesWithHttpInfo(opts) {
opts = opts || {};
var postBody = null;
var pathParams = {};
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 = _GetAllFiles["default"];
return this.apiClient.callApi('/files', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Get all files
* Returns data about all files.
* @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 names and sorting mode separated by a comma (`field_name_1 ASC`, `field_name_2 DESC`). Only first-level field keys are supported (no nested keys). Supported fields: `id`, `user_id`, `deal_id`, `person_id`, `org_id`, `product_id`, `add_time`, `update_time`, `file_name`, `file_type`, `file_size`, `comment`.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetAllFiles}
*/
}, {
key: "getFiles",
value: function getFiles(opts) {
return this.getFilesWithHttpInfo(opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Link a remote file to an item
* Links an existing remote file (`googledrive`) to the item you supply. For more information, see the tutorial for <a href=\"https://pipedrive.readme.io/docs/adding-a-remote-file\" target=\"_blank\" rel=\"noopener noreferrer\">adding a remote file</a>.
* @param {module:model/String} itemType The item type
* @param {Number} itemId The ID of the item to associate the file with
* @param {String} remoteId The remote item ID
* @param {module:model/String} remoteLocation The location type to send the file to. Only `googledrive` is supported at the moment.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/LinkRemoteFileToItem} and HTTP response
*/
}, {
key: "linkFileToItemWithHttpInfo",
value: function linkFileToItemWithHttpInfo(itemType, itemId, remoteId, remoteLocation) {
var opts = {};
var postBody = null;
// verify the required parameter 'itemType' is set
if (itemType === undefined || itemType === null) {
throw new Error("Missing the required parameter 'itemType' when calling linkFileToItem");
}
// verify the required parameter 'itemId' is set
if (itemId === undefined || itemId === null) {
throw new Error("Missing the required parameter 'itemId' when calling linkFileToItem");
}
// verify the required parameter 'remoteId' is set
if (remoteId === undefined || remoteId === null) {
throw new Error("Missing the required parameter 'remoteId' when calling linkFileToItem");
}
// verify the required parameter 'remoteLocation' is set
if (remoteLocation === undefined || remoteLocation === null) {
throw new Error("Missing the required parameter 'remoteLocation' when calling linkFileToItem");
}
var pathParams = {};
var queryParams = {};
var headerParams = {};
var formParams = {
'item_type': itemType,
'item_id': itemId,
'remote_id': remoteId,
'remote_location': remoteLocation
};
var formParamArray = ['itemType', 'itemId', 'remoteId', 'remoteLocation'];
var contentTypes = ['application/x-www-form-urlencoded'];
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 = _LinkRemoteFileToItem["default"];
return this.apiClient.callApi('/files/remoteLink', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Link a remote file to an item
* Links an existing remote file (`googledrive`) to the item you supply. For more information, see the tutorial for <a href=\"https://pipedrive.readme.io/docs/adding-a-remote-file\" target=\"_blank\" rel=\"noopener noreferrer\">adding a remote file</a>.
* @param {module:model/String} itemType The item type
* @param {Number} itemId The ID of the item to associate the file with
* @param {String} remoteId The remote item ID
* @param {module:model/String} remoteLocation The location type to send the file to. Only `googledrive` is supported at the moment.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/LinkRemoteFileToItem}
*/
}, {
key: "linkFileToItem",
value: function linkFileToItem(itemType, itemId, remoteId, remoteLocation) {
return this.linkFileToItemWithHttpInfo(itemType, itemId, remoteId, remoteLocation).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Update file details
* Updates the properties of a file.
* @param {Number} id The ID of the file
* @param {Object} opts Optional parameters
* @param {String} opts.name The visible name of the file
* @param {String} opts.description The description of the file
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/UpdateFile} and HTTP response
*/
}, {
key: "updateFileWithHttpInfo",
value: function updateFileWithHttpInfo(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 updateFile");
}
var pathParams = {
'id': id
};
var queryParams = {};
var headerParams = {};
var formParams = {
'name': opts['name'],
'description': opts['description']
};
var formParamArray = ['name', 'description'];
var contentTypes = ['application/x-www-form-urlencoded'];
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 = _UpdateFile["default"];
return this.apiClient.callApi('/files/{id}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Update file details
* Updates the properties of a file.
* @param {Number} id The ID of the file
* @param {Object} opts Optional parameters
* @param {String} opts.name The visible name of the file
* @param {String} opts.description The description of the file
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/UpdateFile}
*/
}, {
key: "updateFile",
value: function updateFile(id, opts) {
return this.updateFileWithHttpInfo(id, opts).then(function (response_and_data) {
return response_and_data;
});
}
}]);
return FilesApi;
}();
exports["default"] = FilesApi;