Skip to content

Commit 87b008c

Browse files
Merge pull request #140 from onfido/release-upgrade
Refresh onfido-java after onfido-openapi-spec update (be823e7)
2 parents 0b96824 + aaf265f commit 87b008c

File tree

11 files changed

+132
-33
lines changed

11 files changed

+132
-33
lines changed

.release.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"source": {
33
"repo_url": "https://github.com/onfido/onfido-openapi-spec",
4-
"short_sha": "54ce45f",
5-
"long_sha": "54ce45f2138f044cc5cb40f6904dc7bc1a675be6",
6-
"version": "v4.5.0"
4+
"short_sha": "be823e7",
5+
"long_sha": "be823e7815c93bfbfc3fb764c0548f57cb851fe9",
6+
"version": "v4.6.0"
77
},
8-
"release": "v5.5.0"
8+
"release": "v5.6.0"
99
}

README.md

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
The official Java library for integrating with the Onfido API.
44

5-
Documentation can be found at <https://documentation.onfido.com>.
5+
Documentation is available at <https://documentation.onfido.com>.
66

7-
This library is only for use on the backend, as it uses Onfido API tokens which must be kept secret. If you do need to collect applicant data in the frontend of your application, we recommend that you use the Onfido SDKs: [iOS](https://github.com/onfido/onfido-ios-sdk), [Android](https://github.com/onfido/onfido-android-sdk), [Web](https://github.com/onfido/onfido-sdk-ui), and [React Native](https://github.com/onfido/react-native-sdk).
7+
This library is for backend use only, as it requires secret Onfido API tokens and should not be used in the frontend due to security reasons.
88

9-
This version uses Onfido API v3.6. Refer to our [API versioning guide](https://developers.onfido.com/guide/api-versioning-policy#client-libraries) for details of which client library versions use which versions of the API.
9+
If you need to collect applicant data in the frontend of your application, we recommend that you use the Onfido SDKs:
10+
11+
- [iOS](https://github.com/onfido/onfido-ios-sdk)
12+
- [Android](https://github.com/onfido/onfido-android-sdk)
13+
- [Web](https://github.com/onfido/onfido-sdk-ui)
14+
- [React Native](https://github.com/onfido/react-native-sdk)
15+
16+
This version uses Onfido API v3.6. Refer to our [API versioning guide](https://developers.onfido.com/guide/api-versioning-policy#client-libraries) for details. The guide explains which client library versions use which API versions.
1017

1118
![Build Status](https://github.com/onfido/onfido-java/actions/workflows/maven.yml/badge.svg)
1219

@@ -33,7 +40,7 @@ To deploy it to a remote Maven repository instead, configure the settings of the
3340
mvn clean deploy
3441
```
3542

36-
Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information.
43+
Refer to the [OSSRH Guide](https://central.sonatype.org/publish/publish-guide) for more information.
3744

3845
#### Maven users
3946

@@ -43,7 +50,7 @@ Add this dependency to your project's POM:
4350
<dependency>
4451
<groupId>com.onfido</groupId>
4552
<artifactId>onfido-api-java</artifactId>
46-
<version>5.5.0</version>
53+
<version>5.6.0</version>
4754
<scope>compile</scope>
4855
</dependency>
4956
```
@@ -59,7 +66,7 @@ Add this dependency to your project's build file:
5966
}
6067
6168
dependencies {
62-
implementation "com.onfido:onfido-api-java:5.5.0"
69+
implementation "com.onfido:onfido-api-java:5.6.0"
6370
}
6471
```
6572

@@ -73,10 +80,10 @@ mvn clean package
7380

7481
Then manually install the following JARs:
7582

76-
- `target/onfido-api-java-5.5.0.jar`
83+
- `target/onfido-api-java-5.6.0.jar`
7784
- `target/lib/*.jar`
7885

79-
The latest version can be found at: https://search.maven.org/artifact/com.onfido/5.5.0
86+
The latest version can be found at <https://search.maven.org/artifact/com.onfido/onfido-api-java/5.6.0/jar>.
8087

8188
## Getting Started
8289

@@ -98,10 +105,11 @@ DefaultApi onfido = new DefaultApi(Configuration.getDefaultApiClient()
98105
.setApiToken(System.getenv("ONFIDO_API_TOKEN"))
99106
.setRegion(Region.EU) // Supports `EU`, `US` and `CA`
100107
.setConnectTimeout(60_000)
101-
.setReadTimeout(60_000));
108+
.setReadTimeout(60_000)
109+
.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port)))); // Optionally define a connection proxy with the specified host and port
102110
```
103111

104-
NB: by default, timeout values are set to 30 seconds.
112+
NB: By default, the connection and read timeout values are set to 30 seconds. You can adjust these values as shown in the configuration section.
105113

106114
### Making a call to the API
107115

@@ -111,7 +119,7 @@ Most of the request bodies can be created using a builder pattern, this would lo
111119
new ApplicantBuilder().firstName("First").lastName("Last");
112120
```
113121

114-
The above will return an `Applicant.Request` object that can be provided to the `create()` method as the request body, so a full call to to the API will look something like:
122+
The above will return an `ApplicantBuilder` object that can be provided to the `createApplicant()` method as the request body, a full call to the API will look something like:
115123

116124
```java
117125
try {
@@ -136,7 +144,7 @@ try {
136144

137145
### Webhook event verification
138146

139-
Webhook events payload needs to be verified before it can be accessed. Library allows to easily decode the payload and verify its signature before returning it as an object for user convenience:
147+
Webhook events payload needs to be verified before it can be accessed. Verifying webhook payloads is crucial for security reasons, as it ensures that the payloads are indeed from Onfido and have not been tampered with. The library allows you to easily decode the payload and verify its signature before returning it as an object for user convenience:
140148

141149
```java
142150
try {
@@ -156,45 +164,47 @@ try {
156164

157165
### Don't share DefaultApi among different threads
158166

159-
It's recommended to create an instance of `DefaultApi` per thread in a multithreaded environment to avoid any potential issues.
167+
It's recommended to create an instance of `DefaultApi` per thread in a multithreaded environment to avoid potential issues.
160168

161169
#### Do not use additional properties
162170

163-
Retain from using `getAdditionalProperty()` or `getAdditionalProperties()` methods to access not defined properties to avoid breaking changes when these fields will appear.
171+
Except for retrieving Task object's outputs, avoid using `getAdditionalProperty()` or `getAdditionalProperties()` methods to access undefined properties to prevent breaking changes when these fields appear.
164172

165173
## Contributing
166174

167-
This library is automatically generated using [OpenAPI Generator](https://openapi-generator.tech) (version: 7.9.0); therefore all the contributions, except tests files, should target [Onfido OpenAPI specification repository](https://github.com/onfido/onfido-openapi-spec/tree/master) instead of this repository.
175+
This library is automatically generated using [OpenAPI Generator](https://openapi-generator.tech) (version: 7.9.0); therefore, all contributions (except test files) should target the [Onfido OpenAPI specification repository](https://github.com/onfido/onfido-openapi-spec/tree/master) instead of this repository. Please follow the contribution guidelines provided in the OpenAPI specification repository.
168176

169177
For contributions to the tests instead, please follow the steps below:
170178

171-
1. [Fork](https://github.com/onfido/onfido-java/fork) repository
179+
1. Fork the [repository](https://github.com/onfido/onfido-java/fork)
172180
2. Create your feature branch (`git checkout -b my-new-feature`)
173181
3. Make your changes
174-
4. Commit your changes (`git commit -am 'Add some feature'`)
182+
4. Commit your changes (`git commit -am 'Add detailed description of the feature'`)
175183
5. Push to the branch (`git push origin my-new-feature`)
176184
6. Create a new Pull Request
177185

178186
## Versioning policy
179187

180-
[Semantic Versioning](https://semver.org) policy is used for library versioning, following guidelines and limitations below:
188+
Versioning helps manage changes and ensures compatibility across different versions of the library.
189+
190+
[Semantic Versioning](https://semver.org) policy is used for library versioning, following the guidelines and limitations outlined below:
181191

182-
- MAJOR versions (x.0.0) might:
192+
- MAJOR versions (x.0.0) may:
183193
- target a new API version
184194
- include non-backward compatible change
185-
- MINOR versions (0.x.0) might:
195+
- MINOR versions (0.x.0) may:
186196
- add a new functionality, non-mandatory parameter or property
187197
- deprecate an old functionality
188198
- include non-backward compatible change to a functionality which is:
189199
- labelled as alpha or beta
190200
- completely broken and not usable
191-
- PATCH version (0.0.x) might:
201+
- PATCH version (0.0.x) will:
192202
- fix a bug
193203
- include backward compatible changes only
194204

195205
## More documentation
196206

197-
More documentation and code examples can be found at <https://documentation.onfido.com>.
207+
Additional documentation and code examples can be found at <https://documentation.onfido.com>.
198208

199209
## Support
200210

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'java'
44
apply plugin: 'com.diffplug.spotless'
55

66
group = 'com.onfido'
7-
version = '5.5.0'
7+
version = '5.6.0'
88

99
buildscript {
1010
repositories {

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ lazy val root = (project in file(".")).
22
settings(
33
organization := "com.onfido",
44
name := "onfido-api-java",
5-
version := "5.5.0",
5+
version := "5.6.0",
66
scalaVersion := "2.11.4",
77
scalacOptions ++= Seq("-feature"),
88
javacOptions in compile ++= Seq("-Xlint:deprecation"),

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>onfido-api-java</artifactId>
66
<packaging>jar</packaging>
77
<name>onfido-api-java</name>
8-
<version>5.5.0</version>
8+
<version>5.6.0</version>
99
<url>https://documentation.onfido.com</url>
1010
<description>Official Java API client library for the Onfido API</description>
1111
<scm>

src/main/java/com/onfido/ApiClient.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import java.util.function.Supplier;
5151
import java.util.regex.Matcher;
5252
import java.util.regex.Pattern;
53+
import java.net.Proxy;
5354

5455
import com.onfido.auth.Authentication;
5556
import com.onfido.auth.HttpBasicAuth;
@@ -160,7 +161,7 @@ private void init() {
160161
json = new JSON();
161162

162163
// Set default User-Agent.
163-
setUserAgent("onfido-java/5.5.0");
164+
setUserAgent("onfido-java/5.6.0");
164165

165166
authentications = new HashMap<String, Authentication>();
166167
}
@@ -406,12 +407,24 @@ protected void setApiKey(String apiKey) {
406407

407408

408409

410+
/**
411+
* Sets the Api Token.
412+
*
413+
* @param apiToken a String with the api token
414+
* @return Api client
415+
*/
409416
public ApiClient setApiToken(String apiToken) {
410417
this.setApiKey("Token token=" + apiToken);
411418

412419
return this;
413420
}
414421

422+
/**
423+
* Sets the region.
424+
*
425+
* @param region a Region enum value
426+
* @return Api client
427+
*/
415428
public ApiClient setRegion(Region region) {
416429
Map<String, String> serverVariables = getServerVariables();
417430

@@ -425,6 +438,27 @@ public ApiClient setRegion(Region region) {
425438
return this;
426439
}
427440

441+
/**
442+
* Return the HTTP proxy used by connections.
443+
*
444+
* @return Proxy
445+
*/
446+
public Proxy getProxy() {
447+
return httpClient.proxy();
448+
}
449+
450+
/**
451+
* Sets the HTTP proxy that will be used by connections.
452+
*
453+
* @param proxy a Proxy object
454+
* @return Api client
455+
*/
456+
public ApiClient setProxy(Proxy proxy) {
457+
httpClient = httpClient.newBuilder().proxy(proxy).build();
458+
return this;
459+
}
460+
461+
428462
/**
429463
* Helper method to set access token for the first OAuth2 authentication.
430464
*

src/main/java/com/onfido/Configuration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0")
1717
public class Configuration {
18-
public static final String VERSION = "5.5.0";
18+
public static final String VERSION = "5.6.0";
1919

2020
private static ApiClient defaultApiClient = new ApiClient();
2121

src/main/java/com/onfido/model/IdNumber.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public enum TypeEnum {
6363

6464
IDENTITY_CARD("identity_card"),
6565

66+
DRIVING_LICENSE("driving_license"),
67+
6668
DRIVING_LICENCE("driving_licence"),
6769

6870
SHARE_CODE("share_code"),

src/main/java/com/onfido/model/WebhookEventPayloadResource.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ public class WebhookEventPayloadResource {
117117
@SerializedName(SERIALIZED_NAME_ERROR)
118118
private WorkflowRunError error;
119119

120+
public static final String SERIALIZED_NAME_CUSTOMER_USER_ID = "customer_user_id";
121+
@SerializedName(SERIALIZED_NAME_CUSTOMER_USER_ID)
122+
private String customerUserId;
123+
120124
public WebhookEventPayloadResource() {
121125
}
122126

@@ -412,6 +416,25 @@ public void setError(WorkflowRunError error) {
412416
this.error = error;
413417
}
414418

419+
420+
public WebhookEventPayloadResource customerUserId(String customerUserId) {
421+
this.customerUserId = customerUserId;
422+
return this;
423+
}
424+
425+
/**
426+
* Customer-provided user identifier.
427+
* @return customerUserId
428+
*/
429+
@javax.annotation.Nullable
430+
public String getCustomerUserId() {
431+
return customerUserId;
432+
}
433+
434+
public void setCustomerUserId(String customerUserId) {
435+
this.customerUserId = customerUserId;
436+
}
437+
415438
/**
416439
* A container for additional, undeclared properties.
417440
* This is a holder for any undeclared properties as specified with
@@ -481,7 +504,8 @@ public boolean equals(Object o) {
481504
Objects.equals(this.output, webhookEventPayloadResource.output) &&
482505
Objects.equals(this.reasons, webhookEventPayloadResource.reasons) &&
483506
Objects.equals(this.link, webhookEventPayloadResource.link) &&
484-
Objects.equals(this.error, webhookEventPayloadResource.error)&&
507+
Objects.equals(this.error, webhookEventPayloadResource.error) &&
508+
Objects.equals(this.customerUserId, webhookEventPayloadResource.customerUserId)&&
485509
Objects.equals(this.additionalProperties, webhookEventPayloadResource.additionalProperties);
486510
}
487511

@@ -491,7 +515,7 @@ private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b)
491515

492516
@Override
493517
public int hashCode() {
494-
return Objects.hash(id, applicantId, createdAt, updatedAt, dashboardUrl, workflowId, workflowRunId, workflowVersionId, taskDefId, taskDefVersion, input, output, reasons, link, error, additionalProperties);
518+
return Objects.hash(id, applicantId, createdAt, updatedAt, dashboardUrl, workflowId, workflowRunId, workflowVersionId, taskDefId, taskDefVersion, input, output, reasons, link, error, customerUserId, additionalProperties);
495519
}
496520

497521
private static <T> int hashCodeNullable(JsonNullable<T> a) {
@@ -520,6 +544,7 @@ public String toString() {
520544
sb.append(" reasons: ").append(toIndentedString(reasons)).append("\n");
521545
sb.append(" link: ").append(toIndentedString(link)).append("\n");
522546
sb.append(" error: ").append(toIndentedString(error)).append("\n");
547+
sb.append(" customerUserId: ").append(toIndentedString(customerUserId)).append("\n");
523548
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
524549
sb.append("}");
525550
return sb.toString();
@@ -558,6 +583,7 @@ private String toIndentedString(Object o) {
558583
openapiFields.add("reasons");
559584
openapiFields.add("link");
560585
openapiFields.add("error");
586+
openapiFields.add("customer_user_id");
561587

562588
// a set of required properties/fields (JSON key names)
563589
openapiRequiredFields = new HashSet<String>();
@@ -609,6 +635,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
609635
if (jsonObj.get("error") != null && !jsonObj.get("error").isJsonNull()) {
610636
WorkflowRunError.validateJsonElement(jsonObj.get("error"));
611637
}
638+
if ((jsonObj.get("customer_user_id") != null && !jsonObj.get("customer_user_id").isJsonNull()) && !jsonObj.get("customer_user_id").isJsonPrimitive()) {
639+
throw new IllegalArgumentException(String.format("Expected the field `customer_user_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("customer_user_id").toString()));
640+
}
612641
}
613642

614643
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {

src/test/java/com/onfido/OnfidoTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import com.onfido.ApiClient.Region;
77
import com.onfido.api.DefaultApi;
8+
import java.net.InetSocketAddress;
9+
import java.net.Proxy;
810
import java.util.UUID;
911
import org.junit.jupiter.api.Assertions;
1012
import org.junit.jupiter.api.BeforeEach;
@@ -73,4 +75,12 @@ public void usesCARegionApiUrl() {
7375

7476
Assertions.assertEquals("https://api.ca.onfido.com/v3.6", url);
7577
}
78+
79+
@Test()
80+
public void usesProxy() {
81+
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 3128));
82+
DefaultApi onfido = new DefaultApi(apiClient.setApiToken("token").setProxy(proxy));
83+
84+
Assertions.assertEquals(proxy, onfido.getApiClient().getProxy());
85+
}
7686
}

0 commit comments

Comments
 (0)