xero-node
Version:
Xero NodeJS OAuth 2.0 client for xero-node
944 lines (943 loc) • 252 kB
JavaScript
"use strict";
/**
* Xero Payroll UK
* This is the Xero Payroll API for orgs in the UK region.
*
* 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.PayrollUkApi = exports.PayrollUkApiApiKeys = void 0;
const localVarRequest = require("request");
const models_1 = require("../model/payroll-uk/models");
const models_2 = require("../model/payroll-uk/models");
let defaultBasePath = 'https://api.xero.com/payroll.xro/2.0';
// ===============================================
// This file is autogenerated - Please do not edit
// ===============================================
var PayrollUkApiApiKeys;
(function (PayrollUkApiApiKeys) {
})(PayrollUkApiApiKeys = exports.PayrollUkApiApiKeys || (exports.PayrollUkApiApiKeys = {}));
class PayrollUkApi {
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[PayrollUkApiApiKeys[key]].apiKey = value;
}
set accessToken(token) {
this.authentications.OAuth2.accessToken = token;
}
/**
*
* @summary Approves a specific timesheet
* @param xeroTenantId Xero identifier for Tenant
* @param timesheetID Identifier for the timesheet
*/
approveTimesheet(xeroTenantId, timesheetID, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Timesheets/{TimesheetID}/Approve'
.replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID)));
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 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");
Object.assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions = {
method: 'POST',
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, "TimesheetObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates a new employee benefit
* @param xeroTenantId Xero identifier for Tenant
* @param benefit
*/
createBenefit(xeroTenantId, benefit, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Benefits';
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 createBenefit.');
}
// verify required parameter 'benefit' is not null or undefined
if (benefit === null || benefit === undefined) {
throw new Error('Required parameter benefit was null or undefined when calling createBenefit.');
}
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(benefit, "Benefit")
};
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, "BenefitObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates a new deduction
* @param xeroTenantId Xero identifier for Tenant
* @param deduction
*/
createDeduction(xeroTenantId, deduction, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Deductions';
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 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");
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(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.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, "DeductionObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates a new earnings rate
* @param xeroTenantId Xero identifier for Tenant
* @param earningsRate
*/
createEarningsRate(xeroTenantId, earningsRate, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/EarningsRates';
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 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");
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(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.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, "EarningsRateObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates employees
* @param xeroTenantId Xero identifier for Tenant
* @param employee
*/
createEmployee(xeroTenantId, employee, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Employees';
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 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");
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(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.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, "EmployeeObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates an earnings template records for a specific employee
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param earningsTemplate
*/
createEmployeeEarningsTemplate(xeroTenantId, employeeID, earningsTemplate, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Employees/{EmployeeID}/PayTemplates/earnings'
.replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID)));
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 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");
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(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.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, "EarningsTemplateObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates leave records for a specific employee
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param employeeLeave
*/
createEmployeeLeave(xeroTenantId, employeeID, employeeLeave, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Employees/{EmployeeID}/Leave'
.replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID)));
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 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");
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(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.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, "EmployeeLeaveObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates employee leave type records
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param employeeLeaveType
*/
createEmployeeLeaveType(xeroTenantId, employeeID, employeeLeaveType, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Employees/{EmployeeID}/LeaveTypes'
.replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID)));
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 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");
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(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.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, "EmployeeLeaveTypeObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates an opening balance for a specific employee
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param employeeOpeningBalances
*/
createEmployeeOpeningBalances(xeroTenantId, employeeID, employeeOpeningBalances, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Employees/{EmployeeID}/ukopeningbalances'
.replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID)));
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 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 'employeeOpeningBalances' is not null or undefined
if (employeeOpeningBalances === null || employeeOpeningBalances === undefined) {
throw new Error('Required parameter employeeOpeningBalances was null or undefined when calling createEmployeeOpeningBalances.');
}
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(employeeOpeningBalances, "EmployeeOpeningBalances")
};
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, "EmployeeOpeningBalancesObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates an employee payment method
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param paymentMethod
*/
createEmployeePaymentMethod(xeroTenantId, employeeID, paymentMethod, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Employees/{EmployeeID}/PaymentMethods'
.replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID)));
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 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");
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(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 (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, "PaymentMethodObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates a salary and wage record for a specific employee
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param salaryAndWage
*/
createEmployeeSalaryAndWage(xeroTenantId, employeeID, salaryAndWage, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Employees/{EmployeeID}/SalaryAndWages'
.replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID)));
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 createEmployeeSalaryAndWage.');
}
// 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 createEmployeeSalaryAndWage.');
}
// verify required parameter 'salaryAndWage' is not null or undefined
if (salaryAndWage === null || salaryAndWage === undefined) {
throw new Error('Required parameter salaryAndWage was null or undefined when calling createEmployeeSalaryAndWage.');
}
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(salaryAndWage, "SalaryAndWage")
};
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, "SalaryAndWageObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates statutory sick leave records
* @param xeroTenantId Xero identifier for Tenant
* @param employeeStatutorySickLeave
*/
createEmployeeStatutorySickLeave(xeroTenantId, employeeStatutorySickLeave, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/StatutoryLeaves/Sick';
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 createEmployeeStatutorySickLeave.');
}
// verify required parameter 'employeeStatutorySickLeave' is not null or undefined
if (employeeStatutorySickLeave === null || employeeStatutorySickLeave === undefined) {
throw new Error('Required parameter employeeStatutorySickLeave was null or undefined when calling createEmployeeStatutorySickLeave.');
}
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(employeeStatutorySickLeave, "EmployeeStatutorySickLeave")
};
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, "EmployeeStatutorySickLeaveObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates employment detail for a specific employee using a unique employee ID
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param employment
*/
createEmployment(xeroTenantId, employeeID, employment, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/Employees/{EmployeeID}/Employment'
.replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID)));
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 createEmployment.');
}
// 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 createEmployment.');
}
// verify required parameter 'employment' is not null or undefined
if (employment === null || employment === undefined) {
throw new Error('Required parameter employment was null or undefined when calling createEmployment.');
}
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(employment, "Employment")
};
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, "EmploymentObject");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
}
else {
reject({ response: response, body: body });
}
}
});
});
});
});
}
/**
*
* @summary Creates a new leave type
* @param xeroTenantId Xero identifier for Tenant
* @param leaveType
*/
createLeaveType(xeroTenantId, leaveType, options = { headers: {} }) {
return __awaiter(this, void 0, void 0, function* () {
const localVarPath = this.basePath + '/LeaveTypes';
let localVarQueryParameters = {};