Skip to content

Commit 93395e5

Browse files
authored
Merge pull request #283 from XeroAPI/sid-development
Build from OpenAPI spec 2.11.0
2 parents 89737f4 + ebdec73 commit 93395e5

File tree

18 files changed

+158
-31
lines changed

18 files changed

+158
-31
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,21 @@ public class TokenRefresh {
600600
}
601601
```
602602

603+
**Revoking Tokens**
604+
You can revoke a user's refresh token and remove all their connections to your app by making a request to the revocation endpoint.
605+
606+
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
607+
608+
```java
609+
try {
610+
ApiClient apiClient = new ApiClient();
611+
HttpResponse revokeResponse = apiClient.revoke(clientId, clientSecret, refreshToken);
612+
System.out.println("Revoke success: " + revokeResponse.getStatusCode());
613+
} catch (Exception e) {
614+
System.out.println(e.getMessage());
615+
}
616+
```
617+
603618
**Data Endpoints**
604619

605620
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.

docs/v4/accounting/index.html

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3662,7 +3662,6 @@
36623662
"type" : "number",
36633663
"description" : "The calculated tax amount based on the TaxType and LineAmount",
36643664
"format" : "double",
3665-
"readOnly" : true,
36663665
"example" : 0.0,
36673666
"x-is-money" : true
36683667
},
@@ -5813,7 +5812,7 @@
58135812
<nav id="scrollingNav">
58145813
<ul class="sidenav nav nav-list">
58155814
<li class="nav-header" data-group="Accounting"><strong>SDK: </strong><span id='sdk-name'></span></li>
5816-
<li class="nav-header" data-group="Accounting"><strong>VSN: </strong>4.8.3</li>
5815+
<li class="nav-header" data-group="Accounting"><strong>VSN: </strong>4.9.1</li>
58175816
<li class="nav-header" data-group="Accounting"><a href="#api-Accounting">Methods</a></li>
58185817
<li data-group="Accounting" data-name="createAccount" class="">
58195818
<a href="#api-Accounting-createAccount">createAccount</a>
@@ -22097,9 +22096,10 @@ <h3>Usage and SDK Samples</h3>
2209722096
array[UUID] iDs = &quot;00000000-0000-0000-0000-000000000000&quot;;
2209822097
Integer page = 1;
2209922098
Boolean includeArchived = true;
22099+
Boolean summaryOnly = true;
2210022100

2210122101
try {
22102-
Contacts result = apiInstance.getContacts(accessToken, xeroTenantId, ifModifiedSince, where, order, iDs, page, includeArchived);
22102+
Contacts result = apiInstance.getContacts(accessToken, xeroTenantId, ifModifiedSince, where, order, iDs, page, includeArchived, summaryOnly);
2210322103
System.out.println(result);
2210422104
} catch (XeroException e) {
2210522105
System.err.println("Exception when calling AccountingApi#getContacts");
@@ -22279,6 +22279,26 @@ <h2>Parameters</h2>
2227922279
</div>
2228022280
</div>
2228122281
</td>
22282+
</tr>
22283+
22284+
<tr><td style="width:150px;">summaryOnly</td>
22285+
<td>
22286+
22287+
22288+
<div id="d2e199_getContacts_summaryOnly">
22289+
<div class="json-schema-view">
22290+
<div class="primitive">
22291+
<span class="type">
22292+
Boolean
22293+
</span>
22294+
22295+
<div class="inner description marked">
22296+
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.
22297+
</div>
22298+
</div>
22299+
</div>
22300+
</div>
22301+
</td>
2228222302
</tr>
2228322303

2228422304
</table>

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>xero-java</artifactId>
66
<packaging>jar</packaging>
77
<name>xero-java</name>
8-
<version>4.8.3</version>
8+
<version>4.9.1</version>
99
<url>https://github.com/XeroAPI/Xero-Java</url>
1010
<description>This is the official Java SDK for Xero API</description>
1111
<licenses>
@@ -68,7 +68,7 @@
6868
<dependency>
6969
<groupId>commons-io</groupId>
7070
<artifactId>commons-io</artifactId>
71-
<version>2.5</version>
71+
<version>2.7</version>
7272
</dependency>
7373
<dependency>
7474
<groupId>javax.servlet</groupId>

src/main/java/com/xero/api/ApiClient.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
import org.threeten.bp.*;
1010
import com.google.api.client.googleapis.util.Utils;
1111
import com.google.api.client.http.AbstractHttpContent;
12+
import com.google.api.client.http.ByteArrayContent;
13+
import com.google.api.client.http.GenericUrl;
14+
import com.google.api.client.http.HttpContent;
15+
import com.google.api.client.http.HttpHeaders;
16+
import com.google.api.client.http.HttpMethods;
17+
import com.google.api.client.http.HttpResponse;
1218
import com.google.api.client.http.HttpRequestFactory;
1319
import com.google.api.client.http.HttpRequestInitializer;
1420
import com.google.api.client.http.HttpTransport;
@@ -26,6 +32,7 @@
2632
import com.auth0.jwt.interfaces.DecodedJWT;
2733
import java.net.MalformedURLException;
2834
import java.net.URL;
35+
import java.nio.charset.StandardCharsets;
2936
import java.security.interfaces.RSAPublicKey;
3037

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

195202
return verifiedJWT;
196203
}
197-
204+
205+
/** method for revoking a refresh token
206+
* @param refreshToken String the refresh token used to obtain a new access token via the API
207+
* @param clientId String the client id used to authtenticate with the API
208+
* @param clientSecret String the client secret used to authtenticate with the API
209+
* @return revokeResponse HttpResponse a successful revocation request will return a 200 response with an empty body.
210+
*/
211+
public HttpResponse revoke(String clientId, String clientSecret, String refreshToken) throws IOException {
212+
213+
// BASIC AUTHENTICATION HEADER
214+
HttpHeaders headers = new HttpHeaders();
215+
headers.setBasicAuthentication(clientId, clientSecret);
216+
217+
// POST BODY WITH REFRESH TOKEN
218+
String urlParameters = "token=" + refreshToken;
219+
byte[] postData = urlParameters.getBytes( StandardCharsets.UTF_8 );
220+
HttpContent content = new ByteArrayContent("application/x-www-form-urlencoded", postData);
221+
222+
// REVOKE URL DEFINED
223+
GenericUrl url = new GenericUrl("https://identity.xero.com/connect/revocation");
224+
225+
HttpTransport transport = this.getHttpTransport();
226+
HttpRequestFactory requestFactory = transport.createRequestFactory();
227+
HttpResponse revokeResponse = requestFactory
228+
.buildRequest(HttpMethods.POST, url, content)
229+
.setHeaders(headers)
230+
.setConnectTimeout(this.getConnectionTimeout())
231+
.setReadTimeout(this.getReadTimeout())
232+
.execute();
233+
234+
return revokeResponse;
235+
}
198236
}

src/main/java/com/xero/api/client/AccountingApi.java

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Xero Accounting API
33
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
44
*
5-
* The version of the OpenAPI document: 2.10.4
5+
* The version of the OpenAPI document: 2.11.0
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -98,7 +98,7 @@ public class AccountingApi {
9898
private ApiClient apiClient;
9999
private static AccountingApi instance = null;
100100
private String userAgent = "Default";
101-
private String version = "4.8.3";
101+
private String version = "4.9.1";
102102
static final Logger logger = LoggerFactory.getLogger(AccountingApi.class);
103103

104104
/** AccountingApi */
@@ -12453,6 +12453,9 @@ public HttpResponse getContactHistoryForHttpResponse(
1245312453
* @param page e.g. page&#x3D;1 - Up to 100 contacts will be returned in a single API call.
1245412454
* @param includeArchived e.g. includeArchived&#x3D;true - Contacts with a status of ARCHIVED will
1245512455
* be included in the response
12456+
* @param summaryOnly Use summaryOnly&#x3D;true in GET Contacts endpoint to retrieve a smaller
12457+
* version of the response object. This returns only lightweight fields, excluding
12458+
* computation-heavy fields from the response, making the API calls quick and efficient.
1245612459
* @param accessToken Authorization token for user set in header of each request
1245712460
* @return Contacts
1245812461
* @throws IOException if an error occurs while attempting to invoke the API *
@@ -12465,13 +12468,22 @@ public Contacts getContacts(
1246512468
String order,
1246612469
List<UUID> ids,
1246712470
Integer page,
12468-
Boolean includeArchived)
12471+
Boolean includeArchived,
12472+
Boolean summaryOnly)
1246912473
throws IOException {
1247012474
try {
1247112475
TypeReference<Contacts> typeRef = new TypeReference<Contacts>() {};
1247212476
HttpResponse response =
1247312477
getContactsForHttpResponse(
12474-
accessToken, xeroTenantId, ifModifiedSince, where, order, ids, page, includeArchived);
12478+
accessToken,
12479+
xeroTenantId,
12480+
ifModifiedSince,
12481+
where,
12482+
order,
12483+
ids,
12484+
page,
12485+
includeArchived,
12486+
summaryOnly);
1247512487
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
1247612488
} catch (HttpResponseException e) {
1247712489
if (logger.isDebugEnabled()) {
@@ -12503,6 +12515,9 @@ public Contacts getContacts(
1250312515
* @param page e.g. page&#x3D;1 - Up to 100 contacts will be returned in a single API call.
1250412516
* @param includeArchived e.g. includeArchived&#x3D;true - Contacts with a status of ARCHIVED will
1250512517
* be included in the response
12518+
* @param summaryOnly Use summaryOnly&#x3D;true in GET Contacts endpoint to retrieve a smaller
12519+
* version of the response object. This returns only lightweight fields, excluding
12520+
* computation-heavy fields from the response, making the API calls quick and efficient.
1250612521
* @param accessToken Authorization token for user set in header of each request
1250712522
* @return HttpResponse
1250812523
* @throws IOException if an error occurs while attempting to invoke the API
@@ -12515,7 +12530,8 @@ public HttpResponse getContactsForHttpResponse(
1251512530
String order,
1251612531
List<UUID> ids,
1251712532
Integer page,
12518-
Boolean includeArchived)
12533+
Boolean includeArchived,
12534+
Boolean summaryOnly)
1251912535
throws IOException {
1252012536
// verify the required parameter 'xeroTenantId' is set
1252112537
if (xeroTenantId == null) {
@@ -12589,6 +12605,17 @@ public HttpResponse getContactsForHttpResponse(
1258912605
uriBuilder = uriBuilder.queryParam(key, value);
1259012606
}
1259112607
}
12608+
if (summaryOnly != null) {
12609+
String key = "summaryOnly";
12610+
Object value = summaryOnly;
12611+
if (value instanceof Collection) {
12612+
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
12613+
} else if (value instanceof Object[]) {
12614+
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
12615+
} else {
12616+
uriBuilder = uriBuilder.queryParam(key, value);
12617+
}
12618+
}
1259212619
String url = uriBuilder.build().toString();
1259312620
GenericUrl genericUrl = new GenericUrl(url);
1259412621
if (logger.isDebugEnabled()) {

src/main/java/com/xero/api/client/AssetApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Xero Assets API
33
* 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.
44
*
5-
* The version of the OpenAPI document: 2.10.4
5+
* The version of the OpenAPI document: 2.11.0
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -48,7 +48,7 @@ public class AssetApi {
4848
private ApiClient apiClient;
4949
private static AssetApi instance = null;
5050
private String userAgent = "Default";
51-
private String version = "4.8.3";
51+
private String version = "4.9.1";
5252
static final Logger logger = LoggerFactory.getLogger(AssetApi.class);
5353

5454
/** AssetApi */

src/main/java/com/xero/api/client/BankFeedsApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Xero Bank Feeds API
33
* 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.
44
*
5-
* The version of the OpenAPI document: 2.10.4
5+
* The version of the OpenAPI document: 2.11.0
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -46,7 +46,7 @@ public class BankFeedsApi {
4646
private ApiClient apiClient;
4747
private static BankFeedsApi instance = null;
4848
private String userAgent = "Default";
49-
private String version = "4.8.3";
49+
private String version = "4.9.1";
5050
static final Logger logger = LoggerFactory.getLogger(BankFeedsApi.class);
5151

5252
/** BankFeedsApi */

src/main/java/com/xero/api/client/FilesApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Xero Files API
33
* These endpoints are specific to Xero Files API
44
*
5-
* The version of the OpenAPI document: 2.10.4
5+
* The version of the OpenAPI document: 2.11.0
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -53,7 +53,7 @@ public class FilesApi {
5353
private ApiClient apiClient;
5454
private static FilesApi instance = null;
5555
private String userAgent = "Default";
56-
private String version = "4.8.3";
56+
private String version = "4.9.1";
5757
static final Logger logger = LoggerFactory.getLogger(FilesApi.class);
5858

5959
/** FilesApi */

src/main/java/com/xero/api/client/IdentityApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Xero OAuth 2 Identity Service API
33
* These endpoints are related to managing authentication tokens and identity for Xero API
44
*
5-
* The version of the OpenAPI document: 2.10.4
5+
* The version of the OpenAPI document: 2.11.0
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -44,7 +44,7 @@ public class IdentityApi {
4444
private ApiClient apiClient;
4545
private static IdentityApi instance = null;
4646
private String userAgent = "Default";
47-
private String version = "4.8.3";
47+
private String version = "4.9.1";
4848
static final Logger logger = LoggerFactory.getLogger(IdentityApi.class);
4949

5050
/** IdentityApi */

src/main/java/com/xero/api/client/PayrollAuApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Xero Payroll AU API
33
* This is the Xero Payroll API for orgs in Australia region.
44
*
5-
* The version of the OpenAPI document: 2.10.4
5+
* The version of the OpenAPI document: 2.11.0
66
* Contact: [email protected]
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -63,7 +63,7 @@ public class PayrollAuApi {
6363
private ApiClient apiClient;
6464
private static PayrollAuApi instance = null;
6565
private String userAgent = "Default";
66-
private String version = "4.8.3";
66+
private String version = "4.9.1";
6767
static final Logger logger = LoggerFactory.getLogger(PayrollAuApi.class);
6868

6969
/** PayrollAuApi */

0 commit comments

Comments
 (0)