Skip to content

Commit

Permalink
Merge pull request #133 from onfido/release-upgrade
Browse files Browse the repository at this point in the history
Refresh onfido-java after onfido-openapi-spec update (2998dd3)
  • Loading branch information
dvacca-onfido authored Oct 23, 2024
2 parents f1bbdec + 2247071 commit 8fd510e
Show file tree
Hide file tree
Showing 295 changed files with 7,931 additions and 8,231 deletions.
2 changes: 1 addition & 1 deletion .openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.6.0
7.9.0
8 changes: 4 additions & 4 deletions .release.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"source": {
"repo_url": "https://github.com/onfido/onfido-openapi-spec",
"short_sha": "10f8380",
"long_sha": "10f83806efa080edbf022ac48d5eeac90fbceb0c",
"version": ""
"short_sha": "2998dd3",
"long_sha": "2998dd3ad2db49a33e0ecf9b41c7cf873909ef0b",
"version": "v4.0.0"
},
"release": "v4.3.0"
"release": "v5.0.0"
}
33 changes: 33 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Migration Guide

## Upgrading from 4.x to 5.x

### Core Resources

- Applicants
- Replace broken `ConsentsBuilder` object with a list of `ApplicantConsentBuilder` ones
- Workflow Runs
- Rename `WorkflowRunSharedLink` object into `WorkflowRunLink`
- Merge and rename `WorkflowRun.StatusEnum` and `WorkflowRunResponse.StatusEnum` enum into `WorkflowRunStatus` enum for storing status information
- Rename `WorkflowRunResponseError` object into `WorkflowRunError`
- Documents
- Reuse already existent `DocumentTypes` enum when uploading documents

### Other Endpoints

- Webhooks
- Define `WebhookEventObjectStatus` enum to collect webhook event object's status
- Define `WebhookEventResourceType` enum to collect webhhok event resource's type
- Define `WebhookEventPayloadResource` object to store webhook payload's contents
- Checks
- Rename `Check.StatusEnum` enum into `CheckStatus` for accessing checks status
- Reports
- Remove deprecated properties from `DeviceIntelligenceBreakdownPropertiesDevice` object: `trueOs`, `osAnomaly`, `rooted` and `remoteSoftware`
- Remove deprecated properties from `DeviceIntelligenceBreakdownPropertiesIp` object: `vpnDetection`, `proxyDetection` and `type`
- Deprecate `records` object from `WatchlistStandardProperties` and `WatchlistAmlProperties` objects (includes `WatchlistPepsOnly` and `WatchlistSanctionsOnly` ones)

### OpenAPI generator

- Version upgraded from 7.6.0 to 7.9.0
- Some dependencies were update, notabily `jakarta.*` replaced `javax.*` ones
- Use `ISO8601Utils` library instead of `sdf` for date and time parsing
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.onfido</groupId>
<artifactId>onfido-api-java</artifactId>
<version>4.3.0</version>
<version>5.0.0</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -59,7 +59,7 @@ Add this dependency to your project's build file:
}
dependencies {
implementation "com.onfido:onfido-api-java:4.3.0"
implementation "com.onfido:onfido-api-java:5.0.0"
}
```

Expand All @@ -73,10 +73,10 @@ mvn clean package

Then manually install the following JARs:

- `target/onfido-api-java-4.3.0.jar`
- `target/onfido-api-java-5.0.0.jar`
- `target/lib/*.jar`

The latest version can be found at: https://search.maven.org/artifact/com.onfido/4.3.0
The latest version can be found at: https://search.maven.org/artifact/com.onfido/5.0.0

## Getting Started

Expand Down Expand Up @@ -164,7 +164,7 @@ Retain from using `getAdditionalProperty()` or `getAdditionalProperties()` metho

## Contributing

This library is automatically generated using [OpenAPI Generator](https://openapi-generator.tech) (version: 7.6.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.
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.

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

Expand Down
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'java'
apply plugin: 'com.diffplug.spotless'

group = 'com.onfido'
version = '4.3.0'
version = '5.0.0'

buildscript {
repositories {
Expand Down Expand Up @@ -112,14 +112,13 @@ dependencies {
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'io.gsonfire:gson-fire:1.9.0'
implementation 'javax.ws.rs:jsr311-api:1.1.1'
implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1'
implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6'
implementation 'org.openapitools:jackson-databind-nullable:0.2.6'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
testImplementation 'org.mockito:mockito-core:3.12.4'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3'
}

javadoc {
Expand Down
7 changes: 3 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ lazy val root = (project in file(".")).
settings(
organization := "com.onfido",
name := "onfido-api-java",
version := "4.3.0",
version := "5.0.0",
scalaVersion := "2.11.4",
scalacOptions ++= Seq("-feature"),
javacOptions in compile ++= Seq("-Xlint:deprecation"),
Expand All @@ -14,14 +14,13 @@ lazy val root = (project in file(".")).
"com.squareup.okhttp3" % "logging-interceptor" % "4.12.0",
"com.google.code.gson" % "gson" % "2.9.1",
"org.apache.commons" % "commons-lang3" % "3.12.0",
"javax.ws.rs" % "jsr311-api" % "1.1.1",
"javax.ws.rs" % "javax.ws.rs-api" % "2.1.1",
"jakarta.ws.rs" % "jakarta.ws.rs-api" % "2.1.6",
"org.openapitools" % "jackson-databind-nullable" % "0.2.6",
"io.gsonfire" % "gson-fire" % "1.9.0" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
"com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
"org.junit.jupiter" % "junit-jupiter-api" % "5.10.2" % "test",
"org.junit.jupiter" % "junit-jupiter-api" % "5.10.3" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test",
"org.mockito" % "mockito-core" % "3.12.4" % "test"
)
Expand Down
20 changes: 8 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>onfido-api-java</artifactId>
<packaging>jar</packaging>
<name>onfido-api-java</name>
<version>4.3.0</version>
<version>5.0.0</version>
<url>https://documentation.onfido.com</url>
<description>Official Java API client library for the Onfido API</description>
<scm>
Expand Down Expand Up @@ -313,14 +313,9 @@
<version>${jackson-databind-nullable-version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>${jsr311-api-version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${javax.ws.rs-api-version}</version>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>${jakarta.ws.rs-api-version}</version>
</dependency>
<!-- test dependencies -->
<dependency>
Expand All @@ -341,14 +336,15 @@
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<gson-fire-version>1.9.0</gson-fire-version>
<okhttp-version>4.11.0</okhttp-version>
<okhttp-version>4.12.0</okhttp-version>
<gson-version>2.10.1</gson-version>
<commons-lang3-version>3.14.0</commons-lang3-version>
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<junit-version>5.10.0</junit-version>
<beanvalidation-version>2.0.2</beanvalidation-version>
<junit-version>5.10.3</junit-version>
<junit-platform-runner.version>1.10.0</junit-platform-runner.version>
<javax.ws.rs-api-version>2.1.1</javax.ws.rs-api-version>
<jakarta.ws.rs-api-version>2.1.6</jakarta.ws.rs-api-version>
<jsr311-api-version>1.1.1</jsr311-api-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spotless.version>2.43.0</spotless.version>
Expand Down
49 changes: 42 additions & 7 deletions src/main/java/com/onfido/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void init() {
json = new JSON();

// Set default User-Agent.
setUserAgent("onfido-java/4.3.0");
setUserAgent("onfido-java/5.0.0");

authentications = new HashMap<String, Authentication>();
}
Expand Down Expand Up @@ -446,6 +446,19 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down Expand Up @@ -701,6 +714,30 @@ public List<Pair> parameterToPairs(String collectionFormat, String name, Collect
return params;
}

/**
* Formats the specified free-form query parameters to a list of {@code Pair} objects.
*
* @param value The free-form query parameters.
* @return A list of {@code Pair} objects.
*/
public List<Pair> freeFormParameterToPairs(Object value) {
List<Pair> params = new ArrayList<>();

// preconditions
if (value == null || !(value instanceof Map )) {
return params;
}

final Map<String, Object> valuesMap = (Map<String, Object>) value;

for (Map.Entry<String, Object> entry : valuesMap.entrySet()) {
params.add(new Pair(entry.getKey(), parameterToString(entry.getValue())));
}

return params;
}


/**
* Formats the specified collection path parameter to a string value.
*
Expand Down Expand Up @@ -1137,10 +1174,6 @@ public Call buildCall(String baseUrl, String path, String method, List<Pair> que
* @throws com.onfido.ApiException If fail to serialize the request body object
*/
public Request buildRequest(String baseUrl, String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException {
// aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams
List<Pair> allQueryParams = new ArrayList<Pair>(queryParams);
allQueryParams.addAll(collectionQueryParams);

final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams);

// prepare HTTP request body
Expand Down Expand Up @@ -1168,10 +1201,12 @@ public Request buildRequest(String baseUrl, String path, String method, List<Pai
reqBody = serialize(body, contentType);
}

List<Pair> updatedQueryParams = new ArrayList<>(queryParams);

// update parameters with authentication settings
updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url));
updateParamsForAuth(authNames, updatedQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url));

final Request.Builder reqBuilder = new Request.Builder().url(url);
final Request.Builder reqBuilder = new Request.Builder().url(buildUrl(baseUrl, path, updatedQueryParams, collectionQueryParams));
processHeaderParams(headerParams, reqBuilder);
processCookieParams(cookieParams, reqBuilder);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/onfido/ApiException.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* <p>ApiException class.</p>
*/
@SuppressWarnings("serial")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0")
public class ApiException extends Exception {
private static final long serialVersionUID = 1L;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/onfido/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

package com.onfido;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0")
public class Configuration {
public static final String VERSION = "4.3.0";
public static final String VERSION = "5.0.0";

private static ApiClient defaultApiClient = new ApiClient();

Expand Down
19 changes: 6 additions & 13 deletions src/main/java/com/onfido/JSON.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

package com.onfido;

import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
Expand All @@ -31,16 +31,14 @@
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.TimeZone;

/*
* A JSON utility class
Expand All @@ -57,11 +55,6 @@ public class JSON {
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();

private static final StdDateFormat sdf = new StdDateFormat()
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
.withColonInTimeZone(true);
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;

@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
Expand Down Expand Up @@ -659,7 +652,7 @@ public java.sql.Date read(JsonReader in) throws IOException {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(sdf.parse(date).getTime());
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
Expand All @@ -669,7 +662,7 @@ public java.sql.Date read(JsonReader in) throws IOException {

/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, DateTimeFormatter will be used.
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {

Expand All @@ -694,7 +687,7 @@ public void write(JsonWriter out, Date date) throws IOException {
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
value = ISO8601Utils.format(date, true);
}
out.value(value);
}
Expand All @@ -713,7 +706,7 @@ public Date read(JsonReader in) throws IOException {
if (dateFormat != null) {
return dateFormat.parse(date);
}
return sdf.parse(date);
return ISO8601Utils.parse(date, new ParsePosition(0));
} catch (ParseException e) {
throw new JsonParseException(e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/onfido/Pair.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package com.onfido;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0")
public class Pair {
private String name = "";
private String value = "";
Expand Down
Loading

0 comments on commit 8fd510e

Please sign in to comment.