Skip to content

Commit

Permalink
Merge pull request #283 from XeroAPI/sid-development
Browse files Browse the repository at this point in the history
Build from OpenAPI spec 2.11.0
  • Loading branch information
SidneyAllen authored Apr 27, 2021
2 parents 89737f4 + ebdec73 commit 93395e5
Show file tree
Hide file tree
Showing 18 changed files with 158 additions and 31 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,21 @@ public class TokenRefresh {
}
```

**Revoking Tokens**
You can revoke a user's refresh token and remove all their connections to your app by making a request to the revocation endpoint.

We've added a helpful method to the ApiClient class. The code below shows how to pass the id, secret and refresh token to execute the revoke method. Success

```java
try {
ApiClient apiClient = new ApiClient();
HttpResponse revokeResponse = apiClient.revoke(clientId, clientSecret, refreshToken);
System.out.println("Revoke success: " + revokeResponse.getStatusCode());
} catch (Exception e) {
System.out.println(e.getMessage());
}
```

**Data Endpoints**

The Xero Java SDK contains Client classes (AccountingApi, etc) which have helper methods to perform (Create, Read, Update and Delete) actions on each endpoints. AccountingApi is designed as a Singleton. Use the getInstance method of the class class and use with API models to interact with Java Objects.
Expand Down
26 changes: 23 additions & 3 deletions docs/v4/accounting/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3662,7 +3662,6 @@
"type" : "number",
"description" : "The calculated tax amount based on the TaxType and LineAmount",
"format" : "double",
"readOnly" : true,
"example" : 0.0,
"x-is-money" : true
},
Expand Down Expand Up @@ -5813,7 +5812,7 @@
<nav id="scrollingNav">
<ul class="sidenav nav nav-list">
<li class="nav-header" data-group="Accounting"><strong>SDK: </strong><span id='sdk-name'></span></li>
<li class="nav-header" data-group="Accounting"><strong>VSN: </strong>4.8.3</li>
<li class="nav-header" data-group="Accounting"><strong>VSN: </strong>4.9.1</li>
<li class="nav-header" data-group="Accounting"><a href="#api-Accounting">Methods</a></li>
<li data-group="Accounting" data-name="createAccount" class="">
<a href="#api-Accounting-createAccount">createAccount</a>
Expand Down Expand Up @@ -22097,9 +22096,10 @@ <h3>Usage and SDK Samples</h3>
array[UUID] iDs = &quot;00000000-0000-0000-0000-000000000000&quot;;
Integer page = 1;
Boolean includeArchived = true;
Boolean summaryOnly = true;

try {
Contacts result = apiInstance.getContacts(accessToken, xeroTenantId, ifModifiedSince, where, order, iDs, page, includeArchived);
Contacts result = apiInstance.getContacts(accessToken, xeroTenantId, ifModifiedSince, where, order, iDs, page, includeArchived, summaryOnly);
System.out.println(result);
} catch (XeroException e) {
System.err.println("Exception when calling AccountingApi#getContacts");
Expand Down Expand Up @@ -22279,6 +22279,26 @@ <h2>Parameters</h2>
</div>
</div>
</td>
</tr>

<tr><td style="width:150px;">summaryOnly</td>
<td>


<div id="d2e199_getContacts_summaryOnly">
<div class="json-schema-view">
<div class="primitive">
<span class="type">
Boolean
</span>

<div class="inner description marked">
Use summaryOnly=true in GET Contacts endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient.
</div>
</div>
</div>
</div>
</td>
</tr>

</table>
Expand Down
4 changes: 2 additions & 2 deletions 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.3</version>
<version>4.9.1</version>
<url>https://github.com/XeroAPI/Xero-Java</url>
<description>This is the official Java SDK for Xero API</description>
<licenses>
Expand Down Expand Up @@ -68,7 +68,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<version>2.7</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
Expand Down
40 changes: 39 additions & 1 deletion src/main/java/com/xero/api/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
import org.threeten.bp.*;
import com.google.api.client.googleapis.util.Utils;
import com.google.api.client.http.AbstractHttpContent;
import com.google.api.client.http.ByteArrayContent;
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.HttpResponse;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpTransport;
Expand All @@ -26,6 +32,7 @@
import com.auth0.jwt.interfaces.DecodedJWT;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.interfaces.RSAPublicKey;

/**
Expand Down Expand Up @@ -194,5 +201,36 @@ public DecodedJWT verify(String accessToken) throws MalformedURLException, JwkEx

return verifiedJWT;
}


/** method for revoking a refresh token
* @param refreshToken String the refresh token used to obtain a new access token via the API
* @param clientId String the client id used to authtenticate with the API
* @param clientSecret String the client secret used to authtenticate with the API
* @return revokeResponse HttpResponse a successful revocation request will return a 200 response with an empty body.
*/
public HttpResponse revoke(String clientId, String clientSecret, String refreshToken) throws IOException {

// BASIC AUTHENTICATION HEADER
HttpHeaders headers = new HttpHeaders();
headers.setBasicAuthentication(clientId, clientSecret);

// POST BODY WITH REFRESH TOKEN
String urlParameters = "token=" + refreshToken;
byte[] postData = urlParameters.getBytes( StandardCharsets.UTF_8 );
HttpContent content = new ByteArrayContent("application/x-www-form-urlencoded", postData);

// REVOKE URL DEFINED
GenericUrl url = new GenericUrl("https://identity.xero.com/connect/revocation");

HttpTransport transport = this.getHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory();
HttpResponse revokeResponse = requestFactory
.buildRequest(HttpMethods.POST, url, content)
.setHeaders(headers)
.setConnectTimeout(this.getConnectionTimeout())
.setReadTimeout(this.getReadTimeout())
.execute();

return revokeResponse;
}
}
37 changes: 32 additions & 5 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.4
* The version of the OpenAPI document: 2.11.0
* 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.3";
private String version = "4.9.1";
static final Logger logger = LoggerFactory.getLogger(AccountingApi.class);

/** AccountingApi */
Expand Down Expand Up @@ -12453,6 +12453,9 @@ public HttpResponse getContactHistoryForHttpResponse(
* @param page e.g. page&#x3D;1 - Up to 100 contacts will be returned in a single API call.
* @param includeArchived e.g. includeArchived&#x3D;true - Contacts with a status of ARCHIVED will
* be included in the response
* @param summaryOnly Use summaryOnly&#x3D;true in GET Contacts endpoint to retrieve a smaller
* version of the response object. This returns only lightweight fields, excluding
* computation-heavy fields from the response, making the API calls quick and efficient.
* @param accessToken Authorization token for user set in header of each request
* @return Contacts
* @throws IOException if an error occurs while attempting to invoke the API *
Expand All @@ -12465,13 +12468,22 @@ public Contacts getContacts(
String order,
List<UUID> ids,
Integer page,
Boolean includeArchived)
Boolean includeArchived,
Boolean summaryOnly)
throws IOException {
try {
TypeReference<Contacts> typeRef = new TypeReference<Contacts>() {};
HttpResponse response =
getContactsForHttpResponse(
accessToken, xeroTenantId, ifModifiedSince, where, order, ids, page, includeArchived);
accessToken,
xeroTenantId,
ifModifiedSince,
where,
order,
ids,
page,
includeArchived,
summaryOnly);
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
} catch (HttpResponseException e) {
if (logger.isDebugEnabled()) {
Expand Down Expand Up @@ -12503,6 +12515,9 @@ public Contacts getContacts(
* @param page e.g. page&#x3D;1 - Up to 100 contacts will be returned in a single API call.
* @param includeArchived e.g. includeArchived&#x3D;true - Contacts with a status of ARCHIVED will
* be included in the response
* @param summaryOnly Use summaryOnly&#x3D;true in GET Contacts endpoint to retrieve a smaller
* version of the response object. This returns only lightweight fields, excluding
* computation-heavy fields from the response, making the API calls quick and efficient.
* @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
Expand All @@ -12515,7 +12530,8 @@ public HttpResponse getContactsForHttpResponse(
String order,
List<UUID> ids,
Integer page,
Boolean includeArchived)
Boolean includeArchived,
Boolean summaryOnly)
throws IOException {
// verify the required parameter 'xeroTenantId' is set
if (xeroTenantId == null) {
Expand Down Expand Up @@ -12589,6 +12605,17 @@ public HttpResponse getContactsForHttpResponse(
uriBuilder = uriBuilder.queryParam(key, value);
}
}
if (summaryOnly != null) {
String key = "summaryOnly";
Object value = summaryOnly;
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()) {
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.4
* The version of the OpenAPI document: 2.11.0
* 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.3";
private String version = "4.9.1";
static final Logger logger = LoggerFactory.getLogger(AssetApi.class);

/** AssetApi */
Expand Down
4 changes: 2 additions & 2 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.4
* The version of the OpenAPI document: 2.11.0
* 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.3";
private String version = "4.9.1";
static final Logger logger = LoggerFactory.getLogger(BankFeedsApi.class);

/** BankFeedsApi */
Expand Down
4 changes: 2 additions & 2 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.4
* The version of the OpenAPI document: 2.11.0
* 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.3";
private String version = "4.9.1";
static final Logger logger = LoggerFactory.getLogger(FilesApi.class);

/** FilesApi */
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.4
* The version of the OpenAPI document: 2.11.0
* 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.3";
private String version = "4.9.1";
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.4
* The version of the OpenAPI document: 2.11.0
* 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.3";
private String version = "4.9.1";
static final Logger logger = LoggerFactory.getLogger(PayrollAuApi.class);

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

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

/** PayrollUkApi */
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/xero/api/client/ProjectApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Xero Projects API
* This is the Xero Projects API
*
* The version of the OpenAPI document: 2.10.4
* The version of the OpenAPI document: 2.11.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -55,7 +55,7 @@ public class ProjectApi {
private ApiClient apiClient;
private static ProjectApi instance = null;
private String userAgent = "Default";
private String version = "4.8.3";
private String version = "4.9.1";
static final Logger logger = LoggerFactory.getLogger(ProjectApi.class);

/** ProjectApi */
Expand Down
Loading

0 comments on commit 93395e5

Please sign in to comment.