IMPORTANT: development is still in progress
A Kotlin based Client implementation for accessing the Xero File API which is heavily based on the Zalando Riptide HTTP client and inspired by XeroJava.
Please note that the implementation has not been fully completed but all Files and Associations endpoints can be accessed with the client.
- JVM >= 1.8
- Kotlin >= 1.2.61
<dependencies>
<dependency>
<groupId>com.github.xamatech</groupId>
<artifactId>xama-xero-client</artifactId>
<version>{xama-xero-client-version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
The Associations
and the Files
related client requires a Zalando Riptide HTTP
client instance. Please consider the Zalando Riptide documentation
for its configuration. The Xama Xero Client
provides utility methods to apply the required settings:
final ObjectMapper objectMapper = ConfigUtilsKt.configureObjectMapper(new Jackson2ObjectMapperBuilder()).build();
final Http http = ConfigUtilsKt.configureHttp(
Http.builder().requestFactory(
new RestAsyncClientHttpRequestFactory(httpClient, executor)),
objectMapper
)
.build();
final ObjectMapper objectMapper = ConfigUtilsKt.configureObjectMapper(new Jackson2ObjectMapperBuilder()).build();
final Http http = ConfigUtilsKt.configureHttp(
Http.builder().requestFactory(
new RestAsyncClientHttpRequestFactory(httpClient, executor)),
objectMapper
)
.build();
final FilesClient client = new FilesClient(http);
final Credentials credentials = new Credentials("<accessToken>", tenantId, "myUserAgent");
final CompletableFuture<FileDto> future = client.uploadFile(credentials, "test.jpg", "file:///tmp/test.jpeg");
final FileDto file = Completion.join(future);
final AssociationsClient associationsClient = new AssociationsClient(http);
Completion.join(associationsClient.createAssociation(
credentials,
file.getId(),
UUID.fromString("193FDBDA-4738-4AEA-8382-DFAF32F819B0"), // Xero Bank Transaction Id
Associations.ObjectGroup.BANKTRANSACTION
));
Note: you can find examples for each functionality in our tests.
This project is licensed under the MIT License - see the LICENSE.md file for details