UNPKG

xero-node

Version:

Xero NodeJS OAuth 2.0 client for xero-node

902 lines 56 kB
"use strict"; /** * Xero Projects API * This is the Xero Projects 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.ProjectApi = exports.ProjectApiApiKeys = void 0; const localVarRequest = require("request"); const models_1 = require("../model/projects/models"); 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 || (exports.ProjectApiApiKeys = {})); class ProjectApi { 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[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 */ createProject(xeroTenantId, projectCreateOrUpdate, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/Projects'; 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 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"); 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(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.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, "Project"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * 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 */ createTimeEntry(xeroTenantId, projectId, timeEntryCreateOrUpdate, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/Projects/{projectId}/Time' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); 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 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"); 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(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.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, "TimeEntry"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * 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, projectId, timeEntryId, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { 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 = {}; // 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"); 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 }); } } }); }); }); }); } /** * 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, projectId, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/Projects/{projectId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); 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 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"); 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, "Project"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * 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, page, pageSize, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/ProjectsUsers'; 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 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"); 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, "ProjectUsers"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * 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, projectIds, contactID, states, page, pageSize, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/Projects'; 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 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"); 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, "Projects"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * 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, projectId, taskId, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { 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 = {}; // 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"); 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, "Task"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * 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 taskIdsSearch for all tasks that match a comma separated list of taskIds, i.e. GET https://.../tasks?taskIds&#x3D;{taskID},{taskID} * @param chargeType */ getTasks(xeroTenantId, projectId, page, pageSize, taskIds, chargeType, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/Projects/{projectId}/Tasks' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); 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 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"); 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, "Tasks"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * Allows you to retrieve the time entries associated with a specific project * @summary Retrieves all time entries associated with a specific project * @param xeroTenantId Xero identifier for Tenant * @param projectId Identifier of the project, that the task (which the time entry is logged against) belongs to. * @param userId The xero user identifier of the person who logged time. * @param taskId Identifier of the task that time entry is logged against. * @param invoiceId Finds all time entries for this invoice. * @param contactId Finds all time entries for this contact identifier. * @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 states Comma-separated list of states to find. Will find all time entries that are in the status of whatever is specified. * @param isChargeable Finds all time entries which relate to tasks with the charge type &#x60;TIME&#x60; or &#x60;FIXED&#x60;. * @param dateAfterUtc ISO 8601 UTC date. Finds all time entries on or after this date filtered on the &#x60;dateUtc&#x60; field. * @param dateBeforeUtc ISO 8601 UTC date. Finds all time entries on or before this date filtered on the &#x60;dateUtc&#x60; field. */ getTimeEntries(xeroTenantId, projectId, userId, taskId, invoiceId, contactId, page, pageSize, states, isChargeable, dateAfterUtc, dateBeforeUtc, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/Projects/{projectId}/Time' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); 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 getTimeEntries.'); } // 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 getTimeEntries.'); } if (userId !== undefined) { localVarQueryParameters['userId'] = models_1.ObjectSerializer.serialize(userId, "string"); } if (taskId !== undefined) { localVarQueryParameters['taskId'] = models_1.ObjectSerializer.serialize(taskId, "string"); } if (invoiceId !== undefined) { localVarQueryParameters['invoiceId'] = models_1.ObjectSerializer.serialize(invoiceId, "string"); } if (contactId !== undefined) { localVarQueryParameters['contactId'] = models_1.ObjectSerializer.serialize(contactId, "string"); } if (page !== undefined) { localVarQueryParameters['page'] = models_1.ObjectSerializer.serialize(page, "number"); } if (pageSize !== undefined) { localVarQueryParameters['pageSize'] = models_1.ObjectSerializer.serialize(pageSize, "number"); } if (states !== undefined) { localVarQueryParameters['states'] = models_1.ObjectSerializer.serialize(states, "Array<string>"); } if (isChargeable !== undefined) { localVarQueryParameters['isChargeable'] = models_1.ObjectSerializer.serialize(isChargeable, "boolean"); } if (dateAfterUtc !== undefined) { localVarQueryParameters['dateAfterUtc'] = models_1.ObjectSerializer.serialize(dateAfterUtc, "Date"); } if (dateBeforeUtc !== undefined) { localVarQueryParameters['dateBeforeUtc'] = models_1.ObjectSerializer.serialize(dateBeforeUtc, "Date"); } 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, "TimeEntries"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * Allows you to get a single time entry in a project * @summary Retrieves a single 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 time entry by appending the id to the endpoint */ getTimeEntry(xeroTenantId, projectId, timeEntryId, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { 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 = {}; // 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 getTimeEntry.'); } // 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 getTimeEntry.'); } // 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 getTimeEntry.'); } 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, "TimeEntry"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); }); } /** * Allows you to update a specific projects. * @summary creates a project for the specified contact * @param xeroTenantId Xero identifier for Tenant * @param projectId You can specify an individual project by appending the projectId to the endpoint * @param projectPatch Update the status of an existing Project */ patchProject(xeroTenantId, projectId, projectPatch, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/Projects/{projectId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); 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 patchProject.'); } // 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 patchProject.'); } // verify required parameter 'projectPatch' is not null or undefined if (projectPatch === null || projectPatch === undefined) { throw new Error('Required parameter projectPatch was null or undefined when calling patchProject.'); } localVarHeaderParams['Xero-Tenant-Id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); Object.assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions = { method: 'PATCH', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: models_1.ObjectSerializer.serialize(projectPatch, "ProjectPatch") }; 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 }); } } }); }); }); }); } /** * Allows you to update a specific projects. * @summary Updates 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 projectCreateOrUpdate Request of type ProjectCreateOrUpdate */ updateProject(xeroTenantId, projectId, projectCreateOrUpdate, options = { headers: {} }) { return __awaiter(this, void 0, void 0, function* () { const localVarPath = this.basePath + '/Projects/{projectId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); 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 updateProject.'); } // 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 updateProject.'); } // 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 updateProject.'); } 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.ObjectSerializ