Skip to content

Commit b7e7adb

Browse files
committed
Fix OrgId, RowType and update README
Added missing OrganisationID from the Organisation Endpoint Refactored RowType to be separate object Use new RowType object for ReportRow and ReportRow properties Update custom RSA SIgning example in README
1 parent 29102c7 commit b7e7adb

7 files changed

Lines changed: 125 additions & 57 deletions

File tree

README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,20 @@ ApiClient apiClientForAccounting = new ApiClient(config.getApiUrl(),null,null,nu
2929
AccountingApi accountingApi = new AccountingApi(apiClientForAccounting);
3030
accountingApi.setOAuthToken(token, tokenSecret);
3131

32-
// Fixed Assets API endpoints
33-
ApiClient apiClientForAssets = new ApiClient(config.getAssetsUrl(),null,null,null);
34-
AssetApi assetApi = new AssetApi(apiClientForAssets);
35-
assetApi.setOAuthToken(token, tokenSecret);
36-
3732
// BankFeeds API endpoints (for approved Partners)
3833
ApiClient apiClientForBankFeeds = new ApiClient(config.getBankFeedsUrl(),null,null,null);
3934
BankFeedsApi bankFeedsApi = new BankFeedsApi(apiClientForBankFeeds);
4035
bankFeedsApi.setOAuthToken(token, tokenSecret);
36+
37+
// Files API endpoints
38+
ApiClient apiClientForFiles = new ApiClient(config.getFilesUrl(),null,null,null);
39+
FilesApi filesApi = new FilesApi(apiClientForFiles);
40+
filesApi.setOAuthToken(token, tokenSecret);
41+
42+
// Fixed Assets API endpoints
43+
ApiClient apiClientForAssets = new ApiClient(config.getAssetsUrl(),null,null,null);
44+
AssetApi assetApi = new AssetApi(apiClientForAssets);
45+
assetApi.setOAuthToken(token, tokenSecret);
4146
```
4247

4348
### Making API calls will change as well.
@@ -74,7 +79,7 @@ Add the dependency to your pom.xml. Gradle, sbt and other build tools can be fo
7479
<dependency>
7580
<groupId>com.github.xeroapi</groupId>
7681
<artifactId>xero-java</artifactId>
77-
<version>2.2.11</version>
82+
<version>2.2.12</version>
7883
</dependency>
7984

8085

@@ -205,6 +210,20 @@ You can provide your own signing mechanism by using the `public AccountingApi(Co
205210

206211
You can also provide a `RsaSignerFactory` using the `public RsaSignerFactory(InputStream privateKeyInputStream, String privateKeyPassword)` constructor to fetch keys from any InputStream.
207212

213+
```java
214+
config = new JsonConfig("xero/config.json");
215+
216+
try (FileInputStream privateKeyStream = new FileInputStream(config.getPathToPrivateKey()))
217+
{
218+
RsaSignerFactory signerFactory = new RsaSignerFactory(privateKeyStream, config.getPrivateKeyPassword());
219+
220+
// v2
221+
ApiClient apiClientForAccounting = new ApiClient(config.getApiUrl(), null, null, null);
222+
accountingApi = new AccountingApi(config, signerFactory);
223+
accountingApi.setApiClient(apiClientForAccounting);
224+
accountingApi.setOAuthToken(config.getConsumerKey(), config.getConsumerSecret());
225+
}
226+
```
208227

209228
## Logging
210229
The SDK uses log4j2. To configure, add a log4j.properties file to the Resources directory.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.github.xeroapi</groupId>
55
<artifactId>xero-java</artifactId>
66
<packaging>jar</packaging>
7-
<version>2.2.11</version>
7+
<version>2.2.12</version>
88
<name>Xero-Java SDK</name>
99
<description>This is the official Java SDK for Xero API</description>
1010
<url>https://github.com/XeroAPI/Xero-Java</url>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public String getAccessTokenUrl() {
132132

133133
@Override
134134
public String getUserAgent() {
135-
return USER_AGENT + " " + CONSUMER_KEY + " [Xero-Java-2.2.11]";
135+
return USER_AGENT + " " + CONSUMER_KEY + " [Xero-Java-2.2.12]";
136136
}
137137

138138
@Override

src/main/java/com/xero/models/accounting/Organisation.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import io.swagger.annotations.ApiModelProperty;
3030
import java.util.ArrayList;
3131
import java.util.List;
32+
import java.util.UUID;
3233
import org.threeten.bp.LocalDate;
3334
import org.threeten.bp.OffsetDateTime;
3435

@@ -40,6 +41,10 @@
4041

4142
public class Organisation {
4243

44+
@JsonProperty("OrganisationID")
45+
private UUID organisationID = null;
46+
47+
4348
@JsonProperty("APIKey")
4449
private String apIKey = null;
4550

@@ -463,6 +468,24 @@ public static PropertyClassEnum fromValue(String text) {
463468
@JsonProperty("PaymentTerms")
464469
private PaymentTerm paymentTerms = null;
465470

471+
public Organisation organisationID(UUID organisationID) {
472+
this.organisationID = organisationID;
473+
return this;
474+
}
475+
476+
/**
477+
* Unique Xero identifier
478+
* @return organisationID
479+
**/
480+
@ApiModelProperty(example = "8be9db36-3598-4755-ba5c-c2dbc8c4a7a2", value = "Unique Xero identifier")
481+
public UUID getOrganisationID() {
482+
return organisationID;
483+
}
484+
485+
public void setOrganisationID(UUID organisationID) {
486+
this.organisationID = organisationID;
487+
}
488+
466489
public Organisation apIKey(String apIKey) {
467490
this.apIKey = apIKey;
468491
return this;
@@ -1037,7 +1060,8 @@ public boolean equals(java.lang.Object o) {
10371060
return false;
10381061
}
10391062
Organisation organisation = (Organisation) o;
1040-
return Objects.equals(this.apIKey, organisation.apIKey) &&
1063+
return Objects.equals(this.organisationID, organisation.organisationID) &&
1064+
Objects.equals(this.apIKey, organisation.apIKey) &&
10411065
Objects.equals(this.name, organisation.name) &&
10421066
Objects.equals(this.legalName, organisation.legalName) &&
10431067
Objects.equals(this.paysTax, organisation.paysTax) &&
@@ -1071,7 +1095,7 @@ public boolean equals(java.lang.Object o) {
10711095

10721096
@Override
10731097
public int hashCode() {
1074-
return Objects.hash(apIKey, name, legalName, paysTax, version, organisationType, baseCurrency, countryCode, isDemoCompany, organisationStatus, registrationNumber, taxNumber, financialYearEndDay, financialYearEndMonth, salesTaxBasis, salesTaxPeriod, defaultSalesTax, defaultPurchasesTax, periodLockDate, endOfYearLockDate, createdDateUTC, timezone, organisationEntityType, shortCode, propertyClass, lineOfBusiness, addresses, phones, externalLinks, paymentTerms);
1098+
return Objects.hash(organisationID, apIKey, name, legalName, paysTax, version, organisationType, baseCurrency, countryCode, isDemoCompany, organisationStatus, registrationNumber, taxNumber, financialYearEndDay, financialYearEndMonth, salesTaxBasis, salesTaxPeriod, defaultSalesTax, defaultPurchasesTax, periodLockDate, endOfYearLockDate, createdDateUTC, timezone, organisationEntityType, shortCode, propertyClass, lineOfBusiness, addresses, phones, externalLinks, paymentTerms);
10751099
}
10761100

10771101

@@ -1080,6 +1104,7 @@ public String toString() {
10801104
StringBuilder sb = new StringBuilder();
10811105
sb.append("class Organisation {\n");
10821106

1107+
sb.append(" organisationID: ").append(toIndentedString(organisationID)).append("\n");
10831108
sb.append(" apIKey: ").append(toIndentedString(apIKey)).append("\n");
10841109
sb.append(" name: ").append(toIndentedString(name)).append("\n");
10851110
sb.append(" legalName: ").append(toIndentedString(legalName)).append("\n");

src/main/java/com/xero/models/accounting/ReportRow.java

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.fasterxml.jackson.annotation.JsonCreator;
2020
import com.fasterxml.jackson.annotation.JsonValue;
2121
import com.xero.models.accounting.ReportCell;
22+
import com.xero.models.accounting.RowType;
2223
import io.swagger.annotations.ApiModel;
2324
import io.swagger.annotations.ApiModelProperty;
2425
import java.util.ArrayList;
@@ -31,48 +32,9 @@
3132
*/
3233

3334
public class ReportRow {
34-
/**
35-
* Gets or Sets rowType
36-
*/
37-
public enum RowTypeEnum {
38-
HEADER("HEADER"),
39-
40-
SECTION("SECTION"),
41-
42-
ROW("ROW"),
43-
44-
EMPTY("");
45-
46-
private String value;
47-
48-
RowTypeEnum(String value) {
49-
this.value = value;
50-
}
51-
52-
@JsonValue
53-
public String getValue() {
54-
return value;
55-
}
56-
57-
@Override
58-
public String toString() {
59-
return String.valueOf(value);
60-
}
61-
62-
@JsonCreator
63-
public static RowTypeEnum fromValue(String text) {
64-
for (RowTypeEnum b : RowTypeEnum.values()) {
65-
if (String.valueOf(b.value).equals(text)) {
66-
return b;
67-
}
68-
}
69-
throw new IllegalArgumentException("Unexpected value '" + text + "'");
70-
}
71-
}
72-
7335

7436
@JsonProperty("RowType")
75-
private RowTypeEnum rowType = null;
37+
private RowType rowType = null;
7638

7739

7840
@JsonProperty("Title")
@@ -82,7 +44,7 @@ public static RowTypeEnum fromValue(String text) {
8244
@JsonProperty("Cells")
8345
private List<ReportCell> cells = null;
8446

85-
public ReportRow rowType(RowTypeEnum rowType) {
47+
public ReportRow rowType(RowType rowType) {
8648
this.rowType = rowType;
8749
return this;
8850
}
@@ -92,11 +54,11 @@ public ReportRow rowType(RowTypeEnum rowType) {
9254
* @return rowType
9355
**/
9456
@ApiModelProperty(value = "")
95-
public RowTypeEnum getRowType() {
57+
public RowType getRowType() {
9658
return rowType;
9759
}
9860

99-
public void setRowType(RowTypeEnum rowType) {
61+
public void setRowType(RowType rowType) {
10062
this.rowType = rowType;
10163
}
10264

src/main/java/com/xero/models/accounting/ReportRows.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.fasterxml.jackson.annotation.JsonValue;
2121
import com.xero.models.accounting.ReportCell;
2222
import com.xero.models.accounting.ReportRow;
23+
import com.xero.models.accounting.RowType;
2324
import io.swagger.annotations.ApiModel;
2425
import io.swagger.annotations.ApiModelProperty;
2526
import java.util.ArrayList;
@@ -34,7 +35,7 @@
3435
public class ReportRows {
3536

3637
@JsonProperty("RowType")
37-
private String rowType = null;
38+
private RowType rowType = null;
3839

3940

4041
@JsonProperty("Title")
@@ -48,7 +49,7 @@ public class ReportRows {
4849
@JsonProperty("Rows")
4950
private List<ReportRow> rows = null;
5051

51-
public ReportRows rowType(String rowType) {
52+
public ReportRows rowType(RowType rowType) {
5253
this.rowType = rowType;
5354
return this;
5455
}
@@ -58,11 +59,11 @@ public ReportRows rowType(String rowType) {
5859
* @return rowType
5960
**/
6061
@ApiModelProperty(value = "")
61-
public String getRowType() {
62+
public RowType getRowType() {
6263
return rowType;
6364
}
6465

65-
public void setRowType(String rowType) {
66+
public void setRowType(RowType rowType) {
6667
this.rowType = rowType;
6768
}
6869

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Accounting API
3+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4+
*
5+
* OpenAPI spec version: 2.0.0
6+
* Contact: api@xero.com
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package com.xero.models.accounting;
15+
16+
import java.util.Objects;
17+
import java.util.Arrays;
18+
19+
import com.fasterxml.jackson.annotation.JsonCreator;
20+
import com.fasterxml.jackson.annotation.JsonValue;
21+
22+
/**
23+
* Gets or Sets RowType
24+
*/
25+
public enum RowType {
26+
27+
HEADER("Header"),
28+
29+
SECTION("Section"),
30+
31+
ROW("Row"),
32+
33+
SUMMARYROW("SummaryRow");
34+
35+
private String value;
36+
37+
RowType(String value) {
38+
this.value = value;
39+
}
40+
41+
@JsonValue
42+
public String getValue() {
43+
return value;
44+
}
45+
46+
@Override
47+
public String toString() {
48+
return String.valueOf(value);
49+
}
50+
51+
@JsonCreator
52+
public static RowType fromValue(String text) {
53+
for (RowType b : RowType.values()) {
54+
if (String.valueOf(b.value).equals(text)) {
55+
return b;
56+
}
57+
}
58+
throw new IllegalArgumentException("Unexpected value '" + text + "'");
59+
}
60+
}
61+

0 commit comments

Comments
 (0)