Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
42 changes: 13 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ The official Java client library for the [Unit API](https://unit.co/docs/api/).
## Requirements

Building the API client library requires:
1. Java 1.8+
2. Maven (3.8.3+)/Gradle (7.2+)

1. Java 11+
2. Maven/Gradle

## Installation
Add this dependency to your project's POM:
Expand All @@ -23,7 +24,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>co.unit</groupId>
<artifactId>java-sdk</artifactId>
<version>0.0.1</version>
<version>0.0.3</version>
</dependency>
</dependencies>
```
Expand All @@ -33,9 +34,8 @@ For more examples of basic usage, see the [Test suites](https://github.com/unit-

```java
String access_token = System.getenv("access_token");
ApiClient cl = new ApiClient();
cl.setBearerToken(access_token);
Configuration.setDefaultApiClient(cl);
ApiClient apiClient = new ApiClient();
apiClient.setRequestInterceptor(r -> r.header("Authorization", "Bearer " + access_token));

CreateIndividualApplication createIndividualApplication = new CreateIndividualApplication();
CreateIndividualApplicationAttributes attr = new CreateIndividualApplicationAttributes();
Expand Down Expand Up @@ -65,35 +65,19 @@ attr.setOccupation(Occupation.ARCHITECTORENGINEER);

createIndividualApplication.setAttributes(attr);

CreateApplication request = new CreateApplication();
request.data(new CreateApplicationData(createIndividualApplication));

CreateApplication ca = new CreateApplication();
ca.data(new CreateApplicationData(createIndividualApplication));

CreateApplicationApi apiClient = new CreateApplicationApi();
CreateApplicationApi createApiClient = new CreateApplicationApi(apiClient);
UnitCreateApplicationResponse res = apiClient.execute(request);
```

## About
To generate a customized version of the unit-java-sdk using our [OpenAPI project](https://github.com/unit-finance/openapi-unit-sdk)
we suggest using the open-generator-cli to generate the Java client using the following command:
```commandline
openapi-generator-cli generate -g java -i openapi.json -o unit-java-sdk
--additional-properties hideGenerationTimestamp=true
```
Please note that the current generator version lacks support for deepObjects. After generating the Java client, if you wish to enable functionality for list parameters, you'll need to implement a serialization function. A sample of this function, named `toParams()`, can be found in `client/model/ExecuteFilterParameter.java`.

Additionally, modifications need to be made to the executeCall function in each GetList file that utilizes parameters:
```java
if (page != null) {
localVarQueryParams.addAll(page.toParams());
}

if (filter != null) {
localVarQueryParams.addAll(filter.toParams());
}

if (include != null) {
localVarQueryParams.addAll(localVarApiClient.parameterToPair("include", include));
}
openapi-generator-cli generate -g java -i openapi.json -o unit
-p hideGenerationTimestamp=true -p packageName=unit.java.sdk
-p modelPackage=unit.java.sdk.model -p apiPackage=unit.java.sdk.api
--library native -p useJakartaEe=true
```
For parameters defined as deepObjects (beyond primitive types), these should be appended to localVarQueryParams after serialization using the `toParams()` function, rather than using `localVarApiClient.parameterToPair()` which is designed for primitive types exclusively.
Loading