xero-node
Version:
Xero NodeJS OAuth 2.0 client for xero-node
969 lines • 62.9 kB
JavaScript
"use strict";
/**
* Xero Files API
* These endpoints are specific to Xero Files API
*
* 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.FilesApi = exports.FilesApiApiKeys = void 0;
const localVarRequest = require("request");
const models_1 = require("../model/files/models");
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 || (exports.FilesApiApiKeys = {}));
class FilesApi {
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[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
*/
createFileAssociation(xeroTenantId, fileId, association, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Files/{FileId}/Associations'
.replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId)));
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 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.');
}
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(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.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, "Association");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
* 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
*/
createFolder(xeroTenantId, folder, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Folders';
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 createFolder.');
}
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(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.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, "Folder");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
* Delete a specific file
* @summary Deletes a specific file
* @param xeroTenantId Xero identifier for Tenant
* @param fileId File id for single object
*/
deleteFile(xeroTenantId, fileId, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Files/{FileId}'
.replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId)));
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 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");
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'DELETE',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
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 {
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
* 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, fileId, objectId, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
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 = {};
// 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");
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'DELETE',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
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 {
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
* 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, folderId, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Folders/{FolderId}'
.replace('{' + 'FolderId' + '}', encodeURIComponent(String(folderId)));
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 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");
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'DELETE',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
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 {
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
* By passing in the appropriate options,
* @summary Retrieves an association object using a unique object ID
* @param xeroTenantId Xero identifier for Tenant
* @param objectId Object id for single object
*/
getAssociationsByObject(xeroTenantId, objectId, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Associations/{ObjectId}'
.replace('{' + 'ObjectId' + '}', encodeURIComponent(String(objectId)));
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 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.');
}
localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string");
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
};
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, "Array<Association>");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Retrieves a file by a unique file ID
* @param xeroTenantId Xero identifier for Tenant
* @param fileId File id for single object
*/
getFile(xeroTenantId, fileId, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Files/{FileId}'
.replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId)));
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 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");
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
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, "FileObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
* 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, fileId, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Files/{FileId}/Associations'
.replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId)));
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 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");
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
};
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, "Array<Association>");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
* 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, fileId, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Files/{FileId}/Content'
.replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId)));
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 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");
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
encoding: null,
};
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, "Buffer");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @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
*/
getFiles(xeroTenantId, pagesize, page, sort, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Files';
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 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'");
}
localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string");
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
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, "Files");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
* By passing in the appropriate ID, you can search for specific folder
* @summary Retrieves specific folder by using a unique folder ID
* @param xeroTenantId Xero identifier for Tenant
* @param folderId Folder id for single object
*/
getFolder(xeroTenantId, folderId, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Folders/{FolderId}'
.replace('{' + 'FolderId' + '}', encodeURIComponent(String(folderId)));
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 getFolder.');
}
// 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 getFolder.');
}
localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string");
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
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, "Folder");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
* By passing in the appropriate options, you can search for available folders
* @summary Retrieves folders
* @param xeroTenantId Xero identifier for Tenant
* @param sort values to sort by
*/
getFolders(xeroTenantId, sort, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Folders';
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 getFolders.');
}
if (sort !== undefined) {
localVarQueryParameters['sort'] = models_1.ObjectSerializer.serialize(sort, "'Name' | 'Size' | 'CreatedDateUTC'");
}
localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string");
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
};
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, "Array<Folder>");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
* Search for the user inbox
* @summary Retrieves inbox folder
* @param xeroTenantId Xero identifier for Tenant
*/
getInbox(xeroTenantId, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Inbox';
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 getInbox.');
}
localVarHeaderParams['xero-tenant-id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string");
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
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, "Folder");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
* Updates file properties of a single file
* @summary Update a file
* @param xeroTenantId Xero identifier for Tenant
* @param fileId File id for single object
* @param fileObject
*/
updateFile(xeroTenantId, fileId, fileObject, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Files/{FileId}'
.replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId)));
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 updateFile.');
}
// 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 updateFile.');
}
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(fileObject, "FileObject")
};
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, "FileObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
* By passing in the appropriate ID and properties, you can update a folder
* @summary Updates an existing folder
* @param xeroTenantId Xero identifier for Tenant
* @param folderId Folder id for single object
* @param folder
*/
updateFolder(xeroTenantId, folderId, folder, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Folders/{FolderId}'
.replace('{' + 'FolderId' + '}', encodeURIComponent(String(folderId)));
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 unde