
com.xero.api.client.PayrollUkApi Maven / Gradle / Ivy
/*
* Xero Payroll UK
* This is the Xero Payroll API for orgs in the UK region.
*
* The version of the OpenAPI document: 6.3.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.xero.api.client;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.api.client.auth.oauth2.BearerToken;
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpContent;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpMethods;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpResponseException;
import com.google.api.client.http.HttpTransport;
import com.xero.api.ApiClient;
import com.xero.api.XeroApiExceptionHandler;
import com.xero.models.payrolluk.Benefit;
import com.xero.models.payrolluk.BenefitObject;
import com.xero.models.payrolluk.Benefits;
import com.xero.models.payrolluk.Deduction;
import com.xero.models.payrolluk.DeductionObject;
import com.xero.models.payrolluk.Deductions;
import com.xero.models.payrolluk.EarningsOrderObject;
import com.xero.models.payrolluk.EarningsOrders;
import com.xero.models.payrolluk.EarningsRate;
import com.xero.models.payrolluk.EarningsRateObject;
import com.xero.models.payrolluk.EarningsRates;
import com.xero.models.payrolluk.EarningsTemplate;
import com.xero.models.payrolluk.EarningsTemplateObject;
import com.xero.models.payrolluk.Employee;
import com.xero.models.payrolluk.EmployeeLeave;
import com.xero.models.payrolluk.EmployeeLeaveBalances;
import com.xero.models.payrolluk.EmployeeLeaveObject;
import com.xero.models.payrolluk.EmployeeLeaveType;
import com.xero.models.payrolluk.EmployeeLeaveTypeObject;
import com.xero.models.payrolluk.EmployeeLeaveTypes;
import com.xero.models.payrolluk.EmployeeLeaves;
import com.xero.models.payrolluk.EmployeeObject;
import com.xero.models.payrolluk.EmployeeOpeningBalances;
import com.xero.models.payrolluk.EmployeeOpeningBalancesObject;
import com.xero.models.payrolluk.EmployeePayTemplateObject;
import com.xero.models.payrolluk.EmployeePayTemplates;
import com.xero.models.payrolluk.EmployeeStatutoryLeaveBalanceObject;
import com.xero.models.payrolluk.EmployeeStatutoryLeavesSummaries;
import com.xero.models.payrolluk.EmployeeStatutorySickLeave;
import com.xero.models.payrolluk.EmployeeStatutorySickLeaveObject;
import com.xero.models.payrolluk.EmployeeTaxObject;
import com.xero.models.payrolluk.Employees;
import com.xero.models.payrolluk.Employment;
import com.xero.models.payrolluk.EmploymentObject;
import com.xero.models.payrolluk.LeavePeriods;
import com.xero.models.payrolluk.LeaveType;
import com.xero.models.payrolluk.LeaveTypeObject;
import com.xero.models.payrolluk.LeaveTypes;
import com.xero.models.payrolluk.PayRun;
import com.xero.models.payrolluk.PayRunCalendar;
import com.xero.models.payrolluk.PayRunCalendarObject;
import com.xero.models.payrolluk.PayRunCalendars;
import com.xero.models.payrolluk.PayRunObject;
import com.xero.models.payrolluk.PayRuns;
import com.xero.models.payrolluk.PaymentMethod;
import com.xero.models.payrolluk.PaymentMethodObject;
import com.xero.models.payrolluk.PayslipObject;
import com.xero.models.payrolluk.Payslips;
import com.xero.models.payrolluk.Reimbursement;
import com.xero.models.payrolluk.ReimbursementObject;
import com.xero.models.payrolluk.Reimbursements;
import com.xero.models.payrolluk.SalaryAndWage;
import com.xero.models.payrolluk.SalaryAndWageObject;
import com.xero.models.payrolluk.SalaryAndWages;
import com.xero.models.payrolluk.Settings;
import com.xero.models.payrolluk.Timesheet;
import com.xero.models.payrolluk.TimesheetLine;
import com.xero.models.payrolluk.TimesheetLineObject;
import com.xero.models.payrolluk.TimesheetObject;
import com.xero.models.payrolluk.Timesheets;
import com.xero.models.payrolluk.TrackingCategories;
import jakarta.ws.rs.core.UriBuilder;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.threeten.bp.LocalDate;
/** PayrollUkApi has methods for interacting with all endpoints in the API set */
public class PayrollUkApi {
private ApiClient apiClient;
private static PayrollUkApi instance = null;
private String userAgent = "Default";
private String version = "8.3.0";
static final Logger logger = LoggerFactory.getLogger(PayrollUkApi.class);
/** PayrollUkApi */
public PayrollUkApi() {
this(new ApiClient());
}
/**
* PayrollUkApi getInstance
*
* @param apiClient ApiClient pass into the new instance of this class
* @return instance of this class
*/
public static PayrollUkApi getInstance(ApiClient apiClient) {
if (instance == null) {
instance = new PayrollUkApi(apiClient);
}
return instance;
}
/**
* PayrollUkApi
*
* @param apiClient ApiClient pass into the new instance of this class
*/
public PayrollUkApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* get ApiClient
*
* @return apiClient the current ApiClient
*/
public ApiClient getApiClient() {
return apiClient;
}
/**
* set ApiClient
*
* @param apiClient ApiClient pass into the new instance of this class
*/
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* set user agent
*
* @param userAgent string to override the user agent
*/
public void setUserAgent(String userAgent) {
this.userAgent = userAgent;
}
/**
* get user agent
*
* @return String of user agent
*/
public String getUserAgent() {
return this.userAgent + " [Xero-Java-" + this.version + "]";
}
/**
* Approves a specific timesheet
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @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.
* @param accessToken Authorization token for user set in header of each request
* @return TimesheetObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public TimesheetObject approveTimesheet(
String accessToken, String xeroTenantId, UUID timesheetID, String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
approveTimesheetForHttpResponse(accessToken, xeroTenantId, timesheetID, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : approveTimesheet -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
TimesheetObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "TimesheetObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Approves a specific timesheet
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @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.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse approveTimesheetForHttpResponse(
String accessToken, String xeroTenantId, UUID timesheetID, String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling approveTimesheet");
} // verify the required parameter 'timesheetID' is set
if (timesheetID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'timesheetID' when calling approveTimesheet");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling approveTimesheet");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("TimesheetID", timesheetID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Timesheets/{TimesheetID}/Approve");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates a new employee benefit
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param benefit The benefit parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return BenefitObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public BenefitObject createBenefit(
String accessToken, String xeroTenantId, Benefit benefit, String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createBenefitForHttpResponse(accessToken, xeroTenantId, benefit, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createBenefit -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
BenefitObject object = apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "BenefitObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates a new employee benefit
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param benefit The benefit parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createBenefitForHttpResponse(
String accessToken, String xeroTenantId, Benefit benefit, String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createBenefit");
} // verify the required parameter 'benefit' is set
if (benefit == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'benefit' when calling createBenefit");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createBenefit");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Benefits");
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(benefit);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates a new deduction
*
*
200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param deduction The deduction parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return DeductionObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public DeductionObject createDeduction(
String accessToken, String xeroTenantId, Deduction deduction, String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createDeductionForHttpResponse(accessToken, xeroTenantId, deduction, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createDeduction -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
DeductionObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "DeductionObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates a new deduction
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param deduction The deduction parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createDeductionForHttpResponse(
String accessToken, String xeroTenantId, Deduction deduction, String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createDeduction");
} // verify the required parameter 'deduction' is set
if (deduction == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'deduction' when calling createDeduction");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createDeduction");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Deductions");
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(deduction);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates a new earnings rate
*
*
200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param earningsRate The earningsRate parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return EarningsRateObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EarningsRateObject createEarningsRate(
String accessToken, String xeroTenantId, EarningsRate earningsRate, String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createEarningsRateForHttpResponse(
accessToken, xeroTenantId, earningsRate, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createEarningsRate -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
EarningsRateObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EarningsRateObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates a new earnings rate
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param earningsRate The earningsRate parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createEarningsRateForHttpResponse(
String accessToken, String xeroTenantId, EarningsRate earningsRate, String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createEarningsRate");
} // verify the required parameter 'earningsRate' is set
if (earningsRate == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'earningsRate' when calling createEarningsRate");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createEarningsRate");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/EarningsRates");
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(earningsRate);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates employees
*
*
200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employee The employee parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return EmployeeObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EmployeeObject createEmployee(
String accessToken, String xeroTenantId, Employee employee, String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createEmployeeForHttpResponse(accessToken, xeroTenantId, employee, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createEmployee -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
EmployeeObject object = apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EmployeeObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates employees
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employee The employee parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createEmployeeForHttpResponse(
String accessToken, String xeroTenantId, Employee employee, String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createEmployee");
} // verify the required parameter 'employee' is set
if (employee == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employee' when calling createEmployee");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createEmployee");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Employees");
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(employee);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates an earnings template records for a specific employee
*
*
200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param earningsTemplate The earningsTemplate parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return EarningsTemplateObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EarningsTemplateObject createEmployeeEarningsTemplate(
String accessToken,
String xeroTenantId,
UUID employeeID,
EarningsTemplate earningsTemplate,
String idempotencyKey)
throws IOException {
try {
TypeReference typeRef =
new TypeReference() {};
HttpResponse response =
createEmployeeEarningsTemplateForHttpResponse(
accessToken, xeroTenantId, employeeID, earningsTemplate, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createEmployeeEarningsTemplate -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
EarningsTemplateObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(
e.getStatusCode(), "EarningsTemplateObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates an earnings template records for a specific employee
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param earningsTemplate The earningsTemplate parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createEmployeeEarningsTemplateForHttpResponse(
String accessToken,
String xeroTenantId,
UUID employeeID,
EarningsTemplate earningsTemplate,
String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling"
+ " createEmployeeEarningsTemplate");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling"
+ " createEmployeeEarningsTemplate");
} // verify the required parameter 'earningsTemplate' is set
if (earningsTemplate == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'earningsTemplate' when calling"
+ " createEmployeeEarningsTemplate");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling"
+ " createEmployeeEarningsTemplate");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
UriBuilder uriBuilder =
UriBuilder.fromUri(
apiClient.getBasePath() + "/Employees/{EmployeeID}/PayTemplates/earnings");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(earningsTemplate);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates leave records for a specific employee
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param employeeLeave The employeeLeave parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return EmployeeLeaveObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EmployeeLeaveObject createEmployeeLeave(
String accessToken,
String xeroTenantId,
UUID employeeID,
EmployeeLeave employeeLeave,
String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createEmployeeLeaveForHttpResponse(
accessToken, xeroTenantId, employeeID, employeeLeave, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createEmployeeLeave -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
EmployeeLeaveObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EmployeeLeaveObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates leave records for a specific employee
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param employeeLeave The employeeLeave parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createEmployeeLeaveForHttpResponse(
String accessToken,
String xeroTenantId,
UUID employeeID,
EmployeeLeave employeeLeave,
String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createEmployeeLeave");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling createEmployeeLeave");
} // verify the required parameter 'employeeLeave' is set
if (employeeLeave == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeLeave' when calling createEmployeeLeave");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createEmployeeLeave");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Employees/{EmployeeID}/Leave");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(employeeLeave);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates employee leave type records
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param employeeLeaveType The employeeLeaveType parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return EmployeeLeaveTypeObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EmployeeLeaveTypeObject createEmployeeLeaveType(
String accessToken,
String xeroTenantId,
UUID employeeID,
EmployeeLeaveType employeeLeaveType,
String idempotencyKey)
throws IOException {
try {
TypeReference typeRef =
new TypeReference() {};
HttpResponse response =
createEmployeeLeaveTypeForHttpResponse(
accessToken, xeroTenantId, employeeID, employeeLeaveType, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createEmployeeLeaveType -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
EmployeeLeaveTypeObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(
e.getStatusCode(), "EmployeeLeaveTypeObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates employee leave type records
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param employeeLeaveType The employeeLeaveType parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createEmployeeLeaveTypeForHttpResponse(
String accessToken,
String xeroTenantId,
UUID employeeID,
EmployeeLeaveType employeeLeaveType,
String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createEmployeeLeaveType");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling createEmployeeLeaveType");
} // verify the required parameter 'employeeLeaveType' is set
if (employeeLeaveType == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeLeaveType' when calling"
+ " createEmployeeLeaveType");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createEmployeeLeaveType");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Employees/{EmployeeID}/LeaveTypes");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(employeeLeaveType);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates an opening balance for a specific employee
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param employeeOpeningBalances The employeeOpeningBalances parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return EmployeeOpeningBalancesObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EmployeeOpeningBalancesObject createEmployeeOpeningBalances(
String accessToken,
String xeroTenantId,
UUID employeeID,
EmployeeOpeningBalances employeeOpeningBalances,
String idempotencyKey)
throws IOException {
try {
TypeReference typeRef =
new TypeReference() {};
HttpResponse response =
createEmployeeOpeningBalancesForHttpResponse(
accessToken, xeroTenantId, employeeID, employeeOpeningBalances, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createEmployeeOpeningBalances -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
EmployeeOpeningBalancesObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(
e.getStatusCode(), "EmployeeOpeningBalancesObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates an opening balance for a specific employee
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param employeeOpeningBalances The employeeOpeningBalances parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createEmployeeOpeningBalancesForHttpResponse(
String accessToken,
String xeroTenantId,
UUID employeeID,
EmployeeOpeningBalances employeeOpeningBalances,
String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling"
+ " createEmployeeOpeningBalances");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling createEmployeeOpeningBalances");
} // verify the required parameter 'employeeOpeningBalances' is set
if (employeeOpeningBalances == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeOpeningBalances' when calling"
+ " createEmployeeOpeningBalances");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling"
+ " createEmployeeOpeningBalances");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Employees/{EmployeeID}/ukopeningbalances");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(employeeOpeningBalances);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates an employee payment method
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param paymentMethod The paymentMethod parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return PaymentMethodObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public PaymentMethodObject createEmployeePaymentMethod(
String accessToken,
String xeroTenantId,
UUID employeeID,
PaymentMethod paymentMethod,
String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createEmployeePaymentMethodForHttpResponse(
accessToken, xeroTenantId, employeeID, paymentMethod, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createEmployeePaymentMethod -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
PaymentMethodObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "PaymentMethodObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates an employee payment method
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param paymentMethod The paymentMethod parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createEmployeePaymentMethodForHttpResponse(
String accessToken,
String xeroTenantId,
UUID employeeID,
PaymentMethod paymentMethod,
String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createEmployeePaymentMethod");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling createEmployeePaymentMethod");
} // verify the required parameter 'paymentMethod' is set
if (paymentMethod == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'paymentMethod' when calling"
+ " createEmployeePaymentMethod");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createEmployeePaymentMethod");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Employees/{EmployeeID}/PaymentMethods");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(paymentMethod);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates a salary and wage record for a specific employee
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param salaryAndWage The salaryAndWage parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return SalaryAndWageObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public SalaryAndWageObject createEmployeeSalaryAndWage(
String accessToken,
String xeroTenantId,
UUID employeeID,
SalaryAndWage salaryAndWage,
String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createEmployeeSalaryAndWageForHttpResponse(
accessToken, xeroTenantId, employeeID, salaryAndWage, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createEmployeeSalaryAndWage -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
SalaryAndWageObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "SalaryAndWageObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates a salary and wage record for a specific employee
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param salaryAndWage The salaryAndWage parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createEmployeeSalaryAndWageForHttpResponse(
String accessToken,
String xeroTenantId,
UUID employeeID,
SalaryAndWage salaryAndWage,
String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createEmployeeSalaryAndWage");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling createEmployeeSalaryAndWage");
} // verify the required parameter 'salaryAndWage' is set
if (salaryAndWage == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'salaryAndWage' when calling"
+ " createEmployeeSalaryAndWage");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createEmployeeSalaryAndWage");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Employees/{EmployeeID}/SalaryAndWages");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(salaryAndWage);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates statutory sick leave records
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeStatutorySickLeave The employeeStatutorySickLeave parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return EmployeeStatutorySickLeaveObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EmployeeStatutorySickLeaveObject createEmployeeStatutorySickLeave(
String accessToken,
String xeroTenantId,
EmployeeStatutorySickLeave employeeStatutorySickLeave,
String idempotencyKey)
throws IOException {
try {
TypeReference typeRef =
new TypeReference() {};
HttpResponse response =
createEmployeeStatutorySickLeaveForHttpResponse(
accessToken, xeroTenantId, employeeStatutorySickLeave, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createEmployeeStatutorySickLeave -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
EmployeeStatutorySickLeaveObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(
e.getStatusCode(), "EmployeeStatutorySickLeaveObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates statutory sick leave records
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeStatutorySickLeave The employeeStatutorySickLeave parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createEmployeeStatutorySickLeaveForHttpResponse(
String accessToken,
String xeroTenantId,
EmployeeStatutorySickLeave employeeStatutorySickLeave,
String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling"
+ " createEmployeeStatutorySickLeave");
} // verify the required parameter 'employeeStatutorySickLeave' is set
if (employeeStatutorySickLeave == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeStatutorySickLeave' when calling"
+ " createEmployeeStatutorySickLeave");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling"
+ " createEmployeeStatutorySickLeave");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/StatutoryLeaves/Sick");
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(employeeStatutorySickLeave);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates employment detail for a specific employee using a unique employee ID
*
*
200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param employment The employment parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return EmploymentObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EmploymentObject createEmployment(
String accessToken,
String xeroTenantId,
UUID employeeID,
Employment employment,
String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createEmploymentForHttpResponse(
accessToken, xeroTenantId, employeeID, employment, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createEmployment -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
EmploymentObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EmploymentObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates employment detail for a specific employee using a unique employee ID
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param employment The employment parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createEmploymentForHttpResponse(
String accessToken,
String xeroTenantId,
UUID employeeID,
Employment employment,
String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createEmployment");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling createEmployment");
} // verify the required parameter 'employment' is set
if (employment == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employment' when calling createEmployment");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createEmployment");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Employees/{EmployeeID}/Employment");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(employment);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates a new leave type
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param leaveType The leaveType parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return LeaveTypeObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public LeaveTypeObject createLeaveType(
String accessToken, String xeroTenantId, LeaveType leaveType, String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createLeaveTypeForHttpResponse(accessToken, xeroTenantId, leaveType, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createLeaveType -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
LeaveTypeObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "LeaveTypeObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates a new leave type
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param leaveType The leaveType parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createLeaveTypeForHttpResponse(
String accessToken, String xeroTenantId, LeaveType leaveType, String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createLeaveType");
} // verify the required parameter 'leaveType' is set
if (leaveType == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'leaveType' when calling createLeaveType");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createLeaveType");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/LeaveTypes");
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(leaveType);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates multiple earnings template records for a specific employee using a unique employee ID
*
*
200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param earningsTemplate The earningsTemplate parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return EmployeePayTemplates
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EmployeePayTemplates createMultipleEmployeeEarningsTemplate(
String accessToken,
String xeroTenantId,
UUID employeeID,
List earningsTemplate,
String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createMultipleEmployeeEarningsTemplateForHttpResponse(
accessToken, xeroTenantId, employeeID, earningsTemplate, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createMultipleEmployeeEarningsTemplate -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
EmployeePayTemplates object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EmployeePayTemplates", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates multiple earnings template records for a specific employee using a unique employee ID
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param earningsTemplate The earningsTemplate parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createMultipleEmployeeEarningsTemplateForHttpResponse(
String accessToken,
String xeroTenantId,
UUID employeeID,
List earningsTemplate,
String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling"
+ " createMultipleEmployeeEarningsTemplate");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling"
+ " createMultipleEmployeeEarningsTemplate");
} // verify the required parameter 'earningsTemplate' is set
if (earningsTemplate == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'earningsTemplate' when calling"
+ " createMultipleEmployeeEarningsTemplate");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling"
+ " createMultipleEmployeeEarningsTemplate");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Employees/{EmployeeID}/paytemplateearnings");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(earningsTemplate);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates a new payrun calendar
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param payRunCalendar The payRunCalendar parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return PayRunCalendarObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public PayRunCalendarObject createPayRunCalendar(
String accessToken, String xeroTenantId, PayRunCalendar payRunCalendar, String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createPayRunCalendarForHttpResponse(
accessToken, xeroTenantId, payRunCalendar, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createPayRunCalendar -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
PayRunCalendarObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "PayRunCalendarObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates a new payrun calendar
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param payRunCalendar The payRunCalendar parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createPayRunCalendarForHttpResponse(
String accessToken, String xeroTenantId, PayRunCalendar payRunCalendar, String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createPayRunCalendar");
} // verify the required parameter 'payRunCalendar' is set
if (payRunCalendar == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'payRunCalendar' when calling createPayRunCalendar");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createPayRunCalendar");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/PayRunCalendars");
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(payRunCalendar);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates a new reimbursement
*
*
200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param reimbursement The reimbursement parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return ReimbursementObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public ReimbursementObject createReimbursement(
String accessToken, String xeroTenantId, Reimbursement reimbursement, String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createReimbursementForHttpResponse(
accessToken, xeroTenantId, reimbursement, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createReimbursement -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
ReimbursementObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "ReimbursementObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates a new reimbursement
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param reimbursement The reimbursement parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createReimbursementForHttpResponse(
String accessToken, String xeroTenantId, Reimbursement reimbursement, String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createReimbursement");
} // verify the required parameter 'reimbursement' is set
if (reimbursement == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'reimbursement' when calling createReimbursement");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createReimbursement");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Reimbursements");
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(reimbursement);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates a new timesheet
*
*
200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param timesheet The timesheet parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return TimesheetObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public TimesheetObject createTimesheet(
String accessToken, String xeroTenantId, Timesheet timesheet, String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createTimesheetForHttpResponse(accessToken, xeroTenantId, timesheet, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createTimesheet -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
TimesheetObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "TimesheetObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates a new timesheet
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param timesheet The timesheet parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createTimesheetForHttpResponse(
String accessToken, String xeroTenantId, Timesheet timesheet, String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createTimesheet");
} // verify the required parameter 'timesheet' is set
if (timesheet == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'timesheet' when calling createTimesheet");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createTimesheet");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Timesheets");
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(timesheet);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Creates a new timesheet line for a specific timesheet using a unique timesheet ID
*
*
200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param timesheetID Identifier for the timesheet
* @param timesheetLine The timesheetLine parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return TimesheetLineObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public TimesheetLineObject createTimesheetLine(
String accessToken,
String xeroTenantId,
UUID timesheetID,
TimesheetLine timesheetLine,
String idempotencyKey)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
createTimesheetLineForHttpResponse(
accessToken, xeroTenantId, timesheetID, timesheetLine, idempotencyKey);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : createTimesheetLine -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
TimesheetLineObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "TimesheetLineObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Creates a new timesheet line for a specific timesheet using a unique timesheet ID
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param timesheetID Identifier for the timesheet
* @param timesheetLine The timesheetLine parameter
* @param idempotencyKey This allows you to safely retry requests without the risk of duplicate
* processing. 128 character max.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse createTimesheetLineForHttpResponse(
String accessToken,
String xeroTenantId,
UUID timesheetID,
TimesheetLine timesheetLine,
String idempotencyKey)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling createTimesheetLine");
} // verify the required parameter 'timesheetID' is set
if (timesheetID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'timesheetID' when calling createTimesheetLine");
} // verify the required parameter 'timesheetLine' is set
if (timesheetLine == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'timesheetLine' when calling createTimesheetLine");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling createTimesheetLine");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.set("Idempotency-Key", idempotencyKey);
headers.setAccept("application/json");
headers.setContentType("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("TimesheetID", timesheetID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Timesheets/{TimesheetID}/Lines");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
}
HttpContent content = null;
content = apiClient.new JacksonJsonHttpContent(timesheetLine);
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.POST, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Deletes a specific employee's earnings template record
*
* 200 - deletion successful
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param payTemplateEarningID Id for single pay template earnings object
* @param accessToken Authorization token for user set in header of each request
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public void deleteEmployeeEarningsTemplate(
String accessToken, String xeroTenantId, UUID employeeID, UUID payTemplateEarningID)
throws IOException {
try {
deleteEmployeeEarningsTemplateForHttpResponse(
accessToken, xeroTenantId, employeeID, payTemplateEarningID);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : deleteEmployeeEarningsTemplate -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
handler.execute(e);
} catch (IOException ioe) {
throw ioe;
}
}
/**
* Deletes a specific employee's earnings template record
*
*
200 - deletion successful
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param payTemplateEarningID Id for single pay template earnings object
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse deleteEmployeeEarningsTemplateForHttpResponse(
String accessToken, String xeroTenantId, UUID employeeID, UUID payTemplateEarningID)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling"
+ " deleteEmployeeEarningsTemplate");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling"
+ " deleteEmployeeEarningsTemplate");
} // verify the required parameter 'payTemplateEarningID' is set
if (payTemplateEarningID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'payTemplateEarningID' when calling"
+ " deleteEmployeeEarningsTemplate");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling"
+ " deleteEmployeeEarningsTemplate");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
uriVariables.put("PayTemplateEarningID", payTemplateEarningID);
UriBuilder uriBuilder =
UriBuilder.fromUri(
apiClient.getBasePath()
+ "/Employees/{EmployeeID}/PayTemplates/earnings/{PayTemplateEarningID}");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("DELETE " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.DELETE, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Deletes a specific employee's leave record
*
* 200 - successful response
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param leaveID Leave id for single object
* @param accessToken Authorization token for user set in header of each request
* @return EmployeeLeaveObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EmployeeLeaveObject deleteEmployeeLeave(
String accessToken, String xeroTenantId, UUID employeeID, UUID leaveID) throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
deleteEmployeeLeaveForHttpResponse(accessToken, xeroTenantId, employeeID, leaveID);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : deleteEmployeeLeave -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
EmployeeLeaveObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EmployeeLeaveObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Deletes a specific employee's leave record
*
* 200 - successful response
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param leaveID Leave id for single object
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse deleteEmployeeLeaveForHttpResponse(
String accessToken, String xeroTenantId, UUID employeeID, UUID leaveID) throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling deleteEmployeeLeave");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling deleteEmployeeLeave");
} // verify the required parameter 'leaveID' is set
if (leaveID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'leaveID' when calling deleteEmployeeLeave");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling deleteEmployeeLeave");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
uriVariables.put("LeaveID", leaveID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Employees/{EmployeeID}/Leave/{LeaveID}");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("DELETE " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.DELETE, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Deletes a salary and wages record for a specific employee
*
* 200 - deletion successful
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param salaryAndWagesID Id for single salary and wages object
* @param accessToken Authorization token for user set in header of each request
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public void deleteEmployeeSalaryAndWage(
String accessToken, String xeroTenantId, UUID employeeID, UUID salaryAndWagesID)
throws IOException {
try {
deleteEmployeeSalaryAndWageForHttpResponse(
accessToken, xeroTenantId, employeeID, salaryAndWagesID);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : deleteEmployeeSalaryAndWage -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
handler.execute(e);
} catch (IOException ioe) {
throw ioe;
}
}
/**
* Deletes a salary and wages record for a specific employee
*
*
200 - deletion successful
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param salaryAndWagesID Id for single salary and wages object
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse deleteEmployeeSalaryAndWageForHttpResponse(
String accessToken, String xeroTenantId, UUID employeeID, UUID salaryAndWagesID)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling deleteEmployeeSalaryAndWage");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling deleteEmployeeSalaryAndWage");
} // verify the required parameter 'salaryAndWagesID' is set
if (salaryAndWagesID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'salaryAndWagesID' when calling"
+ " deleteEmployeeSalaryAndWage");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling deleteEmployeeSalaryAndWage");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
uriVariables.put("SalaryAndWagesID", salaryAndWagesID);
UriBuilder uriBuilder =
UriBuilder.fromUri(
apiClient.getBasePath() + "/Employees/{EmployeeID}/SalaryAndWages/{SalaryAndWagesID}");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("DELETE " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.DELETE, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Deletes a specific timesheet
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param timesheetID Identifier for the timesheet
* @param accessToken Authorization token for user set in header of each request
* @return TimesheetLine
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public TimesheetLine deleteTimesheet(String accessToken, String xeroTenantId, UUID timesheetID)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
deleteTimesheetForHttpResponse(accessToken, xeroTenantId, timesheetID);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : deleteTimesheet -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
handler.execute(e);
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Deletes a specific timesheet
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param timesheetID Identifier for the timesheet
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse deleteTimesheetForHttpResponse(
String accessToken, String xeroTenantId, UUID timesheetID) throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling deleteTimesheet");
} // verify the required parameter 'timesheetID' is set
if (timesheetID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'timesheetID' when calling deleteTimesheet");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling deleteTimesheet");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("TimesheetID", timesheetID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Timesheets/{TimesheetID}");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("DELETE " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.DELETE, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Deletes a specific timesheet line
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param timesheetID Identifier for the timesheet
* @param timesheetLineID Identifier for the timesheet line
* @param accessToken Authorization token for user set in header of each request
* @return TimesheetLine
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public TimesheetLine deleteTimesheetLine(
String accessToken, String xeroTenantId, UUID timesheetID, UUID timesheetLineID)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
deleteTimesheetLineForHttpResponse(
accessToken, xeroTenantId, timesheetID, timesheetLineID);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : deleteTimesheetLine -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
handler.execute(e);
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Deletes a specific timesheet line
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param timesheetID Identifier for the timesheet
* @param timesheetLineID Identifier for the timesheet line
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse deleteTimesheetLineForHttpResponse(
String accessToken, String xeroTenantId, UUID timesheetID, UUID timesheetLineID)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling deleteTimesheetLine");
} // verify the required parameter 'timesheetID' is set
if (timesheetID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'timesheetID' when calling deleteTimesheetLine");
} // verify the required parameter 'timesheetLineID' is set
if (timesheetLineID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'timesheetLineID' when calling deleteTimesheetLine");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling deleteTimesheetLine");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("TimesheetID", timesheetID);
uriVariables.put("TimesheetLineID", timesheetLineID);
UriBuilder uriBuilder =
UriBuilder.fromUri(
apiClient.getBasePath() + "/Timesheets/{TimesheetID}/Lines/{TimesheetLineID}");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("DELETE " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.DELETE, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Retrieves a specific benefit by using a unique benefit ID
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param id Identifier for the benefit
* @param accessToken Authorization token for user set in header of each request
* @return BenefitObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public BenefitObject getBenefit(String accessToken, String xeroTenantId, UUID id)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response = getBenefitForHttpResponse(accessToken, xeroTenantId, id);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : getBenefit -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
BenefitObject object = apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "BenefitObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Retrieves a specific benefit by using a unique benefit ID
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param id Identifier for the benefit
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse getBenefitForHttpResponse(String accessToken, String xeroTenantId, UUID id)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling getBenefit");
} // verify the required parameter 'id' is set
if (id == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'id' when calling getBenefit");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling getBenefit");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("id", id);
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Benefits/{id}");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("GET " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.GET, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Retrieves employee benefits
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param page Page number which specifies the set of records to retrieve. By default the number
* of the records per set is 100.
* @param accessToken Authorization token for user set in header of each request
* @return Benefits
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public Benefits getBenefits(String accessToken, String xeroTenantId, Integer page)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response = getBenefitsForHttpResponse(accessToken, xeroTenantId, page);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : getBenefits -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
Benefits object = apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "Benefits", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Retrieves employee benefits
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param page Page number which specifies the set of records to retrieve. By default the number
* of the records per set is 100.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse getBenefitsForHttpResponse(
String accessToken, String xeroTenantId, Integer page) throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling getBenefits");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling getBenefits");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Benefits");
if (page != null) {
String key = "page";
Object value = page;
if (value instanceof Collection) {
List valueList = new ArrayList<>((Collection) value);
if (!valueList.isEmpty() && valueList.get(0) instanceof UUID) {
List list = new ArrayList();
for (int i = 0; i < valueList.size(); i++) {
list.add(valueList.get(i).toString());
}
uriBuilder = uriBuilder.queryParam(key, String.join(",", list));
} else {
uriBuilder = uriBuilder.queryParam(key, String.join(",", valueList));
}
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("GET " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.GET, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Retrieves a specific deduction by using a unique deduction ID
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param deductionId Identifier for the deduction
* @param accessToken Authorization token for user set in header of each request
* @return DeductionObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public DeductionObject getDeduction(String accessToken, String xeroTenantId, UUID deductionId)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response = getDeductionForHttpResponse(accessToken, xeroTenantId, deductionId);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : getDeduction -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
DeductionObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "DeductionObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Retrieves a specific deduction by using a unique deduction ID
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param deductionId Identifier for the deduction
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse getDeductionForHttpResponse(
String accessToken, String xeroTenantId, UUID deductionId) throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling getDeduction");
} // verify the required parameter 'deductionId' is set
if (deductionId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'deductionId' when calling getDeduction");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling getDeduction");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("deductionId", deductionId);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Deductions/{deductionId}");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("GET " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.GET, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Retrieves deductions
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param page Page number which specifies the set of records to retrieve. By default the number
* of the records per set is 100.
* @param accessToken Authorization token for user set in header of each request
* @return Deductions
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public Deductions getDeductions(String accessToken, String xeroTenantId, Integer page)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response = getDeductionsForHttpResponse(accessToken, xeroTenantId, page);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : getDeductions -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
Deductions object = apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "Deductions", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Retrieves deductions
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param page Page number which specifies the set of records to retrieve. By default the number
* of the records per set is 100.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse getDeductionsForHttpResponse(
String accessToken, String xeroTenantId, Integer page) throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling getDeductions");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling getDeductions");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Deductions");
if (page != null) {
String key = "page";
Object value = page;
if (value instanceof Collection) {
List valueList = new ArrayList<>((Collection) value);
if (!valueList.isEmpty() && valueList.get(0) instanceof UUID) {
List list = new ArrayList();
for (int i = 0; i < valueList.size(); i++) {
list.add(valueList.get(i).toString());
}
uriBuilder = uriBuilder.queryParam(key, String.join(",", list));
} else {
uriBuilder = uriBuilder.queryParam(key, String.join(",", valueList));
}
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("GET " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.GET, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Retrieves a specific earnings orders by using a unique earnings orders id
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param id Identifier for the deduction
* @param accessToken Authorization token for user set in header of each request
* @return EarningsOrderObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EarningsOrderObject getEarningsOrder(String accessToken, String xeroTenantId, UUID id)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response = getEarningsOrderForHttpResponse(accessToken, xeroTenantId, id);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : getEarningsOrder -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
EarningsOrderObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EarningsOrderObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Retrieves a specific earnings orders by using a unique earnings orders id
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param id Identifier for the deduction
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse getEarningsOrderForHttpResponse(
String accessToken, String xeroTenantId, UUID id) throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling getEarningsOrder");
} // verify the required parameter 'id' is set
if (id == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'id' when calling getEarningsOrder");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling getEarningsOrder");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("id", id);
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/EarningsOrders/{id}");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("GET " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.GET, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Retrieves earnings orders
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param page Page number which specifies the set of records to retrieve. By default the number
* of the records per set is 100.
* @param accessToken Authorization token for user set in header of each request
* @return EarningsOrders
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EarningsOrders getEarningsOrders(String accessToken, String xeroTenantId, Integer page)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response = getEarningsOrdersForHttpResponse(accessToken, xeroTenantId, page);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : getEarningsOrders -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
EarningsOrders object = apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EarningsOrders", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Retrieves earnings orders
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param page Page number which specifies the set of records to retrieve. By default the number
* of the records per set is 100.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse getEarningsOrdersForHttpResponse(
String accessToken, String xeroTenantId, Integer page) throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling getEarningsOrders");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling getEarningsOrders");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/EarningsOrders");
if (page != null) {
String key = "page";
Object value = page;
if (value instanceof Collection) {
List valueList = new ArrayList<>((Collection) value);
if (!valueList.isEmpty() && valueList.get(0) instanceof UUID) {
List list = new ArrayList();
for (int i = 0; i < valueList.size(); i++) {
list.add(valueList.get(i).toString());
}
uriBuilder = uriBuilder.queryParam(key, String.join(",", list));
} else {
uriBuilder = uriBuilder.queryParam(key, String.join(",", valueList));
}
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("GET " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.GET, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Retrieves a specific earnings rates by using a unique earnings rate id
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param earningsRateID Identifier for the earnings rate
* @param accessToken Authorization token for user set in header of each request
* @return EarningsRateObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EarningsRateObject getEarningsRate(
String accessToken, String xeroTenantId, UUID earningsRateID) throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
getEarningsRateForHttpResponse(accessToken, xeroTenantId, earningsRateID);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : getEarningsRate -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
EarningsRateObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EarningsRateObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Retrieves a specific earnings rates by using a unique earnings rate id
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param earningsRateID Identifier for the earnings rate
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse getEarningsRateForHttpResponse(
String accessToken, String xeroTenantId, UUID earningsRateID) throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling getEarningsRate");
} // verify the required parameter 'earningsRateID' is set
if (earningsRateID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'earningsRateID' when calling getEarningsRate");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling getEarningsRate");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EarningsRateID", earningsRateID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/EarningsRates/{EarningsRateID}");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("GET " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.GET, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Retrieves earnings rates
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param page Page number which specifies the set of records to retrieve. By default the number
* of the records per set is 100.
* @param accessToken Authorization token for user set in header of each request
* @return EarningsRates
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EarningsRates getEarningsRates(String accessToken, String xeroTenantId, Integer page)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response = getEarningsRatesForHttpResponse(accessToken, xeroTenantId, page);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : getEarningsRates -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
EarningsRates object = apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EarningsRates", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Retrieves earnings rates
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param page Page number which specifies the set of records to retrieve. By default the number
* of the records per set is 100.
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse getEarningsRatesForHttpResponse(
String accessToken, String xeroTenantId, Integer page) throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling getEarningsRates");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling getEarningsRates");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/EarningsRates");
if (page != null) {
String key = "page";
Object value = page;
if (value instanceof Collection) {
List valueList = new ArrayList<>((Collection) value);
if (!valueList.isEmpty() && valueList.get(0) instanceof UUID) {
List list = new ArrayList();
for (int i = 0; i < valueList.size(); i++) {
list.add(valueList.get(i).toString());
}
uriBuilder = uriBuilder.queryParam(key, String.join(",", list));
} else {
uriBuilder = uriBuilder.queryParam(key, String.join(",", valueList));
}
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("GET " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.GET, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Retrieves specific employees by using a unique employee ID
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param accessToken Authorization token for user set in header of each request
* @return EmployeeObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EmployeeObject getEmployee(String accessToken, String xeroTenantId, UUID employeeID)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response = getEmployeeForHttpResponse(accessToken, xeroTenantId, employeeID);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : getEmployee -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
EmployeeObject object = apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EmployeeObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Retrieves specific employees by using a unique employee ID
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse getEmployeeForHttpResponse(
String accessToken, String xeroTenantId, UUID employeeID) throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling getEmployee");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling getEmployee");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling getEmployee");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Employees/{EmployeeID}");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("GET " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.GET, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Retrieves a specific employee's leave record using a unique employee ID
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param leaveID Leave id for single object
* @param accessToken Authorization token for user set in header of each request
* @return EmployeeLeaveObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EmployeeLeaveObject getEmployeeLeave(
String accessToken, String xeroTenantId, UUID employeeID, UUID leaveID) throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
getEmployeeLeaveForHttpResponse(accessToken, xeroTenantId, employeeID, leaveID);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : getEmployeeLeave -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
EmployeeLeaveObject object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EmployeeLeaveObject", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Retrieves a specific employee's leave record using a unique employee ID
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param leaveID Leave id for single object
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse getEmployeeLeaveForHttpResponse(
String accessToken, String xeroTenantId, UUID employeeID, UUID leaveID) throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling getEmployeeLeave");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling getEmployeeLeave");
} // verify the required parameter 'leaveID' is set
if (leaveID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'leaveID' when calling getEmployeeLeave");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling getEmployeeLeave");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
uriVariables.put("LeaveID", leaveID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Employees/{EmployeeID}/Leave/{LeaveID}");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("GET " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.GET, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Retrieves a specific employee's leave balances using a unique employee ID
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param accessToken Authorization token for user set in header of each request
* @return EmployeeLeaveBalances
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public EmployeeLeaveBalances getEmployeeLeaveBalances(
String accessToken, String xeroTenantId, UUID employeeID) throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
getEmployeeLeaveBalancesForHttpResponse(accessToken, xeroTenantId, employeeID);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : getEmployeeLeaveBalances -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef =
new TypeReference() {};
EmployeeLeaveBalances object =
apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "EmployeeLeaveBalances", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Retrieves a specific employee's leave balances using a unique employee ID
*
* 200 - search results matching criteria
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse getEmployeeLeaveBalancesForHttpResponse(
String accessToken, String xeroTenantId, UUID employeeID) throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling getEmployeeLeaveBalances");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling getEmployeeLeaveBalances");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling getEmployeeLeaveBalances");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Employees/{EmployeeID}/LeaveBalances");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("GET " + genericUrl.toString());
}
HttpContent content = null;
Credential credential =
new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
HttpTransport transport = apiClient.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
return requestFactory
.buildRequest(HttpMethods.GET, genericUrl, content)
.setHeaders(headers)
.setConnectTimeout(apiClient.getConnectionTimeout())
.setReadTimeout(apiClient.getReadTimeout())
.execute();
}
/**
* Retrieves a specific employee's leave periods using a unique employee ID
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param startDate Filter by start date
* @param endDate Filter by end date
* @param accessToken Authorization token for user set in header of each request
* @return LeavePeriods
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public LeavePeriods getEmployeeLeavePeriods(
String accessToken,
String xeroTenantId,
UUID employeeID,
LocalDate startDate,
LocalDate endDate)
throws IOException {
try {
TypeReference typeRef = new TypeReference() {};
HttpResponse response =
getEmployeeLeavePeriodsForHttpResponse(
accessToken, xeroTenantId, employeeID, startDate, endDate);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : getEmployeeLeavePeriods -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
if (e.getStatusCode() == 400 || e.getStatusCode() == 405) {
TypeReference errorTypeRef = new TypeReference() {};
LeavePeriods object = apiClient.getObjectMapper().readValue(e.getContent(), errorTypeRef);
handler.validationError(e.getStatusCode(), "LeavePeriods", object.getProblem(), e);
} else {
handler.execute(e);
}
} catch (IOException ioe) {
throw ioe;
}
return null;
}
/**
* Retrieves a specific employee's leave periods using a unique employee ID
*
* 200 - search results matching criteria
*
*
400 - validation error for a bad request
*
* @param xeroTenantId Xero identifier for Tenant
* @param employeeID Employee id for single object
* @param startDate Filter by start date
* @param endDate Filter by end date
* @param accessToken Authorization token for user set in header of each request
* @return HttpResponse
* @throws IOException if an error occurs while attempting to invoke the API
*/
public HttpResponse getEmployeeLeavePeriodsForHttpResponse(
String accessToken,
String xeroTenantId,
UUID employeeID,
LocalDate startDate,
LocalDate endDate)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling getEmployeeLeavePeriods");
} // verify the required parameter 'employeeID' is set
if (employeeID == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'employeeID' when calling getEmployeeLeavePeriods");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling getEmployeeLeavePeriods");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Xero-Tenant-Id", xeroTenantId);
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
// create a map of path variables
final Map uriVariables = new HashMap();
uriVariables.put("EmployeeID", employeeID);
UriBuilder uriBuilder =
UriBuilder.fromUri(apiClient.getBasePath() + "/Employees/{EmployeeID}/LeavePeriods");
if (startDate != null) {
String key = "startDate";
Object value = startDate;
if (value instanceof Collection) {
List valueList = new ArrayList<>((Collection) value);
if (!valueList.isEmpty() && valueList.get(0) instanceof UUID) {
List list = new ArrayList