UNPKG

xero-node

Version:

Xero NodeJS OAuth 2.0 client for xero-node

815 lines 332 kB
"use strict"; /** * Xero Payroll NZ * This is the Xero Payroll API for orgs in the NZ 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.PayrollNzApi = exports.PayrollNzApiApiKeys = void 0; const models_1 = require("../model/payroll-nz/models"); const ApiError_1 = require("../../model/ApiError"); const axios_1 = __importDefault(require("axios")); const models_2 = require("../model/payroll-nz/models"); let defaultBasePath = 'https://api.xero.com/payroll.xro/2.0'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== var PayrollNzApiApiKeys; (function (PayrollNzApiApiKeys) { })(PayrollNzApiApiKeys || (exports.PayrollNzApiApiKeys = PayrollNzApiApiKeys = {})); class PayrollNzApi { 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[PayrollNzApiApiKeys[key]].apiKey = value; } set accessToken(token) { this.authentications.OAuth2.accessToken = token; } /** * * @summary Approves a timesheet * @param xeroTenantId Xero identifier for Tenant * @param timesheetID Identifier for the timesheet * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ approveTimesheet(xeroTenantId_1, timesheetID_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, timesheetID, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}/Approve' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); 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 approveTimesheet.'); } // verify required parameter 'timesheetID' is not null or undefined if (timesheetID === null || timesheetID === undefined) { throw new Error('Required parameter timesheetID was null or undefined when calling approveTimesheet.'); } 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, "TimesheetObject"); 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 new deduction for a specific employee * @param xeroTenantId Xero identifier for Tenant * @param deduction * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createDeduction(xeroTenantId_1, deduction_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, deduction, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Deductions'; 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 createDeduction.'); } // verify required parameter 'deduction' is not null or undefined if (deduction === null || deduction === undefined) { throw new Error('Required parameter deduction was null or undefined when calling createDeduction.'); } 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(deduction, "Deduction"), }; 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, "DeductionObject"); 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 new earnings rate * @param xeroTenantId Xero identifier for Tenant * @param earningsRate * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createEarningsRate(xeroTenantId_1, earningsRate_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, earningsRate, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/EarningsRates'; 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 createEarningsRate.'); } // verify required parameter 'earningsRate' is not null or undefined if (earningsRate === null || earningsRate === undefined) { throw new Error('Required parameter earningsRate was null or undefined when calling createEarningsRate.'); } 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(earningsRate, "EarningsRate"), }; 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, "EarningsRateObject"); 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 an employees * @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, "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, "EmployeeObject"); 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 earnings template records for an employee * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object * @param earningsTemplate * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createEmployeeEarningsTemplate(xeroTenantId_1, employeeID_1, earningsTemplate_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, employeeID, earningsTemplate, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PayTemplates/Earnings' .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 createEmployeeEarningsTemplate.'); } // 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 createEmployeeEarningsTemplate.'); } // verify required parameter 'earningsTemplate' is not null or undefined if (earningsTemplate === null || earningsTemplate === undefined) { throw new Error('Required parameter earningsTemplate was null or undefined when calling createEmployeeEarningsTemplate.'); } 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(earningsTemplate, "EarningsTemplate"), }; 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, "EarningsTemplateObject"); 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 leave records for a specific employee * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object * @param employeeLeave * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createEmployeeLeave(xeroTenantId_1, employeeID_1, employeeLeave_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, employeeID, employeeLeave, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Leave' .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 createEmployeeLeave.'); } // 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 createEmployeeLeave.'); } // verify required parameter 'employeeLeave' is not null or undefined if (employeeLeave === null || employeeLeave === undefined) { throw new Error('Required parameter employeeLeave was null or undefined when calling createEmployeeLeave.'); } 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(employeeLeave, "EmployeeLeave"), }; 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, "EmployeeLeaveObject"); 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 set-up for a specific employee. This is required before viewing, configuring and requesting leave for an employee * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object * @param employeeLeaveSetup * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createEmployeeLeaveSetup(xeroTenantId_1, employeeID_1, employeeLeaveSetup_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, employeeID, employeeLeaveSetup, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Employees/{EmployeeID}/LeaveSetup' .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 createEmployeeLeaveSetup.'); } // 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 createEmployeeLeaveSetup.'); } // verify required parameter 'employeeLeaveSetup' is not null or undefined if (employeeLeaveSetup === null || employeeLeaveSetup === undefined) { throw new Error('Required parameter employeeLeaveSetup was null or undefined when calling createEmployeeLeaveSetup.'); } 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(employeeLeaveSetup, "EmployeeLeaveSetup"), }; 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, "EmployeeLeaveSetupObject"); 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 leave type records for a specific employee * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object * @param employeeLeaveType * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createEmployeeLeaveType(xeroTenantId_1, employeeID_1, employeeLeaveType_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, employeeID, employeeLeaveType, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Employees/{EmployeeID}/LeaveTypes' .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 createEmployeeLeaveType.'); } // 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 createEmployeeLeaveType.'); } // verify required parameter 'employeeLeaveType' is not null or undefined if (employeeLeaveType === null || employeeLeaveType === undefined) { throw new Error('Required parameter employeeLeaveType was null or undefined when calling createEmployeeLeaveType.'); } 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(employeeLeaveType, "EmployeeLeaveType"), }; 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, "EmployeeLeaveTypeObject"); 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 opening balances for a specific employee * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object * @param employeeOpeningBalance * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createEmployeeOpeningBalances(xeroTenantId_1, employeeID_1, employeeOpeningBalance_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, employeeID, employeeOpeningBalance, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Employees/{EmployeeID}/OpeningBalances' .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 createEmployeeOpeningBalances.'); } // 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 createEmployeeOpeningBalances.'); } // verify required parameter 'employeeOpeningBalance' is not null or undefined if (employeeOpeningBalance === null || employeeOpeningBalance === undefined) { throw new Error('Required parameter employeeOpeningBalance was null or undefined when calling createEmployeeOpeningBalances.'); } 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(employeeOpeningBalance, "Array<EmployeeOpeningBalance>"), }; 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, "EmployeeOpeningBalancesObject"); 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 payment method for an employee * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object * @param paymentMethod * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ createEmployeePaymentMethod(xeroTenantId_1, employeeID_1, paymentMethod_1, idempotencyKey_1) { return __awaiter(this, arguments, void 0, function* (xeroTenantId, employeeID, paymentMethod, idempotencyKey, options = { headers: {} }) { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PaymentMethods' .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 createEmployeePaymentMethod.'); } // 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 createEmployeePaymentMethod.'); } // verify required parameter 'paymentMethod' is not null or undefined if (paymentMethod === null || paymentMethod === undefined) { throw new Error('Required parameter paymentMethod was null or undefined when calling createEmployeePaymentMethod.'); } 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(paymentMethod, "PaymentMethod"), }; 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 (