Skip to content

Commit

Permalink
Merge pull request #275 from XeroAPI/sid-development
Browse files Browse the repository at this point in the history
Build from OAS 2.10.3
  • Loading branch information
SidneyAllen authored Mar 24, 2021
2 parents 6a7086c + 94bd4e7 commit 0ead3dc
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 66 deletions.
4 changes: 2 additions & 2 deletions docs/v4/accounting/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6396,9 +6396,9 @@ <h1>Xero Accounting API</h1>
<div id="header">
<div id="api-_">
<h2 id="welcome-to-apidoc">API and SDK Documentation</h2>
<div class="app-desc">Version: 4.8.1</div>
<div class="app-desc">Version: 4.8.2</div>
<!--
<div class="app-desc">Version: 2.10.1</div>
<div class="app-desc">Version: 2.10.3</div>
<hr>
<div id="app-description" class="app-desc">
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>xero-java</artifactId>
<packaging>jar</packaging>
<name>xero-java</name>
<version>4.8.1</version>
<version>4.8.2</version>
<url>https://github.com/XeroAPI/Xero-Java</url>
<description>This is the official Java SDK for Xero API</description>
<licenses>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/xero/api/client/AccountingApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Xero Accounting API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.10.1
* The version of the OpenAPI document: 2.10.3
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -98,7 +98,7 @@ public class AccountingApi {
private ApiClient apiClient;
private static AccountingApi instance = null;
private String userAgent = "Default";
private String version = "4.8.1";
private String version = "4.8.2";
static final Logger logger = LoggerFactory.getLogger(AccountingApi.class);

/** AccountingApi */
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/xero/api/client/AssetApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Xero Assets API
* The Assets API exposes fixed asset related functions of the Xero Accounting application and can be used for a variety of purposes such as creating assets, retrieving asset valuations etc.
*
* The version of the OpenAPI document: 2.10.1
* The version of the OpenAPI document: 2.10.3
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -48,7 +48,7 @@ public class AssetApi {
private ApiClient apiClient;
private static AssetApi instance = null;
private String userAgent = "Default";
private String version = "4.8.1";
private String version = "4.8.2";
static final Logger logger = LoggerFactory.getLogger(AssetApi.class);

/** AssetApi */
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/com/xero/api/client/BankFeedsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Xero Bank Feeds API
* The Bank Feeds API is a closed API that is only available to financial institutions that have an established financial services partnership with Xero. If you're an existing financial services partner that wants access, contact your local Partner Manager. If you're a financial institution who wants to provide bank feeds to your business customers, contact us to become a financial services partner.
*
* The version of the OpenAPI document: 2.10.1
* The version of the OpenAPI document: 2.10.3
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -46,7 +46,7 @@ public class BankFeedsApi {
private ApiClient apiClient;
private static BankFeedsApi instance = null;
private String userAgent = "Default";
private String version = "4.8.1";
private String version = "4.8.2";
static final Logger logger = LoggerFactory.getLogger(BankFeedsApi.class);

/** BankFeedsApi */
Expand Down Expand Up @@ -118,9 +118,7 @@ public String getUserAgent() {
*
* <p><b>202</b> - success new feed connection(s)response
*
* <p><b>400</b> - invalid input, object invalid
*
* <p><b>409</b> - failed to create new feed connection(s)response
* <p><b>400</b> - failed to create new feed connection(s)response
*
* @param xeroTenantId Xero identifier for Tenant
* @param feedConnections Feed Connection(s) array object in the body
Expand Down Expand Up @@ -164,9 +162,7 @@ public FeedConnections createFeedConnections(
*
* <p><b>202</b> - success new feed connection(s)response
*
* <p><b>400</b> - invalid input, object invalid
*
* <p><b>409</b> - failed to create new feed connection(s)response
* <p><b>400</b> - failed to create new feed connection(s)response
*
* @param xeroTenantId Xero identifier for Tenant
* @param feedConnections Feed Connection(s) array object in the body
Expand Down
190 changes: 170 additions & 20 deletions src/main/java/com/xero/api/client/FilesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Xero Files API
* These endpoints are specific to Xero Files API
*
* The version of the OpenAPI document: 2.10.1
* The version of the OpenAPI document: 2.10.3
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -53,7 +53,7 @@ public class FilesApi {
private ApiClient apiClient;
private static FilesApi instance = null;
private String userAgent = "Default";
private String version = "4.8.1";
private String version = "4.8.2";
static final Logger logger = LoggerFactory.getLogger(FilesApi.class);

/** FilesApi */
Expand Down Expand Up @@ -1493,14 +1493,13 @@ public HttpResponse updateFolderForHttpResponse(
}

/**
* Uploads a File
* Uploads a File to the inbox
*
* <p><b>201</b> - A successful request
*
* <p><b>400</b> - invalid input, object invalid
*
* @param xeroTenantId Xero identifier for Tenant
* @param folderId pass an optional folder id to save file to specific folder
* @param body The body parameter
* @param name exact name of the file you are uploading
* @param filename The filename parameter
Expand All @@ -1512,7 +1511,6 @@ public HttpResponse updateFolderForHttpResponse(
public FileObject uploadFile(
String accessToken,
String xeroTenantId,
UUID folderId,
File body,
String name,
String filename,
Expand All @@ -1521,8 +1519,7 @@ public FileObject uploadFile(
try {
TypeReference<FileObject> typeRef = new TypeReference<FileObject>() {};
HttpResponse response =
uploadFileForHttpResponse(
accessToken, xeroTenantId, folderId, body, name, filename, mimeType);
uploadFileForHttpResponse(accessToken, xeroTenantId, body, name, filename, mimeType);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
Expand All @@ -1541,14 +1538,13 @@ public FileObject uploadFile(
}

/**
* Uploads a File
* Uploads a File to the inbox
*
* <p><b>201</b> - A successful request
*
* <p><b>400</b> - invalid input, object invalid
*
* @param xeroTenantId Xero identifier for Tenant
* @param folderId pass an optional folder id to save file to specific folder
* @param body The body parameter
* @param name exact name of the file you are uploading
* @param filename The filename parameter
Expand All @@ -1560,7 +1556,6 @@ public FileObject uploadFile(
public HttpResponse uploadFileForHttpResponse(
String accessToken,
String xeroTenantId,
UUID folderId,
File body,
String name,
String filename,
Expand All @@ -1570,6 +1565,18 @@ public HttpResponse uploadFileForHttpResponse(
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling uploadFile");
} // verify the required parameter 'body' is set
if (body == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'body' when calling uploadFile");
} // verify the required parameter 'name' is set
if (name == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'name' when calling uploadFile");
} // verify the required parameter 'filename' is set
if (filename == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'filename' when calling uploadFile");
}
if (accessToken == null) {
throw new IllegalArgumentException(
Expand All @@ -1580,18 +1587,161 @@ public HttpResponse uploadFileForHttpResponse(
headers.setAccept("application/json");
headers.setUserAgent(this.getUserAgent());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Files");
if (folderId != null) {
String key = "FolderId";
Object value = folderId;
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} 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("POST " + genericUrl.toString());
}

Map<String, String> parameters = Maps.newHashMap();
parameters.put("name", name);
parameters.put("filename", filename);

// Add parameters
MultipartContent content =
new MultipartContent()
.setMediaType(
new HttpMediaType("multipart/form-data")
.setParameter("boundary", "__END_OF_PART__"));

for (String key : parameters.keySet()) {
MultipartContent.Part part =
new MultipartContent.Part(new ByteArrayContent(null, parameters.get(key).getBytes()));
part.setHeaders(
new HttpHeaders()
.set("Content-Disposition", String.format("form-data; name=\"%s\"", key)));
content.addPart(part);
}

FileContent fileContent = new FileContent(mimeType, body);
MultipartContent.Part part = new MultipartContent.Part(fileContent);
part.setHeaders(
new HttpHeaders()
.set(
"Content-Disposition",
String.format("form-data; name=\"content\"; filename=\"%s\"", filename)));
content.addPart(part);
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();
}

/**
* Uploads a File to a specific folder
*
* <p><b>201</b> - A successful request
*
* <p><b>400</b> - invalid input, object invalid
*
* @param xeroTenantId Xero identifier for Tenant
* @param folderId pass required folder id to save file to specific folder
* @param body The body parameter
* @param name exact name of the file you are uploading
* @param filename The filename parameter
* @param mimeType The mimeType parameter
* @param accessToken Authorization token for user set in header of each request
* @return FileObject
* @throws IOException if an error occurs while attempting to invoke the API *
*/
public FileObject uploadFileToFolder(
String accessToken,
String xeroTenantId,
UUID folderId,
File body,
String name,
String filename,
String mimeType)
throws IOException {
try {
TypeReference<FileObject> typeRef = new TypeReference<FileObject>() {};
HttpResponse response =
uploadFileToFolderForHttpResponse(
accessToken, xeroTenantId, folderId, body, name, filename, mimeType);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
logger.debug(
"------------------ HttpResponseException "
+ e.getStatusCode()
+ " : uploadFileToFolder -------------------");
logger.debug(e.toString());
}
XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
handler.execute(e);
} catch (IOException ioe) {
throw ioe;
}
String url = uriBuilder.build().toString();
return null;
}

/**
* Uploads a File to a specific folder
*
* <p><b>201</b> - A successful request
*
* <p><b>400</b> - invalid input, object invalid
*
* @param xeroTenantId Xero identifier for Tenant
* @param folderId pass required folder id to save file to specific folder
* @param body The body parameter
* @param name exact name of the file you are uploading
* @param filename The filename parameter
* @param mimeType The mimeType parameter
* @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 uploadFileToFolderForHttpResponse(
String accessToken,
String xeroTenantId,
UUID folderId,
File body,
String name,
String filename,
String mimeType)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'xeroTenantId' when calling uploadFileToFolder");
} // verify the required parameter 'folderId' is set
if (folderId == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'folderId' when calling uploadFileToFolder");
} // verify the required parameter 'body' is set
if (body == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'body' when calling uploadFileToFolder");
} // verify the required parameter 'name' is set
if (name == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'name' when calling uploadFileToFolder");
} // verify the required parameter 'filename' is set
if (filename == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'filename' when calling uploadFileToFolder");
}
if (accessToken == null) {
throw new IllegalArgumentException(
"Missing the required parameter 'accessToken' when calling uploadFileToFolder");
}
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<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("FolderId", folderId);

UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Files/{FolderId}");
String url = uriBuilder.buildFromMap(uriVariables).toString();
GenericUrl genericUrl = new GenericUrl(url);
if (logger.isDebugEnabled()) {
logger.debug("POST " + genericUrl.toString());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/xero/api/client/IdentityApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Xero OAuth 2 Identity Service API
* These endpoints are related to managing authentication tokens and identity for Xero API
*
* The version of the OpenAPI document: 2.10.1
* The version of the OpenAPI document: 2.10.3
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -44,7 +44,7 @@ public class IdentityApi {
private ApiClient apiClient;
private static IdentityApi instance = null;
private String userAgent = "Default";
private String version = "4.8.1";
private String version = "4.8.2";
static final Logger logger = LoggerFactory.getLogger(IdentityApi.class);

/** IdentityApi */
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/xero/api/client/PayrollAuApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Xero Payroll AU API
* This is the Xero Payroll API for orgs in Australia region.
*
* The version of the OpenAPI document: 2.10.1
* The version of the OpenAPI document: 2.10.3
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -63,7 +63,7 @@ public class PayrollAuApi {
private ApiClient apiClient;
private static PayrollAuApi instance = null;
private String userAgent = "Default";
private String version = "4.8.1";
private String version = "4.8.2";
static final Logger logger = LoggerFactory.getLogger(PayrollAuApi.class);

/** PayrollAuApi */
Expand Down
Loading

0 comments on commit 0ead3dc

Please sign in to comment.