Skip to content

Commit e93d1c5

Browse files
committed
Update README
add example code for passing a CustomJsonConfig class into thte AccountApi constructor.
1 parent 00ffc0e commit e93d1c5

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Add the dependency to your pom.xml. Gradle, sbt and other build tools can be fo
7474
<dependency>
7575
<groupId>com.github.xeroapi</groupId>
7676
<artifactId>xero-java</artifactId>
77-
<version>2.2.2</version>
77+
<version>2.2.3</version>
7878
</dependency>
7979

8080

@@ -156,6 +156,21 @@ You have the option to implement your own Config class and pass it as an argumen
156156

157157
An example of how you might implement Config can be found in the `/src/main/java/com/xero/example` folder named `CustomJsonConfig.java`.
158158

159+
```java
160+
try {
161+
config = new CustomJsonConfig();
162+
System.out.println("Your user agent is: " + config.getUserAgent());
163+
} catch(Exception e) {
164+
System.out.println(e.getMessage());
165+
}
166+
167+
ApiClient apiClientForAccounting = new ApiClient(config.getApiUrl(),null,null,null);
168+
169+
AccountingApi accountingApi = new AccountingApi(config);
170+
accountingApi.setApiClient(apiClientForAccounting);
171+
accountingApi.setOAuthToken(token, tokenSecret);
172+
```
173+
159174
### Spring Framework based Configuration
160175

161176
An alternative method of configuring the Xero Java SDK can be found in the `example-spring/src/main/java` folder named `SpringConfig.java`.

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.2]";
135+
return USER_AGENT + " " + CONSUMER_KEY + " [Xero-Java-2.2.3]";
136136
}
137137

138138
@Override

0 commit comments

Comments
 (0)