UNPKG

xero-node

Version:

Xero NodeJS OAuth 2.0 client for xero-node

856 lines 87.3 kB
"use strict"; /** * Xero Files API * These endpoints are specific to Xero Files API * * The version of the OpenAPI document: 12.0.0 * 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()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FilesApi = exports.FilesApiApiKeys = void 0; const models_1 = require("../model/files/models"); const ApiError_1 = require("../../model/ApiError"); const axios_1 = __importDefault(require("axios")); const models_2 = require("../model/files/models"); let defaultBasePath = 'https://api.xero.com/files.xro/1.0'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== var FilesApiApiKeys; (function (FilesApiApiKeys) { })(FilesApiApiKeys || (exports.FilesApiApiKeys = FilesApiApiKeys = {})); class FilesApi { constructor(basePathOrUsername, password, basePath) { this._basePath = defaultBasePath; this.defaultHeaders = { 'user-agent': 'xero-node-15.0.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[FilesApiApiKeys[key]].apiKey = value; } set accessToken(token) { this.authentications.OAuth2.accessToken = token; } /** * By passing in the appropriate options, you can create a new folder * @summary Creates a new file association * @param xeroTenantId Xero identifier for Tenant * @param fileId File id for single object * @param association * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createFileAssociation(xeroTenantId_1, fileId_1, association_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, fileId, association, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Files/{FileId}/Associations' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; let acceptHeadersFromSpec = [ "application/json" ]; const isBufferType = acceptHeadersFromSpec.includes("application/pdf") || acceptHeadersFromSpec.includes("application/octet-stream") || acceptHeadersFromSpec.includes("application/jpg"); const responseTypeOption = isBufferType ? "arraybuffer" : "json"; // 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 createFileAssociation.'); } // verify required parameter 'fileId' is not null or undefined if (fileId === null || fileId === undefined) { throw new Error('Required parameter fileId was null or undefined when calling createFileAssociation.'); } // verify required parameter 'association' is not null or undefined if (association === null || association === undefined) { throw new Error('Required parameter association was null or undefined when calling createFileAssociation.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); localVarHeaderParams['Idempotency-Key'] = models_1.ObjectSerializer.serialize(idempotencyKey, "string"); localVarHeaderParams['Accept'] = acceptHeadersFromSpec.join(); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, data: models_1.ObjectSerializer.serialize(association, "Association"), }; 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.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'Content-Type': 'multipart/form-data' }); } else { localVarRequestOptions.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'content-type': 'application/x-www-form-urlencoded' }); } } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let body = null; try { const response = yield (0, axios_1.default)(localVarRequestOptions); body = models_1.ObjectSerializer.deserialize(response.data, "Association"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * By passing in the appropriate properties, you can create a new folder * @summary Creates a new folder * @param xeroTenantId Xero identifier for Tenant * @param folder * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createFolder(xeroTenantId_1, folder_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, folder, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Folders'; let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; let acceptHeadersFromSpec = [ "application/json" ]; const isBufferType = acceptHeadersFromSpec.includes("application/pdf") || acceptHeadersFromSpec.includes("application/octet-stream") || acceptHeadersFromSpec.includes("application/jpg"); const responseTypeOption = isBufferType ? "arraybuffer" : "json"; // 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 createFolder.'); } // verify required parameter 'folder' is not null or undefined if (folder === null || folder === undefined) { throw new Error('Required parameter folder was null or undefined when calling createFolder.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); localVarHeaderParams['Idempotency-Key'] = models_1.ObjectSerializer.serialize(idempotencyKey, "string"); localVarHeaderParams['Accept'] = acceptHeadersFromSpec.join(); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, data: models_1.ObjectSerializer.serialize(folder, "Folder"), }; 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.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'Content-Type': 'multipart/form-data' }); } else { localVarRequestOptions.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'content-type': 'application/x-www-form-urlencoded' }); } } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let body = null; try { const response = yield (0, axios_1.default)(localVarRequestOptions); body = models_1.ObjectSerializer.deserialize(response.data, "Folder"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * Delete a specific file * @summary Deletes a specific file * @param xeroTenantId Xero identifier for Tenant * @param fileId File id for single object */ deleteFile(xeroTenantId_1, fileId_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, fileId, options = { headers: {} }) { const localVarPath = this.basePath + '/Files/{FileId}' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; let acceptHeadersFromSpec = []; const isBufferType = acceptHeadersFromSpec.includes("application/pdf") || acceptHeadersFromSpec.includes("application/octet-stream") || acceptHeadersFromSpec.includes("application/jpg"); const responseTypeOption = isBufferType ? "arraybuffer" : "json"; // 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 deleteFile.'); } // verify required parameter 'fileId' is not null or undefined if (fileId === null || fileId === undefined) { throw new Error('Required parameter fileId was null or undefined when calling deleteFile.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); localVarHeaderParams['Accept'] = acceptHeadersFromSpec.join(); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, data: {}, }; 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.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'Content-Type': 'multipart/form-data' }); } else { localVarRequestOptions.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'content-type': 'application/x-www-form-urlencoded' }); } } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let body = null; try { const response = yield (0, axios_1.default)(localVarRequestOptions); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * By passing in the appropriate options, you can create a new folder * @summary Deletes an existing file association * @param xeroTenantId Xero identifier for Tenant * @param fileId File id for single object * @param objectId Object id for single object */ deleteFileAssociation(xeroTenantId_1, fileId_1, objectId_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, fileId, objectId, options = { headers: {} }) { const localVarPath = this.basePath + '/Files/{FileId}/Associations/{ObjectId}' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))) .replace('{' + 'ObjectId' + '}', encodeURIComponent(String(objectId))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; let acceptHeadersFromSpec = []; const isBufferType = acceptHeadersFromSpec.includes("application/pdf") || acceptHeadersFromSpec.includes("application/octet-stream") || acceptHeadersFromSpec.includes("application/jpg"); const responseTypeOption = isBufferType ? "arraybuffer" : "json"; // 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 deleteFileAssociation.'); } // verify required parameter 'fileId' is not null or undefined if (fileId === null || fileId === undefined) { throw new Error('Required parameter fileId was null or undefined when calling deleteFileAssociation.'); } // verify required parameter 'objectId' is not null or undefined if (objectId === null || objectId === undefined) { throw new Error('Required parameter objectId was null or undefined when calling deleteFileAssociation.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); localVarHeaderParams['Accept'] = acceptHeadersFromSpec.join(); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, data: {}, }; 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.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'Content-Type': 'multipart/form-data' }); } else { localVarRequestOptions.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'content-type': 'application/x-www-form-urlencoded' }); } } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let body = null; try { const response = yield (0, axios_1.default)(localVarRequestOptions); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * By passing in the appropriate ID, you can delete a folder * @summary Deletes a folder * @param xeroTenantId Xero identifier for Tenant * @param folderId Folder id for single object */ deleteFolder(xeroTenantId_1, folderId_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, folderId, options = { headers: {} }) { const localVarPath = this.basePath + '/Folders/{FolderId}' .replace('{' + 'FolderId' + '}', encodeURIComponent(String(folderId))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; let acceptHeadersFromSpec = []; const isBufferType = acceptHeadersFromSpec.includes("application/pdf") || acceptHeadersFromSpec.includes("application/octet-stream") || acceptHeadersFromSpec.includes("application/jpg"); const responseTypeOption = isBufferType ? "arraybuffer" : "json"; // 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 deleteFolder.'); } // verify required parameter 'folderId' is not null or undefined if (folderId === null || folderId === undefined) { throw new Error('Required parameter folderId was null or undefined when calling deleteFolder.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); localVarHeaderParams['Accept'] = acceptHeadersFromSpec.join(); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, data: {}, }; 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.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'Content-Type': 'multipart/form-data' }); } else { localVarRequestOptions.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'content-type': 'application/x-www-form-urlencoded' }); } } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let body = null; try { const response = yield (0, axios_1.default)(localVarRequestOptions); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * By passing in the appropriate options, you can retrieve an association * @summary Retrieves an association object using a unique object ID * @param xeroTenantId Xero identifier for Tenant * @param objectId Object id for single object * @param pagesize pass an optional page size value * @param page number of records to skip for pagination * @param sort values to sort by * @param direction direction to sort by */ getAssociationsByObject(xeroTenantId_1, objectId_1, pagesize_1, page_1, sort_1, direction_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, objectId, pagesize, page, sort, direction, options = { headers: {} }) { const localVarPath = this.basePath + '/Associations/{ObjectId}' .replace('{' + 'ObjectId' + '}', encodeURIComponent(String(objectId))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; let acceptHeadersFromSpec = [ "application/json" ]; const isBufferType = acceptHeadersFromSpec.includes("application/pdf") || acceptHeadersFromSpec.includes("application/octet-stream") || acceptHeadersFromSpec.includes("application/jpg"); const responseTypeOption = isBufferType ? "arraybuffer" : "json"; // 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 getAssociationsByObject.'); } // verify required parameter 'objectId' is not null or undefined if (objectId === null || objectId === undefined) { throw new Error('Required parameter objectId was null or undefined when calling getAssociationsByObject.'); } if (pagesize !== undefined) { localVarQueryParameters['pagesize'] = models_1.ObjectSerializer.serialize(pagesize, "number"); } if (page !== undefined) { localVarQueryParameters['page'] = models_1.ObjectSerializer.serialize(page, "number"); } if (sort !== undefined) { localVarQueryParameters['sort'] = models_1.ObjectSerializer.serialize(sort, "'Name' | 'CreatedDateUTC'"); } if (direction !== undefined) { localVarQueryParameters['direction'] = models_1.ObjectSerializer.serialize(direction, "'ASC' | 'DESC'"); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); localVarHeaderParams['Accept'] = acceptHeadersFromSpec.join(); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, data: {}, }; 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.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'Content-Type': 'multipart/form-data' }); } else { localVarRequestOptions.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'content-type': 'application/x-www-form-urlencoded' }); } } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let body = null; try { const response = yield (0, axios_1.default)(localVarRequestOptions); body = models_1.ObjectSerializer.deserialize(response.data, "Array<Association>"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * By passing in the appropriate options, you can retrieve the association count for objects * @summary Retrieves a count of associations for a list of objects. * @param xeroTenantId Xero identifier for Tenant * @param objectIds A comma-separated list of object ids */ getAssociationsCount(xeroTenantId_1, objectIds_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, objectIds, options = { headers: {} }) { const localVarPath = this.basePath + '/Associations/Count'; let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; let acceptHeadersFromSpec = [ "application/json" ]; const isBufferType = acceptHeadersFromSpec.includes("application/pdf") || acceptHeadersFromSpec.includes("application/octet-stream") || acceptHeadersFromSpec.includes("application/jpg"); const responseTypeOption = isBufferType ? "arraybuffer" : "json"; // 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 getAssociationsCount.'); } // verify required parameter 'objectIds' is not null or undefined if (objectIds === null || objectIds === undefined) { throw new Error('Required parameter objectIds was null or undefined when calling getAssociationsCount.'); } if (objectIds !== undefined) { localVarQueryParameters['ObjectIds'] = models_1.ObjectSerializer.serialize(objectIds, "Array<string>"); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); localVarHeaderParams['Accept'] = acceptHeadersFromSpec.join(); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, data: {}, }; 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.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'Content-Type': 'multipart/form-data' }); } else { localVarRequestOptions.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'content-type': 'application/x-www-form-urlencoded' }); } } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let body = null; try { const response = yield (0, axios_1.default)(localVarRequestOptions); body = models_1.ObjectSerializer.deserialize(response.data, "object"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * * @summary Retrieves a file by a unique file ID * @param xeroTenantId Xero identifier for Tenant * @param fileId File id for single object */ getFile(xeroTenantId_1, fileId_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, fileId, options = { headers: {} }) { const localVarPath = this.basePath + '/Files/{FileId}' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; let acceptHeadersFromSpec = [ "application/json" ]; const isBufferType = acceptHeadersFromSpec.includes("application/pdf") || acceptHeadersFromSpec.includes("application/octet-stream") || acceptHeadersFromSpec.includes("application/jpg"); const responseTypeOption = isBufferType ? "arraybuffer" : "json"; // 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 getFile.'); } // verify required parameter 'fileId' is not null or undefined if (fileId === null || fileId === undefined) { throw new Error('Required parameter fileId was null or undefined when calling getFile.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); localVarHeaderParams['Accept'] = acceptHeadersFromSpec.join(); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, data: {}, }; 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.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'Content-Type': 'multipart/form-data' }); } else { localVarRequestOptions.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'content-type': 'application/x-www-form-urlencoded' }); } } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let body = null; try { const response = yield (0, axios_1.default)(localVarRequestOptions); body = models_1.ObjectSerializer.deserialize(response.data, "FileObject"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * By passing in the appropriate options, * @summary Retrieves a specific file associations * @param xeroTenantId Xero identifier for Tenant * @param fileId File id for single object */ getFileAssociations(xeroTenantId_1, fileId_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, fileId, options = { headers: {} }) { const localVarPath = this.basePath + '/Files/{FileId}/Associations' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; let acceptHeadersFromSpec = [ "application/json" ]; const isBufferType = acceptHeadersFromSpec.includes("application/pdf") || acceptHeadersFromSpec.includes("application/octet-stream") || acceptHeadersFromSpec.includes("application/jpg"); const responseTypeOption = isBufferType ? "arraybuffer" : "json"; // 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 getFileAssociations.'); } // verify required parameter 'fileId' is not null or undefined if (fileId === null || fileId === undefined) { throw new Error('Required parameter fileId was null or undefined when calling getFileAssociations.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); localVarHeaderParams['Accept'] = acceptHeadersFromSpec.join(); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, data: {}, }; 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.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'Content-Type': 'multipart/form-data' }); } else { localVarRequestOptions.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'content-type': 'application/x-www-form-urlencoded' }); } } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let body = null; try { const response = yield (0, axios_1.default)(localVarRequestOptions); body = models_1.ObjectSerializer.deserialize(response.data, "Array<Association>"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * By passing in the appropriate options, retrieve data for specific file * @summary Retrieves the content of a specific file * @param xeroTenantId Xero identifier for Tenant * @param fileId File id for single object */ getFileContent(xeroTenantId_1, fileId_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, fileId, options = { headers: {} }) { const localVarPath = this.basePath + '/Files/{FileId}/Content' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))); let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; let acceptHeadersFromSpec = [ "application/octet-stream" ]; const isBufferType = acceptHeadersFromSpec.includes("application/pdf") || acceptHeadersFromSpec.includes("application/octet-stream") || acceptHeadersFromSpec.includes("application/jpg"); const responseTypeOption = isBufferType ? "arraybuffer" : "json"; // 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 getFileContent.'); } // verify required parameter 'fileId' is not null or undefined if (fileId === null || fileId === undefined) { throw new Error('Required parameter fileId was null or undefined when calling getFileContent.'); } localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); localVarHeaderParams['Accept'] = acceptHeadersFromSpec.join(); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, data: {}, }; 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.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'Content-Type': 'multipart/form-data' }); } else { localVarRequestOptions.data = localVarFormParams; localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarRequestOptions.headers), { 'content-type': 'application/x-www-form-urlencoded' }); } } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let body = null; try { const response = yield (0, axios_1.default)(localVarRequestOptions); body = models_1.ObjectSerializer.deserialize(response.data, "Buffer"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * * @summary Retrieves files * @param xeroTenantId Xero identifier for Tenant * @param pagesize pass an optional page size value * @param page number of records to skip for pagination * @param sort values to sort by * @param direction sort direction */ getFiles(xeroTenantId_1, pagesize_1, page_1, sort_1, direction_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, pagesize, page, sort, direction, options = { headers: {} }) { const localVarPath = this.basePath + '/Files'; let localVarQueryParameters = {}; let localVarHeaderParams = Object.assign({}, this.defaultHeaders); let localVarFormParams = {}; let acceptHeadersFromSpec = [ "application/json" ]; const isBufferType = acceptHeadersFromSpec.includes("application/pdf") || acceptHeadersFromSpec.includes("application/octet-stream") || acceptHeadersFromSpec.includes("application/jpg"); const responseTypeOption = isBufferType ? "arraybuffer" : "json"; // 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 getFiles.'); } if (pagesize !== undefined) { localVarQueryParameters['pagesize'] = models_1.ObjectSerializer.serialize(pagesize, "number"); } if (page !== undefined) { localVarQueryParameters['page'] = models_1.ObjectSerializer.serialize(page, "number"); } if (sort !== undefined) { localVarQueryParameters['sort'] = models_1.ObjectSerializer.serialize(sort, "'Name' | 'Size' | 'CreatedDateUTC'"); } if (direction !== undefined) { localVarQueryParameters['direction'] = models_1.ObjectSerializer.serialize(direction, "'ASC' | 'DESC'"); } localVarHeaderParams['xero-tenant-id'] = m