UNPKG

wallee

Version:
792 lines (791 loc) 39.3 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.PaymentWebAppService = void 0; const Promise = require("bluebird"); const axios = require("axios"); const HMACAuthentication_1 = require("../auth/HMACAuthentication"); const ObjectSerializer_1 = require("../serializers/ObjectSerializer"); const ClientError_1 = require("../models/ClientError"); const ServerError_1 = require("../models/ServerError"); class PaymentWebAppService { constructor(configuration) { this._basePath = 'https://app-wallee.com:443/api'; this._defaultHeaders = {}; this._useQuerystring = false; this._timeout = 25; this._defaultAuthentication = new HMACAuthentication_1.HMACAuthentication(configuration).apply; this._defaultHeaders = configuration.default_headers; this.setTimeout(configuration.timeout); } /** * Set timeout in seconds. Default timeout: 25 seconds * @param {number} timeout */ set timeout(timeout) { this.setTimeout(timeout); } setTimeout(timeout) { if (timeout !== undefined) { if (!Number.isInteger(timeout)) { throw new Error('Timeout value has to be integer'); } if (timeout) { this._timeout = timeout; } else { throw new Error('Timeout value has to be greater than 0'); } } } set basePath(basePath) { this._basePath = basePath; } get basePath() { return this._basePath; } setDefaultAuthentication(auth) { this._defaultAuthentication = auth; } getVersion() { if (typeof (process) !== 'undefined' && process && process.version) { return 'node ' + process.version; } else { return 'unknown'; } } /** * This operation marks the processor to be usable within the production environment. * @summary Activate Processor for Production * @param spaceId The space ID identifies the space in which the processor is installed in. * @param externalId The external ID identifies the processor. The external ID corresponds to the ID provided during inserting of the processor. * @param {*} [options] Override http request options. */ activateProcessorForProduction(spaceId, externalId, options = {}) { const url = '/payment-web-app/activate-processor-for-production'; let queryParams = {}; let headers = Object.assign({}, this._defaultHeaders); // verify required parameter 'spaceId' is not null or undefined if (spaceId === null || spaceId === undefined) { throw new Error('Required parameter spaceId was null or undefined when calling activateProcessorForProduction.'); } // verify required parameter 'externalId' is not null or undefined if (externalId === null || externalId === undefined) { throw new Error('Required parameter externalId was null or undefined when calling activateProcessorForProduction.'); } if (spaceId !== undefined) { queryParams['spaceId'] = ObjectSerializer_1.ObjectSerializer.serialize(spaceId, "number"); } if (externalId !== undefined) { queryParams['externalId'] = ObjectSerializer_1.ObjectSerializer.serialize(externalId, "string"); } headers['Content-Type'] = '*/*'; Object.assign(headers, options.headers); let defaultHeaders = { "x-meta-sdk-version": "4.7.0", "x-meta-sdk-language": "typescript", "x-meta-sdk-provider": "wallee", "x-meta-sdk-language-version": this.getVersion(), }; Object.assign(headers, defaultHeaders); let requestConfig = { url, method: 'POST', baseURL: this._basePath, headers, params: queryParams, timeout: this._timeout * 1000, responseType: 'json', }; const axiosInstance = axios.default.create(); axiosInstance.interceptors.request.use(this._defaultAuthentication); return new Promise((resolve, reject) => { axiosInstance.request(requestConfig) .then(success => { let body; body = ObjectSerializer_1.ObjectSerializer.deserialize(success.data, "PaymentAppProcessor"); return resolve({ response: success.request.res, body: body }); }, failure => { var _a, _b, _c, _d, _e; let errorObject; if ((_a = failure.response) === null || _a === void 0 ? void 0 : _a.status) { if (failure.response.status >= 400 && failure.response.status <= 499) { errorObject = new ClientError_1.ClientError(); } else if (failure.response.status >= 500 && failure.response.status <= 599) { errorObject = new ServerError_1.ServerError(); } else { errorObject = new Object(); } } else { errorObject = new Object(); } return reject({ errorType: errorObject.constructor.name, date: (new Date()).toDateString(), statusCode: ((_b = failure.response) === null || _b === void 0 ? void 0 : _b.status) && isNaN(failure.response.status) ? String(failure.response.status) : "Unknown", statusMessage: ((_c = failure.response) === null || _c === void 0 ? void 0 : _c.statusText) != null ? failure.response.statusText : "Unknown", body: (_d = failure.response) === null || _d === void 0 ? void 0 : _d.data, response: (_e = failure.response) === null || _e === void 0 ? void 0 : _e.request.res }); }) .catch(error => { return reject(error); }); }); } ; /** * This operation removes the web app payment connector from the given space. * @summary Delete Connector * @param spaceId The space ID identifies the space in which the connector is installed in. * @param externalId The external ID identifies the connector. The external ID corresponds to the ID provided during inserting of the connector. * @param {*} [options] Override http request options. */ deleteConnector(spaceId, externalId, options = {}) { const url = '/payment-web-app/delete-connector'; let queryParams = {}; let headers = Object.assign({}, this._defaultHeaders); // verify required parameter 'spaceId' is not null or undefined if (spaceId === null || spaceId === undefined) { throw new Error('Required parameter spaceId was null or undefined when calling deleteConnector.'); } // verify required parameter 'externalId' is not null or undefined if (externalId === null || externalId === undefined) { throw new Error('Required parameter externalId was null or undefined when calling deleteConnector.'); } if (spaceId !== undefined) { queryParams['spaceId'] = ObjectSerializer_1.ObjectSerializer.serialize(spaceId, "number"); } if (externalId !== undefined) { queryParams['externalId'] = ObjectSerializer_1.ObjectSerializer.serialize(externalId, "string"); } headers['Content-Type'] = 'application/json'; Object.assign(headers, options.headers); let defaultHeaders = { "x-meta-sdk-version": "4.7.0", "x-meta-sdk-language": "typescript", "x-meta-sdk-provider": "wallee", "x-meta-sdk-language-version": this.getVersion(), }; Object.assign(headers, defaultHeaders); let requestConfig = { url, method: 'POST', baseURL: this._basePath, headers, params: queryParams, timeout: this._timeout * 1000, responseType: 'json', }; const axiosInstance = axios.default.create(); axiosInstance.interceptors.request.use(this._defaultAuthentication); return new Promise((resolve, reject) => { axiosInstance.request(requestConfig) .then(success => { let body; return resolve({ response: success.request.res, body: body }); }, failure => { var _a, _b, _c, _d, _e; let errorObject; if ((_a = failure.response) === null || _a === void 0 ? void 0 : _a.status) { if (failure.response.status >= 400 && failure.response.status <= 499) { errorObject = new ClientError_1.ClientError(); } else if (failure.response.status >= 500 && failure.response.status <= 599) { errorObject = new ServerError_1.ServerError(); } else { errorObject = new Object(); } } else { errorObject = new Object(); } return reject({ errorType: errorObject.constructor.name, date: (new Date()).toDateString(), statusCode: ((_b = failure.response) === null || _b === void 0 ? void 0 : _b.status) && isNaN(failure.response.status) ? String(failure.response.status) : "Unknown", statusMessage: ((_c = failure.response) === null || _c === void 0 ? void 0 : _c.statusText) != null ? failure.response.statusText : "Unknown", body: (_d = failure.response) === null || _d === void 0 ? void 0 : _d.data, response: (_e = failure.response) === null || _e === void 0 ? void 0 : _e.request.res }); }) .catch(error => { return reject(error); }); }); } ; /** * This operation removes the web app payment processor and its connectors from the given space. * @summary Delete Processor * @param spaceId The space ID identifies the space in which the processor is installed in. * @param externalId The external ID identifies the processor. The external ID corresponds to the ID provided during inserting of the processor. * @param {*} [options] Override http request options. */ deleteProcessor(spaceId, externalId, options = {}) { const url = '/payment-web-app/delete-processor'; let queryParams = {}; let headers = Object.assign({}, this._defaultHeaders); // verify required parameter 'spaceId' is not null or undefined if (spaceId === null || spaceId === undefined) { throw new Error('Required parameter spaceId was null or undefined when calling deleteProcessor.'); } // verify required parameter 'externalId' is not null or undefined if (externalId === null || externalId === undefined) { throw new Error('Required parameter externalId was null or undefined when calling deleteProcessor.'); } if (spaceId !== undefined) { queryParams['spaceId'] = ObjectSerializer_1.ObjectSerializer.serialize(spaceId, "number"); } if (externalId !== undefined) { queryParams['externalId'] = ObjectSerializer_1.ObjectSerializer.serialize(externalId, "string"); } headers['Content-Type'] = 'application/json'; Object.assign(headers, options.headers); let defaultHeaders = { "x-meta-sdk-version": "4.7.0", "x-meta-sdk-language": "typescript", "x-meta-sdk-provider": "wallee", "x-meta-sdk-language-version": this.getVersion(), }; Object.assign(headers, defaultHeaders); let requestConfig = { url, method: 'POST', baseURL: this._basePath, headers, params: queryParams, timeout: this._timeout * 1000, responseType: 'json', }; const axiosInstance = axios.default.create(); axiosInstance.interceptors.request.use(this._defaultAuthentication); return new Promise((resolve, reject) => { axiosInstance.request(requestConfig) .then(success => { let body; return resolve({ response: success.request.res, body: body }); }, failure => { var _a, _b, _c, _d, _e; let errorObject; if ((_a = failure.response) === null || _a === void 0 ? void 0 : _a.status) { if (failure.response.status >= 400 && failure.response.status <= 499) { errorObject = new ClientError_1.ClientError(); } else if (failure.response.status >= 500 && failure.response.status <= 599) { errorObject = new ServerError_1.ServerError(); } else { errorObject = new Object(); } } else { errorObject = new Object(); } return reject({ errorType: errorObject.constructor.name, date: (new Date()).toDateString(), statusCode: ((_b = failure.response) === null || _b === void 0 ? void 0 : _b.status) && isNaN(failure.response.status) ? String(failure.response.status) : "Unknown", statusMessage: ((_c = failure.response) === null || _c === void 0 ? void 0 : _c.statusText) != null ? failure.response.statusText : "Unknown", body: (_d = failure.response) === null || _d === void 0 ? void 0 : _d.data, response: (_e = failure.response) === null || _e === void 0 ? void 0 : _e.request.res }); }) .catch(error => { return reject(error); }); }); } ; /** * This operation inserts or updates a web app payment connector. * @summary Insert or Update Connector * @param spaceId The space ID identifies the space into which the connector should be inserted into. * @param request The connector object contains all the details required to create or update a web app connector. * @param {*} [options] Override http request options. */ insertOrUpdateConnector(spaceId, request, options = {}) { const url = '/payment-web-app/insert-or-update-connector'; let queryParams = {}; let headers = Object.assign({}, this._defaultHeaders); // verify required parameter 'spaceId' is not null or undefined if (spaceId === null || spaceId === undefined) { throw new Error('Required parameter spaceId was null or undefined when calling insertOrUpdateConnector.'); } // verify required parameter 'request' is not null or undefined if (request === null || request === undefined) { throw new Error('Required parameter request was null or undefined when calling insertOrUpdateConnector.'); } if (spaceId !== undefined) { queryParams['spaceId'] = ObjectSerializer_1.ObjectSerializer.serialize(spaceId, "number"); } headers['Content-Type'] = 'application/json'; Object.assign(headers, options.headers); let defaultHeaders = { "x-meta-sdk-version": "4.7.0", "x-meta-sdk-language": "typescript", "x-meta-sdk-provider": "wallee", "x-meta-sdk-language-version": this.getVersion(), }; Object.assign(headers, defaultHeaders); let requestConfig = { url, method: 'POST', baseURL: this._basePath, headers, params: queryParams, data: request, timeout: this._timeout * 1000, responseType: 'json', }; const axiosInstance = axios.default.create(); axiosInstance.interceptors.request.use(this._defaultAuthentication); return new Promise((resolve, reject) => { axiosInstance.request(requestConfig) .then(success => { let body; body = ObjectSerializer_1.ObjectSerializer.deserialize(success.data, "PaymentAppConnector"); return resolve({ response: success.request.res, body: body }); }, failure => { var _a, _b, _c, _d, _e; let errorObject; if ((_a = failure.response) === null || _a === void 0 ? void 0 : _a.status) { if (failure.response.status >= 400 && failure.response.status <= 499) { errorObject = new ClientError_1.ClientError(); } else if (failure.response.status >= 500 && failure.response.status <= 599) { errorObject = new ServerError_1.ServerError(); } else { errorObject = new Object(); } } else { errorObject = new Object(); } return reject({ errorType: errorObject.constructor.name, date: (new Date()).toDateString(), statusCode: ((_b = failure.response) === null || _b === void 0 ? void 0 : _b.status) && isNaN(failure.response.status) ? String(failure.response.status) : "Unknown", statusMessage: ((_c = failure.response) === null || _c === void 0 ? void 0 : _c.statusText) != null ? failure.response.statusText : "Unknown", body: (_d = failure.response) === null || _d === void 0 ? void 0 : _d.data, response: (_e = failure.response) === null || _e === void 0 ? void 0 : _e.request.res }); }) .catch(error => { return reject(error); }); }); } ; /** * This operation inserts or updates a web app payment processor. * @summary Insert or Update Processor * @param spaceId The space ID identifies the space into which the processor should be inserted into. * @param request The processor object contains all the details required to create or update a web app processor. * @param {*} [options] Override http request options. */ insertOrUpdateProcessor(spaceId, request, options = {}) { const url = '/payment-web-app/insert-or-update-processor'; let queryParams = {}; let headers = Object.assign({}, this._defaultHeaders); // verify required parameter 'spaceId' is not null or undefined if (spaceId === null || spaceId === undefined) { throw new Error('Required parameter spaceId was null or undefined when calling insertOrUpdateProcessor.'); } // verify required parameter 'request' is not null or undefined if (request === null || request === undefined) { throw new Error('Required parameter request was null or undefined when calling insertOrUpdateProcessor.'); } if (spaceId !== undefined) { queryParams['spaceId'] = ObjectSerializer_1.ObjectSerializer.serialize(spaceId, "number"); } headers['Content-Type'] = 'application/json'; Object.assign(headers, options.headers); let defaultHeaders = { "x-meta-sdk-version": "4.7.0", "x-meta-sdk-language": "typescript", "x-meta-sdk-provider": "wallee", "x-meta-sdk-language-version": this.getVersion(), }; Object.assign(headers, defaultHeaders); let requestConfig = { url, method: 'POST', baseURL: this._basePath, headers, params: queryParams, data: request, timeout: this._timeout * 1000, responseType: 'json', }; const axiosInstance = axios.default.create(); axiosInstance.interceptors.request.use(this._defaultAuthentication); return new Promise((resolve, reject) => { axiosInstance.request(requestConfig) .then(success => { let body; body = ObjectSerializer_1.ObjectSerializer.deserialize(success.data, "PaymentAppProcessor"); return resolve({ response: success.request.res, body: body }); }, failure => { var _a, _b, _c, _d, _e; let errorObject; if ((_a = failure.response) === null || _a === void 0 ? void 0 : _a.status) { if (failure.response.status >= 400 && failure.response.status <= 499) { errorObject = new ClientError_1.ClientError(); } else if (failure.response.status >= 500 && failure.response.status <= 599) { errorObject = new ServerError_1.ServerError(); } else { errorObject = new Object(); } } else { errorObject = new Object(); } return reject({ errorType: errorObject.constructor.name, date: (new Date()).toDateString(), statusCode: ((_b = failure.response) === null || _b === void 0 ? void 0 : _b.status) && isNaN(failure.response.status) ? String(failure.response.status) : "Unknown", statusMessage: ((_c = failure.response) === null || _c === void 0 ? void 0 : _c.statusText) != null ? failure.response.statusText : "Unknown", body: (_d = failure.response) === null || _d === void 0 ? void 0 : _d.data, response: (_e = failure.response) === null || _e === void 0 ? void 0 : _e.request.res }); }) .catch(error => { return reject(error); }); }); } ; /** * This operation updates the state of the charge attempt. This method can be invoked for transactions originally created with a processor associated with the web app that invokes this operation. The returned charge attempt corresponds to the charge attempt indicated in the request. * @summary Update Charge Attempt * @param spaceId This is the ID of the space in which the charge attempt is located in. * @param request The charge attempt update request allows to update the state of a charge attempt. * @param {*} [options] Override http request options. */ updateChargeAttempt(spaceId, request, options = {}) { const url = '/payment-web-app/update-charge-attempt'; let queryParams = {}; let headers = Object.assign({}, this._defaultHeaders); // verify required parameter 'spaceId' is not null or undefined if (spaceId === null || spaceId === undefined) { throw new Error('Required parameter spaceId was null or undefined when calling updateChargeAttempt.'); } // verify required parameter 'request' is not null or undefined if (request === null || request === undefined) { throw new Error('Required parameter request was null or undefined when calling updateChargeAttempt.'); } if (spaceId !== undefined) { queryParams['spaceId'] = ObjectSerializer_1.ObjectSerializer.serialize(spaceId, "number"); } headers['Content-Type'] = 'application/json'; Object.assign(headers, options.headers); let defaultHeaders = { "x-meta-sdk-version": "4.7.0", "x-meta-sdk-language": "typescript", "x-meta-sdk-provider": "wallee", "x-meta-sdk-language-version": this.getVersion(), }; Object.assign(headers, defaultHeaders); let requestConfig = { url, method: 'POST', baseURL: this._basePath, headers, params: queryParams, data: request, timeout: this._timeout * 1000, responseType: 'json', }; const axiosInstance = axios.default.create(); axiosInstance.interceptors.request.use(this._defaultAuthentication); return new Promise((resolve, reject) => { axiosInstance.request(requestConfig) .then(success => { let body; body = ObjectSerializer_1.ObjectSerializer.deserialize(success.data, "ChargeAttempt"); return resolve({ response: success.request.res, body: body }); }, failure => { var _a, _b, _c, _d, _e; let errorObject; if ((_a = failure.response) === null || _a === void 0 ? void 0 : _a.status) { if (failure.response.status >= 400 && failure.response.status <= 499) { errorObject = new ClientError_1.ClientError(); } else if (failure.response.status >= 500 && failure.response.status <= 599) { errorObject = new ServerError_1.ServerError(); } else { errorObject = new Object(); } } else { errorObject = new Object(); } return reject({ errorType: errorObject.constructor.name, date: (new Date()).toDateString(), statusCode: ((_b = failure.response) === null || _b === void 0 ? void 0 : _b.status) && isNaN(failure.response.status) ? String(failure.response.status) : "Unknown", statusMessage: ((_c = failure.response) === null || _c === void 0 ? void 0 : _c.statusText) != null ? failure.response.statusText : "Unknown", body: (_d = failure.response) === null || _d === void 0 ? void 0 : _d.data, response: (_e = failure.response) === null || _e === void 0 ? void 0 : _e.request.res }); }) .catch(error => { return reject(error); }); }); } ; /** * This operation updates the state of the transaction completion. This method can be invoked for transactions originally created with a processor associated with the web app that invokes this operation. The returned completion corresponds to the completion indicated in the request. * @summary Update Completion * @param spaceId This is the ID of the space in which the completion is located in. * @param request The completion update request allows to update the state of a completion. * @param {*} [options] Override http request options. */ updateCompletion(spaceId, request, options = {}) { const url = '/payment-web-app/update-completion'; let queryParams = {}; let headers = Object.assign({}, this._defaultHeaders); // verify required parameter 'spaceId' is not null or undefined if (spaceId === null || spaceId === undefined) { throw new Error('Required parameter spaceId was null or undefined when calling updateCompletion.'); } // verify required parameter 'request' is not null or undefined if (request === null || request === undefined) { throw new Error('Required parameter request was null or undefined when calling updateCompletion.'); } if (spaceId !== undefined) { queryParams['spaceId'] = ObjectSerializer_1.ObjectSerializer.serialize(spaceId, "number"); } headers['Content-Type'] = 'application/json'; Object.assign(headers, options.headers); let defaultHeaders = { "x-meta-sdk-version": "4.7.0", "x-meta-sdk-language": "typescript", "x-meta-sdk-provider": "wallee", "x-meta-sdk-language-version": this.getVersion(), }; Object.assign(headers, defaultHeaders); let requestConfig = { url, method: 'POST', baseURL: this._basePath, headers, params: queryParams, data: request, timeout: this._timeout * 1000, responseType: 'json', }; const axiosInstance = axios.default.create(); axiosInstance.interceptors.request.use(this._defaultAuthentication); return new Promise((resolve, reject) => { axiosInstance.request(requestConfig) .then(success => { let body; body = ObjectSerializer_1.ObjectSerializer.deserialize(success.data, "TransactionCompletion"); return resolve({ response: success.request.res, body: body }); }, failure => { var _a, _b, _c, _d, _e; let errorObject; if ((_a = failure.response) === null || _a === void 0 ? void 0 : _a.status) { if (failure.response.status >= 400 && failure.response.status <= 499) { errorObject = new ClientError_1.ClientError(); } else if (failure.response.status >= 500 && failure.response.status <= 599) { errorObject = new ServerError_1.ServerError(); } else { errorObject = new Object(); } } else { errorObject = new Object(); } return reject({ errorType: errorObject.constructor.name, date: (new Date()).toDateString(), statusCode: ((_b = failure.response) === null || _b === void 0 ? void 0 : _b.status) && isNaN(failure.response.status) ? String(failure.response.status) : "Unknown", statusMessage: ((_c = failure.response) === null || _c === void 0 ? void 0 : _c.statusText) != null ? failure.response.statusText : "Unknown", body: (_d = failure.response) === null || _d === void 0 ? void 0 : _d.data, response: (_e = failure.response) === null || _e === void 0 ? void 0 : _e.request.res }); }) .catch(error => { return reject(error); }); }); } ; /** * This operation updates the state of the refund. This method can be invoked for transactions originally created with a processor associated with the web app that invokes this operation. The returned refund corresponds to the refund indicated in the request. * @summary Update Refund * @param spaceId This is the ID of the space in which the refund is located in. * @param request The refund update request allows to update the state of a refund. * @param {*} [options] Override http request options. */ updateRefund(spaceId, request, options = {}) { const url = '/payment-web-app/update-refund'; let queryParams = {}; let headers = Object.assign({}, this._defaultHeaders); // verify required parameter 'spaceId' is not null or undefined if (spaceId === null || spaceId === undefined) { throw new Error('Required parameter spaceId was null or undefined when calling updateRefund.'); } // verify required parameter 'request' is not null or undefined if (request === null || request === undefined) { throw new Error('Required parameter request was null or undefined when calling updateRefund.'); } if (spaceId !== undefined) { queryParams['spaceId'] = ObjectSerializer_1.ObjectSerializer.serialize(spaceId, "number"); } headers['Content-Type'] = 'application/json'; Object.assign(headers, options.headers); let defaultHeaders = { "x-meta-sdk-version": "4.7.0", "x-meta-sdk-language": "typescript", "x-meta-sdk-provider": "wallee", "x-meta-sdk-language-version": this.getVersion(), }; Object.assign(headers, defaultHeaders); let requestConfig = { url, method: 'POST', baseURL: this._basePath, headers, params: queryParams, data: request, timeout: this._timeout * 1000, responseType: 'json', }; const axiosInstance = axios.default.create(); axiosInstance.interceptors.request.use(this._defaultAuthentication); return new Promise((resolve, reject) => { axiosInstance.request(requestConfig) .then(success => { let body; body = ObjectSerializer_1.ObjectSerializer.deserialize(success.data, "Refund"); return resolve({ response: success.request.res, body: body }); }, failure => { var _a, _b, _c, _d, _e; let errorObject; if ((_a = failure.response) === null || _a === void 0 ? void 0 : _a.status) { if (failure.response.status >= 400 && failure.response.status <= 499) { errorObject = new ClientError_1.ClientError(); } else if (failure.response.status >= 500 && failure.response.status <= 599) { errorObject = new ServerError_1.ServerError(); } else { errorObject = new Object(); } } else { errorObject = new Object(); } return reject({ errorType: errorObject.constructor.name, date: (new Date()).toDateString(), statusCode: ((_b = failure.response) === null || _b === void 0 ? void 0 : _b.status) && isNaN(failure.response.status) ? String(failure.response.status) : "Unknown", statusMessage: ((_c = failure.response) === null || _c === void 0 ? void 0 : _c.statusText) != null ? failure.response.statusText : "Unknown", body: (_d = failure.response) === null || _d === void 0 ? void 0 : _d.data, response: (_e = failure.response) === null || _e === void 0 ? void 0 : _e.request.res }); }) .catch(error => { return reject(error); }); }); } ; /** * This operation updates the state of the transaction void. This method can be invoked for transactions originally created with a processor associated with the web app that invokes this operation. The returned void corresponds to the void indicated in the request. * @summary Update Void * @param spaceId This is the ID of the space in which the void is located in. * @param request The void update request allows to update the state of a void. * @param {*} [options] Override http request options. */ updateVoid(spaceId, request, options = {}) { const url = '/payment-web-app/update-void'; let queryParams = {}; let headers = Object.assign({}, this._defaultHeaders); // verify required parameter 'spaceId' is not null or undefined if (spaceId === null || spaceId === undefined) { throw new Error('Required parameter spaceId was null or undefined when calling updateVoid.'); } // verify required parameter 'request' is not null or undefined if (request === null || request === undefined) { throw new Error('Required parameter request was null or undefined when calling updateVoid.'); } if (spaceId !== undefined) { queryParams['spaceId'] = ObjectSerializer_1.ObjectSerializer.serialize(spaceId, "number"); } headers['Content-Type'] = 'application/json'; Object.assign(headers, options.headers); let defaultHeaders = { "x-meta-sdk-version": "4.7.0", "x-meta-sdk-language": "typescript", "x-meta-sdk-provider": "wallee", "x-meta-sdk-language-version": this.getVersion(), }; Object.assign(headers, defaultHeaders); let requestConfig = { url, method: 'POST', baseURL: this._basePath, headers, params: queryParams, data: request, timeout: this._timeout * 1000, responseType: 'json', }; const axiosInstance = axios.default.create(); axiosInstance.interceptors.request.use(this._defaultAuthentication); return new Promise((resolve, reject) => { axiosInstance.request(requestConfig) .then(success => { let body; body = ObjectSerializer_1.ObjectSerializer.deserialize(success.data, "TransactionVoid"); return resolve({ response: success.request.res, body: body }); }, failure => { var _a, _b, _c, _d, _e; let errorObject; if ((_a = failure.response) === null || _a === void 0 ? void 0 : _a.status) { if (failure.response.status >= 400 && failure.response.status <= 499) { errorObject = new ClientError_1.ClientError(); } else if (failure.response.status >= 500 && failure.response.status <= 599) { errorObject = new ServerError_1.ServerError(); } else { errorObject = new Object(); } } else { errorObject = new Object(); } return reject({ errorType: errorObject.constructor.name, date: (new Date()).toDateString(), statusCode: ((_b = failure.response) === null || _b === void 0 ? void 0 : _b.status) && isNaN(failure.response.status) ? String(failure.response.status) : "Unknown", statusMessage: ((_c = failure.response) === null || _c === void 0 ? void 0 : _c.statusText) != null ? failure.response.statusText : "Unknown", body: (_d = failure.response) === null || _d === void 0 ? void 0 : _d.data, response: (_e = failure.response) === null || _e === void 0 ? void 0 : _e.request.res }); }) .catch(error => { return reject(error); }); }); } ; } exports.PaymentWebAppService = PaymentWebAppService;