UNPKG

xero-node

Version:

Xero NodeJS OAuth 2.0 client for xero-node

828 lines 85.4 kB
"use strict"; /** * Xero Projects API * This is the Xero Projects 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.ProjectApi = exports.ProjectApiApiKeys = void 0; const models_1 = require("../model/projects/models"); const ApiError_1 = require("../../model/ApiError"); const axios_1 = __importDefault(require("axios")); const models_2 = require("../model/projects/models"); let defaultBasePath = 'https://api.xero.com/projects.xro/2.0'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== var ProjectApiApiKeys; (function (ProjectApiApiKeys) { })(ProjectApiApiKeys || (exports.ProjectApiApiKeys = ProjectApiApiKeys = {})); class ProjectApi { 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[ProjectApiApiKeys[key]].apiKey = value; } set accessToken(token) { this.authentications.OAuth2.accessToken = token; } /** * * @summary Create one or more new projects * @param xeroTenantId Xero identifier for Tenant * @param projectCreateOrUpdate Create a new project with ProjectCreateOrUpdate object * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createProject(xeroTenantId_1, projectCreateOrUpdate_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, projectCreateOrUpdate, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Projects'; 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 createProject.'); } // verify required parameter 'projectCreateOrUpdate' is not null or undefined if (projectCreateOrUpdate === null || projectCreateOrUpdate === undefined) { throw new Error('Required parameter projectCreateOrUpdate was null or undefined when calling createProject.'); } 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(projectCreateOrUpdate, "ProjectCreateOrUpdate"), }; 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, "Project"); 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())); } })); }); }); } /** * Allows you to create a specific task * @summary Allows you to create a task * @param xeroTenantId Xero identifier for Tenant * @param projectId You can create a task on a specified projectId * @param taskCreateOrUpdate The task object you are creating * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createTask(xeroTenantId_1, projectId_1, taskCreateOrUpdate_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, projectId, taskCreateOrUpdate, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Projects/{projectId}/Tasks' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); 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 createTask.'); } // verify required parameter 'projectId' is not null or undefined if (projectId === null || projectId === undefined) { throw new Error('Required parameter projectId was null or undefined when calling createTask.'); } // verify required parameter 'taskCreateOrUpdate' is not null or undefined if (taskCreateOrUpdate === null || taskCreateOrUpdate === undefined) { throw new Error('Required parameter taskCreateOrUpdate was null or undefined when calling createTask.'); } 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(taskCreateOrUpdate, "TaskCreateOrUpdate"), }; 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, "Task"); 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())); } })); }); }); } /** * Allows you to create a specific task * @summary Creates a time entry for a specific project * @param xeroTenantId Xero identifier for Tenant * @param projectId You can specify an individual project by appending the projectId to the endpoint * @param timeEntryCreateOrUpdate The time entry object you are creating * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createTimeEntry(xeroTenantId_1, projectId_1, timeEntryCreateOrUpdate_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, projectId, timeEntryCreateOrUpdate, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Projects/{projectId}/Time' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); 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 createTimeEntry.'); } // verify required parameter 'projectId' is not null or undefined if (projectId === null || projectId === undefined) { throw new Error('Required parameter projectId was null or undefined when calling createTimeEntry.'); } // verify required parameter 'timeEntryCreateOrUpdate' is not null or undefined if (timeEntryCreateOrUpdate === null || timeEntryCreateOrUpdate === undefined) { throw new Error('Required parameter timeEntryCreateOrUpdate was null or undefined when calling createTimeEntry.'); } 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(timeEntryCreateOrUpdate, "TimeEntryCreateOrUpdate"), }; 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, "TimeEntry"); 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())); } })); }); }); } /** * Allows you to delete a specific task * @summary Allows you to delete a task * @param xeroTenantId Xero identifier for Tenant * @param projectId You can specify an individual project by appending the projectId to the endpoint * @param taskId You can specify an individual task by appending the id to the endpoint */ deleteTask(xeroTenantId_1, projectId_1, taskId_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, projectId, taskId, options = { headers: {} }) { const localVarPath = this.basePath + '/Projects/{projectId}/Tasks/{taskId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))) .replace('{' + 'taskId' + '}', encodeURIComponent(String(taskId))); 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 deleteTask.'); } // verify required parameter 'projectId' is not null or undefined if (projectId === null || projectId === undefined) { throw new Error('Required parameter projectId was null or undefined when calling deleteTask.'); } // verify required parameter 'taskId' is not null or undefined if (taskId === null || taskId === undefined) { throw new Error('Required parameter taskId was null or undefined when calling deleteTask.'); } 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())); } })); }); }); } /** * Allows you to delete a specific time entry * @summary Deletes a time entry for a specific project * @param xeroTenantId Xero identifier for Tenant * @param projectId You can specify an individual project by appending the projectId to the endpoint * @param timeEntryId You can specify an individual task by appending the id to the endpoint */ deleteTimeEntry(xeroTenantId_1, projectId_1, timeEntryId_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, projectId, timeEntryId, options = { headers: {} }) { const localVarPath = this.basePath + '/Projects/{projectId}/Time/{timeEntryId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))) .replace('{' + 'timeEntryId' + '}', encodeURIComponent(String(timeEntryId))); 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 deleteTimeEntry.'); } // verify required parameter 'projectId' is not null or undefined if (projectId === null || projectId === undefined) { throw new Error('Required parameter projectId was null or undefined when calling deleteTimeEntry.'); } // verify required parameter 'timeEntryId' is not null or undefined if (timeEntryId === null || timeEntryId === undefined) { throw new Error('Required parameter timeEntryId was null or undefined when calling deleteTimeEntry.'); } 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())); } })); }); }); } /** * Allows you to retrieve a specific project using the projectId * @summary Retrieves a single project * @param xeroTenantId Xero identifier for Tenant * @param projectId You can specify an individual project by appending the projectId to the endpoint */ getProject(xeroTenantId_1, projectId_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, projectId, options = { headers: {} }) { const localVarPath = this.basePath + '/Projects/{projectId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); 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 getProject.'); } // verify required parameter 'projectId' is not null or undefined if (projectId === null || projectId === undefined) { throw new Error('Required parameter projectId was null or undefined when calling getProject.'); } 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, "Project"); 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())); } })); }); }); } /** * Allows you to retrieve the users on a projects. * @summary Retrieves a list of all project users * @param xeroTenantId Xero identifier for Tenant * @param page set to 1 by default. The requested number of the page in paged response - Must be a number greater than 0. * @param pageSize Optional, it is set to 50 by default. The number of items to return per page in a paged response - Must be a number between 1 and 500. */ getProjectUsers(xeroTenantId_1, page_1, pageSize_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, page, pageSize, options = { headers: {} }) { const localVarPath = this.basePath + '/ProjectsUsers'; 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 getProjectUsers.'); } if (page !== undefined) { localVarQueryParameters['page'] = models_1.ObjectSerializer.serialize(page, "number"); } if (pageSize !== undefined) { localVarQueryParameters['pageSize'] = models_1.ObjectSerializer.serialize(pageSize, "number"); } 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, "ProjectUsers"); 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())); } })); }); }); } /** * Allows you to retrieve, create and update projects. * @summary Retrieves all projects * @param xeroTenantId Xero identifier for Tenant * @param projectIds Search for all projects that match a comma separated list of projectIds * @param contactID Filter for projects for a specific contact * @param states Filter for projects in a particular state (INPROGRESS or CLOSED) * @param page set to 1 by default. The requested number of the page in paged response - Must be a number greater than 0. * @param pageSize Optional, it is set to 50 by default. The number of items to return per page in a paged response - Must be a number between 1 and 500. */ getProjects(xeroTenantId_1, projectIds_1, contactID_1, states_1, page_1, pageSize_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, projectIds, contactID, states, page, pageSize, options = { headers: {} }) { const localVarPath = this.basePath + '/Projects'; 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 getProjects.'); } if (projectIds !== undefined) { localVarQueryParameters['projectIds'] = models_1.ObjectSerializer.serialize(projectIds, "Array<string>"); } if (contactID !== undefined) { localVarQueryParameters['contactID'] = models_1.ObjectSerializer.serialize(contactID, "string"); } if (states !== undefined) { localVarQueryParameters['states'] = models_1.ObjectSerializer.serialize(states, "string"); } if (page !== undefined) { localVarQueryParameters['page'] = models_1.ObjectSerializer.serialize(page, "number"); } if (pageSize !== undefined) { localVarQueryParameters['pageSize'] = models_1.ObjectSerializer.serialize(pageSize, "number"); } 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, "Projects"); 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())); } })); }); }); } /** * Allows you to retrieve a specific project * @summary Retrieves a single project task * @param xeroTenantId Xero identifier for Tenant * @param projectId You can specify an individual project by appending the projectId to the endpoint * @param taskId You can specify an individual task by appending the taskId to the endpoint, i.e. GET https://.../tasks/{taskID} */ getTask(xeroTenantId_1, projectId_1, taskId_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, projectId, taskId, options = { headers: {} }) { const localVarPath = this.basePath + '/Projects/{projectId}/Tasks/{taskId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))) .replace('{' + 'taskId' + '}', encodeURIComponent(String(taskId))); 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 getTask.'); } // verify required parameter 'projectId' is not null or undefined if (projectId === null || projectId === undefined) { throw new Error('Required parameter projectId was null or undefined when calling getTask.'); } // verify required parameter 'taskId' is not null or undefined if (taskId === null || taskId === undefined) { throw new Error('Required parameter taskId was null or undefined when calling getTask.'); } 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, "Task"); 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())); } })); }); }); } /** * Allows you to retrieve a specific project * @summary Retrieves all project tasks * @param xeroTenantId Xero identifier for Tenant * @param projectId You can specify an individual project by appending the projectId to the endpoint * @param page Set to 1 by default. The requested number of the page in paged response - Must be a number greater than 0. * @param pageSize Optional, it is set to 50 by default. The number of items to return per page in a paged response - Must be a number between 1 and 500. * @param taskIds Search for all tasks that match a comma separated list of taskIds, i.e. GET https://.../tasks?taskIds&#x3D;{taskID},{taskID} * @param chargeType */ getTasks(xeroTenantId_1, projectId_1, page_1, pageSize_1, taskIds_1, chargeType_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, projectId, page, pageSize, taskIds, chargeType, options = { headers: {} }) { const localVarPath = this.basePath + '/Projects/{projectId}/Tasks' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); 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 getTasks.'); } // verify required parameter 'projectId' is not null or undefined if (projectId === null || projectId === undefined) { throw new Error('Required parameter projectId was null or undefined when calling getTasks.'); } if (page !== undefined) { localVarQueryParameters['page'] = models_1.ObjectSerializer.serialize(page, "number"); } if (pageSize !== undefined) { localVarQueryParameters['pageSize'] = models_1.ObjectSerializer.serialize(pageSize, "number"); } if (taskIds !== undefined) { localVarQueryParameters['taskIds'] = models_1.ObjectSerializer.serialize(taskIds, "string"); } if (chargeType !== undefined) { localVarQueryParameters['chargeType'] = models_1.ObjectSerializer.serialize(chargeType, "ChargeType"); } 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)); authenticationPromis