UNPKG

xero-node

Version:

Xero NodeJS OAuth 2.0 client for xero-node

841 lines 150 kB
"use strict"; /** * Xero Payroll AU API * This is the Xero Payroll API for orgs in Australia region. * * 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.PayrollAuApi = exports.PayrollAuApiApiKeys = void 0; const models_1 = require("../model/payroll-au/models"); const ApiError_1 = require("../../model/ApiError"); const axios_1 = __importDefault(require("axios")); const models_2 = require("../model/payroll-au/models"); let defaultBasePath = 'https://api.xero.com/payroll.xro/1.0'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== var PayrollAuApiApiKeys; (function (PayrollAuApiApiKeys) { })(PayrollAuApiApiKeys || (exports.PayrollAuApiApiKeys = PayrollAuApiApiKeys = {})); class PayrollAuApi { 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[PayrollAuApiApiKeys[key]].apiKey = value; } set accessToken(token) { this.authentications.OAuth2.accessToken = token; } /** * * @summary Approve a requested leave application by a unique leave application id * @param xeroTenantId Xero identifier for Tenant * @param leaveApplicationID Leave Application id for single object * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ approveLeaveApplication(xeroTenantId_1, leaveApplicationID_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, leaveApplicationID, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/LeaveApplications/{LeaveApplicationID}/approve' .replace('{' + 'LeaveApplicationID' + '}', encodeURIComponent(String(leaveApplicationID))); 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 approveLeaveApplication.'); } // verify required parameter 'leaveApplicationID' is not null or undefined if (leaveApplicationID === null || leaveApplicationID === undefined) { throw new Error('Required parameter leaveApplicationID was null or undefined when calling approveLeaveApplication.'); } 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: {}, }; 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, "LeaveApplications"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * * @summary Creates a payroll employee * @param xeroTenantId Xero identifier for Tenant * @param employee * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createEmployee(xeroTenantId_1, employee_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, employee, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Employees'; 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 createEmployee.'); } // verify required parameter 'employee' is not null or undefined if (employee === null || employee === undefined) { throw new Error('Required parameter employee was null or undefined when calling createEmployee.'); } 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(employee, "Array<Employee>"), }; 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, "Employees"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * * @summary Creates a leave application * @param xeroTenantId Xero identifier for Tenant * @param leaveApplication * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createLeaveApplication(xeroTenantId_1, leaveApplication_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, leaveApplication, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/LeaveApplications'; 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 createLeaveApplication.'); } // verify required parameter 'leaveApplication' is not null or undefined if (leaveApplication === null || leaveApplication === undefined) { throw new Error('Required parameter leaveApplication was null or undefined when calling createLeaveApplication.'); } 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(leaveApplication, "Array<LeaveApplication>"), }; 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, "LeaveApplications"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * * @summary Creates a pay item * @param xeroTenantId Xero identifier for Tenant * @param payItem * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createPayItem(xeroTenantId_1, payItem_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, payItem, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/PayItems'; 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 createPayItem.'); } // verify required parameter 'payItem' is not null or undefined if (payItem === null || payItem === undefined) { throw new Error('Required parameter payItem was null or undefined when calling createPayItem.'); } 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(payItem, "PayItem"), }; 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, "PayItems"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * * @summary Creates a pay run * @param xeroTenantId Xero identifier for Tenant * @param payRun * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createPayRun(xeroTenantId_1, payRun_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, payRun, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/PayRuns'; 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 createPayRun.'); } // verify required parameter 'payRun' is not null or undefined if (payRun === null || payRun === undefined) { throw new Error('Required parameter payRun was null or undefined when calling createPayRun.'); } 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(payRun, "Array<PayRun>"), }; 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, "PayRuns"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * * @summary Creates a Payroll Calendar * @param xeroTenantId Xero identifier for Tenant * @param payrollCalendar * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createPayrollCalendar(xeroTenantId_1, payrollCalendar_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, payrollCalendar, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/PayrollCalendars'; 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 createPayrollCalendar.'); } // verify required parameter 'payrollCalendar' is not null or undefined if (payrollCalendar === null || payrollCalendar === undefined) { throw new Error('Required parameter payrollCalendar was null or undefined when calling createPayrollCalendar.'); } 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(payrollCalendar, "Array<PayrollCalendar>"), }; 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, "PayrollCalendars"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * * @summary Creates a superfund * @param xeroTenantId Xero identifier for Tenant * @param superFund * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createSuperfund(xeroTenantId_1, superFund_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, superFund, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Superfunds'; 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 createSuperfund.'); } // verify required parameter 'superFund' is not null or undefined if (superFund === null || superFund === undefined) { throw new Error('Required parameter superFund was null or undefined when calling createSuperfund.'); } 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(superFund, "Array<SuperFund>"), }; 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, "SuperFunds"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * * @summary Creates a timesheet * @param xeroTenantId Xero identifier for Tenant * @param timesheet * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createTimesheet(xeroTenantId_1, timesheet_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, timesheet, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Timesheets'; 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 createTimesheet.'); } // verify required parameter 'timesheet' is not null or undefined if (timesheet === null || timesheet === undefined) { throw new Error('Required parameter timesheet was null or undefined when calling createTimesheet.'); } 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(timesheet, "Array<Timesheet>"), }; 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, "Timesheets"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * * @summary Retrieves an employee\'s detail by unique employee id * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ getEmployee(xeroTenantId_1, employeeID_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, employeeID, options = { headers: {} }) { const localVarPath = this.basePath + '/Employees/{EmployeeID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); 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 getEmployee.'); } // verify required parameter 'employeeID' is not null or undefined if (employeeID === null || employeeID === undefined) { throw new Error('Required parameter employeeID was null or undefined when calling getEmployee.'); } 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, "Employees"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * * @summary Searches payroll employees * @param xeroTenantId Xero identifier for Tenant * @param ifModifiedSince Only records created or modified since this timestamp will be returned * @param where Filter by an any element * @param order Order by an any element * @param page e.g. page&#x3D;1 – Up to 100 employees will be returned in a single API call */ getEmployees(xeroTenantId_1, ifModifiedSince_1, where_1, order_1, page_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, ifModifiedSince, where, order, page, options = { headers: {} }) { const localVarPath = this.basePath + '/Employees'; 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 getEmployees.'); } if (where !== undefined) { localVarQueryParameters['where'] = models_1.ObjectSerializer.serialize(where, "string"); } if (order !== undefined) { localVarQueryParameters['order'] = models_1.ObjectSerializer.serialize(order, "string"); } if (page !== undefined) { localVarQueryParameters['page'] = models_1.ObjectSerializer.serialize(page, "number"); } localVarHeaderParams['Xero-Tenant-Id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); localVarHeaderParams['If-Modified-Since'] = models_1.ObjectSerializer.serialize(ifModifiedSince, "Date"); 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, "Employees"); if (response.status && response.status >= 200 && response.status <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } catch (error) { const errorResponse = new ApiError_1.ApiError(error); reject(JSON.stringify(errorResponse.generateError())); } })); }); }); } /** * * @summary Retrieves a leave application by a unique leave application id * @param xeroTenantId Xero identifier for Tenant * @param leaveApplicationID Leave Application id for single object */ getLeaveApplication(xeroTenantId_1, leaveApplicationID_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, leaveApplicationID, options = { headers: {} }) { const localVarPath = this.basePath + '/LeaveApplications/{LeaveApplicationID}' .replace('{' + 'LeaveApplicationID' + '}', encodeURIComponent(String(leaveApplicationID))); 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 getLeaveApplication.'); } // verify required parameter 'leaveApplicationID' is not null or undefined if (leaveApplicationID === null || leaveApplicationID === undefined) { throw new Error('Required parameter leaveApplicationID was null or undefined when calling getLeaveApplication.'); } localVarHeaderParams['Xero-Tenant-Id'] = models_1.ObjectSerializer.serialize(xeroTenantId, "string"); loc