File: /var/www/quadcode.com/node_modules/pipedrive/dist/api/SubscriptionsApi.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 _PaymentsResponse = _interopRequireDefault(require("../model/PaymentsResponse"));
var _SubscriptionInstallmentCreateRequest = _interopRequireDefault(require("../model/SubscriptionInstallmentCreateRequest"));
var _SubscriptionInstallmentUpdateRequest = _interopRequireDefault(require("../model/SubscriptionInstallmentUpdateRequest"));
var _SubscriptionRecurringCancelRequest = _interopRequireDefault(require("../model/SubscriptionRecurringCancelRequest"));
var _SubscriptionRecurringCreateRequest = _interopRequireDefault(require("../model/SubscriptionRecurringCreateRequest"));
var _SubscriptionRecurringUpdateRequest = _interopRequireDefault(require("../model/SubscriptionRecurringUpdateRequest"));
var _SubscriptionsIdResponse = _interopRequireDefault(require("../model/SubscriptionsIdResponse"));
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.
*
*/
/**
* Subscriptions service.
* @module api/SubscriptionsApi
* @version 1.0.0
*/
var SubscriptionsApi = /*#__PURE__*/function () {
/**
* Constructs a new SubscriptionsApi.
* @alias module:api/SubscriptionsApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
function SubscriptionsApi(apiClient) {
(0, _classCallCheck2["default"])(this, SubscriptionsApi);
this.apiClient = apiClient;
}
/**
* Add a recurring subscription
* Adds a new recurring subscription.
* @param {Object} opts Optional parameters
* @param {module:model/SubscriptionRecurringCreateRequest} opts.subscriptionRecurringCreateRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionsIdResponse} and HTTP response
*/
(0, _createClass2["default"])(SubscriptionsApi, [{
key: "addRecurringSubscriptionWithHttpInfo",
value: function addRecurringSubscriptionWithHttpInfo(opts) {
opts = opts || {};
var postBody = opts['subscriptionRecurringCreateRequest'];
if (opts['deal_id'] === undefined || opts['deal_id'] === null) {
throw new Error("Missing the required parameter 'deal_id' when calling addRecurringSubscription");
}
if (opts['currency'] === undefined || opts['currency'] === null) {
throw new Error("Missing the required parameter 'currency' when calling addRecurringSubscription");
}
if (opts['cadence_type'] === undefined || opts['cadence_type'] === null) {
throw new Error("Missing the required parameter 'cadence_type' when calling addRecurringSubscription");
}
if (opts['cycle_amount'] === undefined || opts['cycle_amount'] === null) {
throw new Error("Missing the required parameter 'cycle_amount' when calling addRecurringSubscription");
}
if (opts['start_date'] === undefined || opts['start_date'] === null) {
throw new Error("Missing the required parameter 'start_date' when calling addRecurringSubscription");
}
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 = _SubscriptionsIdResponse["default"];
return this.apiClient.callApi('/subscriptions/recurring', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Add a recurring subscription
* Adds a new recurring subscription.
* @param {Object} opts Optional parameters
* @param {module:model/SubscriptionRecurringCreateRequest} opts.subscriptionRecurringCreateRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionsIdResponse}
*/
}, {
key: "addRecurringSubscription",
value: function addRecurringSubscription(opts) {
return this.addRecurringSubscriptionWithHttpInfo(opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Add an installment subscription
* Adds a new installment subscription.
* @param {Object} opts Optional parameters
* @param {module:model/SubscriptionInstallmentCreateRequest} opts.subscriptionInstallmentCreateRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionsIdResponse} and HTTP response
*/
}, {
key: "addSubscriptionInstallmentWithHttpInfo",
value: function addSubscriptionInstallmentWithHttpInfo(opts) {
opts = opts || {};
var postBody = opts['subscriptionInstallmentCreateRequest'];
if (opts['deal_id'] === undefined || opts['deal_id'] === null) {
throw new Error("Missing the required parameter 'deal_id' when calling addSubscriptionInstallment");
}
if (opts['currency'] === undefined || opts['currency'] === null) {
throw new Error("Missing the required parameter 'currency' when calling addSubscriptionInstallment");
}
if (opts['payments'] === undefined || opts['payments'] === null) {
throw new Error("Missing the required parameter 'payments' when calling addSubscriptionInstallment");
}
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 = _SubscriptionsIdResponse["default"];
return this.apiClient.callApi('/subscriptions/installment', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Add an installment subscription
* Adds a new installment subscription.
* @param {Object} opts Optional parameters
* @param {module:model/SubscriptionInstallmentCreateRequest} opts.subscriptionInstallmentCreateRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionsIdResponse}
*/
}, {
key: "addSubscriptionInstallment",
value: function addSubscriptionInstallment(opts) {
return this.addSubscriptionInstallmentWithHttpInfo(opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Cancel a recurring subscription
* Cancels a recurring subscription.
* @param {Number} id The ID of the subscription
* @param {Object} opts Optional parameters
* @param {module:model/SubscriptionRecurringCancelRequest} opts.subscriptionRecurringCancelRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionsIdResponse} and HTTP response
*/
}, {
key: "cancelRecurringSubscriptionWithHttpInfo",
value: function cancelRecurringSubscriptionWithHttpInfo(id, opts) {
opts = opts || {};
var postBody = opts['subscriptionRecurringCancelRequest'];
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling cancelRecurringSubscription");
}
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 = _SubscriptionsIdResponse["default"];
return this.apiClient.callApi('/subscriptions/recurring/{id}/cancel', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Cancel a recurring subscription
* Cancels a recurring subscription.
* @param {Number} id The ID of the subscription
* @param {Object} opts Optional parameters
* @param {module:model/SubscriptionRecurringCancelRequest} opts.subscriptionRecurringCancelRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionsIdResponse}
*/
}, {
key: "cancelRecurringSubscription",
value: function cancelRecurringSubscription(id, opts) {
return this.cancelRecurringSubscriptionWithHttpInfo(id, opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Delete a subscription
* Marks an installment or a recurring subscription as deleted.
* @param {Number} id The ID of the subscription
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionsIdResponse} and HTTP response
*/
}, {
key: "deleteSubscriptionWithHttpInfo",
value: function deleteSubscriptionWithHttpInfo(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 deleteSubscription");
}
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 = _SubscriptionsIdResponse["default"];
return this.apiClient.callApi('/subscriptions/{id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Delete a subscription
* Marks an installment or a recurring subscription as deleted.
* @param {Number} id The ID of the subscription
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionsIdResponse}
*/
}, {
key: "deleteSubscription",
value: function deleteSubscription(id) {
return this.deleteSubscriptionWithHttpInfo(id).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Find subscription by deal
* Returns details of an installment or a recurring subscription by the deal ID.
* @param {Number} dealId The ID of the deal
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionsIdResponse} and HTTP response
*/
}, {
key: "findSubscriptionByDealWithHttpInfo",
value: function findSubscriptionByDealWithHttpInfo(dealId) {
var opts = {};
var postBody = null;
// verify the required parameter 'dealId' is set
if (dealId === undefined || dealId === null) {
throw new Error("Missing the required parameter 'dealId' when calling findSubscriptionByDeal");
}
var pathParams = {
'dealId': dealId
};
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 = _SubscriptionsIdResponse["default"];
return this.apiClient.callApi('/subscriptions/find/{dealId}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Find subscription by deal
* Returns details of an installment or a recurring subscription by the deal ID.
* @param {Number} dealId The ID of the deal
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionsIdResponse}
*/
}, {
key: "findSubscriptionByDeal",
value: function findSubscriptionByDeal(dealId) {
return this.findSubscriptionByDealWithHttpInfo(dealId).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Get details of a subscription
* Returns details of an installment or a recurring subscription.
* @param {Number} id The ID of the subscription
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionsIdResponse} and HTTP response
*/
}, {
key: "getSubscriptionWithHttpInfo",
value: function getSubscriptionWithHttpInfo(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 getSubscription");
}
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 = _SubscriptionsIdResponse["default"];
return this.apiClient.callApi('/subscriptions/{id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Get details of a subscription
* Returns details of an installment or a recurring subscription.
* @param {Number} id The ID of the subscription
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionsIdResponse}
*/
}, {
key: "getSubscription",
value: function getSubscription(id) {
return this.getSubscriptionWithHttpInfo(id).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Get all payments of a subscription
* Returns all payments of an installment or recurring subscription.
* @param {Number} id The ID of the subscription
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/PaymentsResponse} and HTTP response
*/
}, {
key: "getSubscriptionPaymentsWithHttpInfo",
value: function getSubscriptionPaymentsWithHttpInfo(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 getSubscriptionPayments");
}
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 = _PaymentsResponse["default"];
return this.apiClient.callApi('/subscriptions/{id}/payments', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Get all payments of a subscription
* Returns all payments of an installment or recurring subscription.
* @param {Number} id The ID of the subscription
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/PaymentsResponse}
*/
}, {
key: "getSubscriptionPayments",
value: function getSubscriptionPayments(id) {
return this.getSubscriptionPaymentsWithHttpInfo(id).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Update a recurring subscription
* Updates a recurring subscription.
* @param {Number} id The ID of the subscription
* @param {Object} opts Optional parameters
* @param {module:model/SubscriptionRecurringUpdateRequest} opts.subscriptionRecurringUpdateRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionsIdResponse} and HTTP response
*/
}, {
key: "updateRecurringSubscriptionWithHttpInfo",
value: function updateRecurringSubscriptionWithHttpInfo(id, opts) {
opts = opts || {};
var postBody = opts['subscriptionRecurringUpdateRequest'];
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling updateRecurringSubscription");
}
if (opts['effective_date'] === undefined || opts['effective_date'] === null) {
throw new Error("Missing the required parameter 'effective_date' when calling updateRecurringSubscription");
}
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 = _SubscriptionsIdResponse["default"];
return this.apiClient.callApi('/subscriptions/recurring/{id}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Update a recurring subscription
* Updates a recurring subscription.
* @param {Number} id The ID of the subscription
* @param {Object} opts Optional parameters
* @param {module:model/SubscriptionRecurringUpdateRequest} opts.subscriptionRecurringUpdateRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionsIdResponse}
*/
}, {
key: "updateRecurringSubscription",
value: function updateRecurringSubscription(id, opts) {
return this.updateRecurringSubscriptionWithHttpInfo(id, opts).then(function (response_and_data) {
return response_and_data;
});
}
/**
* Update an installment subscription
* Updates an installment subscription.
* @param {Number} id The ID of the subscription
* @param {Object} opts Optional parameters
* @param {module:model/SubscriptionInstallmentUpdateRequest} opts.subscriptionInstallmentUpdateRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionsIdResponse} and HTTP response
*/
}, {
key: "updateSubscriptionInstallmentWithHttpInfo",
value: function updateSubscriptionInstallmentWithHttpInfo(id, opts) {
opts = opts || {};
var postBody = opts['subscriptionInstallmentUpdateRequest'];
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling updateSubscriptionInstallment");
}
if (opts['payments'] === undefined || opts['payments'] === null) {
throw new Error("Missing the required parameter 'payments' when calling updateSubscriptionInstallment");
}
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 = _SubscriptionsIdResponse["default"];
return this.apiClient.callApi('/subscriptions/installment/{id}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Update an installment subscription
* Updates an installment subscription.
* @param {Number} id The ID of the subscription
* @param {Object} opts Optional parameters
* @param {module:model/SubscriptionInstallmentUpdateRequest} opts.subscriptionInstallmentUpdateRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionsIdResponse}
*/
}, {
key: "updateSubscriptionInstallment",
value: function updateSubscriptionInstallment(id, opts) {
return this.updateSubscriptionInstallmentWithHttpInfo(id, opts).then(function (response_and_data) {
return response_and_data;
});
}
}]);
return SubscriptionsApi;
}();
exports["default"] = SubscriptionsApi;