UNPKG

xero-node

Version:

Xero NodeJS OAuth 2.0 client for xero-node

916 lines 892 kB
"use strict"; /** * Xero Accounting API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 2.17.1 * Contact: api@xero.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AccountingApi = exports.AccountingApiApiKeys = void 0; const localVarRequest = require("request"); const models_1 = require("../model/accounting/models"); const models_2 = require("../model/accounting/models"); let defaultBasePath = 'https://api.xero.com/api.xro/2.0'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== var AccountingApiApiKeys; (function (AccountingApiApiKeys) { })(AccountingApiApiKeys = exports.AccountingApiApiKeys || (exports.AccountingApiApiKeys = {})); class AccountingApi { constructor(basePathOrUsername, password, basePath) { this._basePath = defaultBasePath; this.defaultHeaders = { 'user-agent': 'xero-node-4.16.0' }; this._useQuerystring = false; this.binaryHeaders = {}; this.authentications = { 'default': new models_1.VoidAuth(), 'OAuth2': new models_2.OAuth(), }; if (password) { if (basePath) { this.basePath = basePath; } } else { if (basePathOrUsername) { this.basePath = basePathOrUsername; } } } set useQuerystring(value) { this._useQuerystring = value; } set basePath(basePath) { this._basePath = basePath; } get basePath() { return this._basePath; } setDefaultAuthentication(auth) { this.authentications.default = auth; } setApiKey(key, value) { this.authentications[AccountingApiApiKeys[key]].apiKey = value; } set accessToken(token) { this.authentications.OAuth2.accessToken = token; } /** * * @summary Creates a new chart of accounts * @param xeroTenantId Xero identifier for Tenant * @param account Account object in body of request */ createAccount(xeroTenantId, account, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/Accounts'; let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; // verify required parameter 'xeroTenantId' is not null or undefined if (xeroTenantId === null || xeroTenantId === undefined) { throw new Error('Required parameter xeroTenantId was null or undefined when calling createAccount.'); } // verify required parameter 'account' is not null or undefined if (account === null || account === undefined) { throw new Error('Required parameter account was null or undefined when calling createAccount.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: models_1.ObjectSerializer.serialize(account, "Account") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { localVarRequestOptions.formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = models_1.ObjectSerializer.deserialize(body, "Accounts"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * * @summary Creates an attachment on a specific account * @param xeroTenantId Xero identifier for Tenant * @param accountID Unique identifier for Account object * @param fileName Name of the attachment * @param body Byte array of file in body of request */ createAccountAttachmentByFileName(xeroTenantId, accountID, fileName, body, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/Accounts/{AccountID}/Attachments/{FileName}' .replace('{' + 'AccountID' + '}', encodeURIComponent(String(accountID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; // verify required parameter 'xeroTenantId' is not null or undefined if (xeroTenantId === null || xeroTenantId === undefined) { throw new Error('Required parameter xeroTenantId was null or undefined when calling createAccountAttachmentByFileName.'); } // verify required parameter 'accountID' is not null or undefined if (accountID === null || accountID === undefined) { throw new Error('Required parameter accountID was null or undefined when calling createAccountAttachmentByFileName.'); } // verify required parameter 'fileName' is not null or undefined if (fileName === null || fileName === undefined) { throw new Error('Required parameter fileName was null or undefined when calling createAccountAttachmentByFileName.'); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling createAccountAttachmentByFileName.'); } this.binaryHeaders = { 'Accept': 'application/json' }; Object.assign(localVarHeaderParams, this.binaryHeaders); localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, body: models_1.ObjectSerializer.serialize(body, "string") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { localVarRequestOptions.formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } }).then(() => { // Reads file stream as chunks so we can put it in body of request. // This collects the whole file into memory, which is why we do it _after_ authentication. return new Promise((resolve, reject) => { const fileContents = []; body.on('data', (chunk) => { fileContents.push(chunk); }); body.on('end', () => { resolve(fileContents); }); body.on('error', (err) => { reject(err); }); }); }).then((fileContents) => { localVarRequestOptions.body = fileContents; return new Promise((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { try { body = JSON.parse(body); } catch (err) { console.log('JSON parse body failed'); } body = models_1.ObjectSerializer.deserialize(body, "Attachments"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * * @summary Creates an attachment for a specific bank transaction by filename * @param xeroTenantId Xero identifier for Tenant * @param bankTransactionID Xero generated unique identifier for a bank transaction * @param fileName Name of the attachment * @param body Byte array of file in body of request */ createBankTransactionAttachmentByFileName(xeroTenantId, bankTransactionID, fileName, body, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/BankTransactions/{BankTransactionID}/Attachments/{FileName}' .replace('{' + 'BankTransactionID' + '}', encodeURIComponent(String(bankTransactionID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; // verify required parameter 'xeroTenantId' is not null or undefined if (xeroTenantId === null || xeroTenantId === undefined) { throw new Error('Required parameter xeroTenantId was null or undefined when calling createBankTransactionAttachmentByFileName.'); } // verify required parameter 'bankTransactionID' is not null or undefined if (bankTransactionID === null || bankTransactionID === undefined) { throw new Error('Required parameter bankTransactionID was null or undefined when calling createBankTransactionAttachmentByFileName.'); } // verify required parameter 'fileName' is not null or undefined if (fileName === null || fileName === undefined) { throw new Error('Required parameter fileName was null or undefined when calling createBankTransactionAttachmentByFileName.'); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling createBankTransactionAttachmentByFileName.'); } this.binaryHeaders = { 'Accept': 'application/json' }; Object.assign(localVarHeaderParams, this.binaryHeaders); localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, body: models_1.ObjectSerializer.serialize(body, "string") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { localVarRequestOptions.formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } }).then(() => { // Reads file stream as chunks so we can put it in body of request. // This collects the whole file into memory, which is why we do it _after_ authentication. return new Promise((resolve, reject) => { const fileContents = []; body.on('data', (chunk) => { fileContents.push(chunk); }); body.on('end', () => { resolve(fileContents); }); body.on('error', (err) => { reject(err); }); }); }).then((fileContents) => { localVarRequestOptions.body = fileContents; return new Promise((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { try { body = JSON.parse(body); } catch (err) { console.log('JSON parse body failed'); } body = models_1.ObjectSerializer.deserialize(body, "Attachments"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * * @summary Creates a history record for a specific bank transactions * @param xeroTenantId Xero identifier for Tenant * @param bankTransactionID Xero generated unique identifier for a bank transaction * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request */ createBankTransactionHistoryRecord(xeroTenantId, bankTransactionID, historyRecords, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/BankTransactions/{BankTransactionID}/History' .replace('{' + 'BankTransactionID' + '}', encodeURIComponent(String(bankTransactionID))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; // verify required parameter 'xeroTenantId' is not null or undefined if (xeroTenantId === null || xeroTenantId === undefined) { throw new Error('Required parameter xeroTenantId was null or undefined when calling createBankTransactionHistoryRecord.'); } // verify required parameter 'bankTransactionID' is not null or undefined if (bankTransactionID === null || bankTransactionID === undefined) { throw new Error('Required parameter bankTransactionID was null or undefined when calling createBankTransactionHistoryRecord.'); } // verify required parameter 'historyRecords' is not null or undefined if (historyRecords === null || historyRecords === undefined) { throw new Error('Required parameter historyRecords was null or undefined when calling createBankTransactionHistoryRecord.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: models_1.ObjectSerializer.serialize(historyRecords, "HistoryRecords") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { localVarRequestOptions.formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = models_1.ObjectSerializer.deserialize(body, "HistoryRecords"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * * @summary Creates one or more spent or received money transaction * @param xeroTenantId Xero identifier for Tenant * @param bankTransactions BankTransactions with an array of BankTransaction objects in body of request * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors * @param unitdp e.g. unitdp&#x3D;4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ createBankTransactions(xeroTenantId, bankTransactions, summarizeErrors, unitdp, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/BankTransactions'; let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; // verify required parameter 'xeroTenantId' is not null or undefined if (xeroTenantId === null || xeroTenantId === undefined) { throw new Error('Required parameter xeroTenantId was null or undefined when calling createBankTransactions.'); } // verify required parameter 'bankTransactions' is not null or undefined if (bankTransactions === null || bankTransactions === undefined) { throw new Error('Required parameter bankTransactions was null or undefined when calling createBankTransactions.'); } if (summarizeErrors !== undefined) { localVarQueryParameters['summarizeErrors'] = models_1.ObjectSerializer.serialize(summarizeErrors, "boolean"); } if (unitdp !== undefined) { localVarQueryParameters['unitdp'] = models_1.ObjectSerializer.serialize(unitdp, "number"); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: models_1.ObjectSerializer.serialize(bankTransactions, "BankTransactions") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { localVarRequestOptions.formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = models_1.ObjectSerializer.deserialize(body, "BankTransactions"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * * @summary Creates a bank transfer * @param xeroTenantId Xero identifier for Tenant * @param bankTransfers BankTransfers with array of BankTransfer objects in request body */ createBankTransfer(xeroTenantId, bankTransfers, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/BankTransfers'; let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; // verify required parameter 'xeroTenantId' is not null or undefined if (xeroTenantId === null || xeroTenantId === undefined) { throw new Error('Required parameter xeroTenantId was null or undefined when calling createBankTransfer.'); } // verify required parameter 'bankTransfers' is not null or undefined if (bankTransfers === null || bankTransfers === undefined) { throw new Error('Required parameter bankTransfers was null or undefined when calling createBankTransfer.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: models_1.ObjectSerializer.serialize(bankTransfers, "BankTransfers") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { localVarRequestOptions.formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = models_1.ObjectSerializer.deserialize(body, "BankTransfers"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * * @param xeroTenantId Xero identifier for Tenant * @param bankTransferID Xero generated unique identifier for a bank transfer * @param fileName Name of the attachment * @param body Byte array of file in body of request */ createBankTransferAttachmentByFileName(xeroTenantId, bankTransferID, fileName, body, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/BankTransfers/{BankTransferID}/Attachments/{FileName}' .replace('{' + 'BankTransferID' + '}', encodeURIComponent(String(bankTransferID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; // verify required parameter 'xeroTenantId' is not null or undefined if (xeroTenantId === null || xeroTenantId === undefined) { throw new Error('Required parameter xeroTenantId was null or undefined when calling createBankTransferAttachmentByFileName.'); } // verify required parameter 'bankTransferID' is not null or undefined if (bankTransferID === null || bankTransferID === undefined) { throw new Error('Required parameter bankTransferID was null or undefined when calling createBankTransferAttachmentByFileName.'); } // verify required parameter 'fileName' is not null or undefined if (fileName === null || fileName === undefined) { throw new Error('Required parameter fileName was null or undefined when calling createBankTransferAttachmentByFileName.'); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling createBankTransferAttachmentByFileName.'); } this.binaryHeaders = { 'Accept': 'application/json' }; Object.assign(localVarHeaderParams, this.binaryHeaders); localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, body: models_1.ObjectSerializer.serialize(body, "string") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { localVarRequestOptions.formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } }).then(() => { // Reads file stream as chunks so we can put it in body of request. // This collects the whole file into memory, which is why we do it _after_ authentication. return new Promise((resolve, reject) => { const fileContents = []; body.on('data', (chunk) => { fileContents.push(chunk); }); body.on('end', () => { resolve(fileContents); }); body.on('error', (err) => { reject(err); }); }); }).then((fileContents) => { localVarRequestOptions.body = fileContents; return new Promise((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { try { body = JSON.parse(body); } catch (err) { console.log('JSON parse body failed'); } body = models_1.ObjectSerializer.deserialize(body, "Attachments"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * * @summary Creates a history record for a specific bank transfer * @param xeroTenantId Xero identifier for Tenant * @param bankTransferID Xero generated unique identifier for a bank transfer * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request */ createBankTransferHistoryRecord(xeroTenantId, bankTransferID, historyRecords, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/BankTransfers/{BankTransferID}/History' .replace('{' + 'BankTransferID' + '}', encodeURIComponent(String(bankTransferID))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; // verify required parameter 'xeroTenantId' is not null or undefined if (xeroTenantId === null || xeroTenantId === undefined) { throw new Error('Required parameter xeroTenantId was null or undefined when calling createBankTransferHistoryRecord.'); } // verify required parameter 'bankTransferID' is not null or undefined if (bankTransferID === null || bankTransferID === undefined) { throw new Error('Required parameter bankTransferID was null or undefined when calling createBankTransferHistoryRecord.'); } // verify required parameter 'historyRecords' is not null or undefined if (historyRecords === null || historyRecords === undefined) { throw new Error('Required parameter historyRecords was null or undefined when calling createBankTransferHistoryRecord.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: models_1.ObjectSerializer.serialize(historyRecords, "HistoryRecords") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { localVarRequestOptions.formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = models_1.ObjectSerializer.deserialize(body, "HistoryRecords"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * * @summary Creates one or many batch payments for invoices * @param xeroTenantId Xero identifier for Tenant * @param batchPayments BatchPayments with an array of Payments in body of request * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ createBatchPayment(xeroTenantId, batchPayments, summarizeErrors, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/BatchPayments'; let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; // verify required parameter 'xeroTenantId' is not null or undefined if (xeroTenantId === null || xeroTenantId === undefined) { throw new Error('Required parameter xeroTenantId was null or undefined when calling createBatchPayment.'); } // verify required parameter 'batchPayments' is not null or undefined if (batchPayments === null || batchPayments === undefined) { throw new Error('Required parameter batchPayments was null or undefined when calling createBatchPayment.'); } if (summarizeErrors !== undefined) { localVarQueryParameters['summarizeErrors'] = models_1.ObjectSerializer.serialize(summarizeErrors, "boolean"); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: models_1.ObjectSerializer.serialize(batchPayments, "BatchPayments") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { localVarRequestOptions.formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = models_1.ObjectSerializer.deserialize(body, "BatchPayments"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * * @summary Creates a history record for a specific batch payment * @param xeroTenantId Xero identifier for Tenant * @param batchPaymentID Unique identifier for BatchPayment * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request */ createBatchPaymentHistoryRecord(xeroTenantId, batchPaymentID, historyRecords, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/BatchPayments/{BatchPaymentID}/History' .replace('{' + 'BatchPaymentID' + '}', encodeURIComponent(String(batchPaymentID))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; // verify required parameter 'xeroTenantId' is not null or undefined if (xeroTenantId === null || xeroTenantId === undefined) { throw new Error('Required parameter xeroTenantId was null or undefined when calling createBatchPaymentHistoryRecord.'); } // verify required parameter 'batchPaymentID' is not null or undefined if (batchPaymentID === null || batchPaymentID === undefined) { throw new Error('Required parameter batchPaymentID was null or undefined when calling createBatchPaymentHistoryRecord.'); } // verify required parameter 'historyRecords' is not null or undefined if (historyRecords === null || historyRecords === undefined) { throw new Error('Required parameter historyRecords was null or undefined when calling createBatchPaymentHistoryRecord.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: models_1.ObjectSerializer.serialize(historyRecords, "HistoryRecords") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { localVarRequestOptions.formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = models_1.ObjectSerializer.deserialize(body, "HistoryRecords"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * * @summary Creates a new custom payment service for a specific branding theme * @param xeroTenantId Xero identifier for Tenant * @param brandingThemeID Unique identifier for a Branding Theme * @param paymentService PaymentService object in body of request */ createBrandingThemePaymentServices(xeroTenantId, brandingThemeID, paymentService, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/BrandingThemes/{BrandingThemeID}/PaymentServices' .replace('{' + 'BrandingThemeID' + '}', encodeURIComponent(String(brandingThemeID))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; // verify required parameter 'xeroTenantId' is not null or undefined if (xeroTenantId === null || xeroTenantId === undefined) { throw new Error('Required parameter xeroTenantId was null or undefined when calling createBrandingThemePaymentServices.'); } // verify required parameter 'brandingThemeID' is not null or undefined if (brandingThemeID === null || brandingThemeID === undefined) { throw new Error('Required parameter brandingThemeID was null or undefined when calling createBrandingThemePaymentServices.'); } // verify required parameter 'paymentService' is not null or undefined if (paymentService === null || paymentService === undefined) { throw new Error('Required parameter paymentService was null or undefined when calling createBrandingThemePaymentServices.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: models_1.ObjectSerializer.serialize(paymentService, "PaymentService") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { localVarRequestOptions.formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = models_1.ObjectSerializer.deserialize(body, "PaymentServices"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * * @param xeroTenantId Xero identifier for Tenant * @param contactID Unique identifier for a Contact * @param fileName Name of the attachment * @param body Byte array of file in body of request */ createContactAttachmentByFileName(xeroTenan