From 477236604bdf8ea5d5cbf1034d4c67168735ffd7 Mon Sep 17 00:00:00 2001 From: dvacca-onfido <134616519+dvacca-onfido@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:49:51 +0000 Subject: [PATCH 1/2] Upgrade after onfido-openapi-spec change 54ce45f --- .release.json | 8 +- README.md | 8 +- build.gradle | 2 +- build.sbt | 2 +- pom.xml | 2 +- src/main/java/com/onfido/ApiClient.java | 2 +- src/main/java/com/onfido/Configuration.java | 2 +- src/main/java/com/onfido/api/DefaultApi.java | 132 +++++++++++++++++++ 8 files changed, 145 insertions(+), 13 deletions(-) diff --git a/.release.json b/.release.json index 4f8096b..8890d2f 100644 --- a/.release.json +++ b/.release.json @@ -1,9 +1,9 @@ { "source": { "repo_url": "https://github.com/onfido/onfido-openapi-spec", - "short_sha": "964fb43", - "long_sha": "964fb43a1bf211197ef7a45c230771b8ba561b3c", - "version": "v4.4.0" + "short_sha": "54ce45f", + "long_sha": "54ce45f2138f044cc5cb40f6904dc7bc1a675be6", + "version": "v4.5.0" }, - "release": "v5.4.0" + "release": "v5.5.0" } diff --git a/README.md b/README.md index d0cdd3b..9f2cd55 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Add this dependency to your project's POM: com.onfido onfido-api-java - 5.4.0 + 5.5.0 compile ``` @@ -59,7 +59,7 @@ Add this dependency to your project's build file: } dependencies { - implementation "com.onfido:onfido-api-java:5.4.0" + implementation "com.onfido:onfido-api-java:5.5.0" } ``` @@ -73,10 +73,10 @@ mvn clean package Then manually install the following JARs: -- `target/onfido-api-java-5.4.0.jar` +- `target/onfido-api-java-5.5.0.jar` - `target/lib/*.jar` -The latest version can be found at: https://search.maven.org/artifact/com.onfido/5.4.0 +The latest version can be found at: https://search.maven.org/artifact/com.onfido/5.5.0 ## Getting Started diff --git a/build.gradle b/build.gradle index acace55..328ddd4 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'com.onfido' -version = '5.4.0' +version = '5.5.0' buildscript { repositories { diff --git a/build.sbt b/build.sbt index 0405cf0..dd7c391 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "com.onfido", name := "onfido-api-java", - version := "5.4.0", + version := "5.5.0", scalaVersion := "2.11.4", scalacOptions ++= Seq("-feature"), javacOptions in compile ++= Seq("-Xlint:deprecation"), diff --git a/pom.xml b/pom.xml index b38ea6b..5e4826f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ onfido-api-java jar onfido-api-java - 5.4.0 + 5.5.0 https://documentation.onfido.com Official Java API client library for the Onfido API diff --git a/src/main/java/com/onfido/ApiClient.java b/src/main/java/com/onfido/ApiClient.java index 461b44e..ed6c97d 100644 --- a/src/main/java/com/onfido/ApiClient.java +++ b/src/main/java/com/onfido/ApiClient.java @@ -160,7 +160,7 @@ private void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("onfido-java/5.4.0"); + setUserAgent("onfido-java/5.5.0"); authentications = new HashMap(); } diff --git a/src/main/java/com/onfido/Configuration.java b/src/main/java/com/onfido/Configuration.java index a9a82fe..aa25b62 100644 --- a/src/main/java/com/onfido/Configuration.java +++ b/src/main/java/com/onfido/Configuration.java @@ -15,7 +15,7 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0") public class Configuration { - public static final String VERSION = "5.4.0"; + public static final String VERSION = "5.5.0"; private static ApiClient defaultApiClient = new ApiClient(); diff --git a/src/main/java/com/onfido/api/DefaultApi.java b/src/main/java/com/onfido/api/DefaultApi.java index 8c10e3e..af211d5 100644 --- a/src/main/java/com/onfido/api/DefaultApi.java +++ b/src/main/java/com/onfido/api/DefaultApi.java @@ -1904,6 +1904,138 @@ public okhttp3.Call downloadDocumentVideoAsync(String documentId, final ApiCallb localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for downloadEvidenceFolder + * @param workflowRunId Workflow Run ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
302 Found * Location - Link to the Timeline File.
200 The evidence folder binary data. -
0 Unexpected error -
+ */ + public okhttp3.Call downloadEvidenceFolderCall(UUID workflowRunId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/workflow_runs/{workflow_run_id}/evidence_folder" + .replace("{" + "workflow_run_id" + "}", localVarApiClient.escapeString(workflowRunId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/zip", + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "Token" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call downloadEvidenceFolderValidateBeforeCall(UUID workflowRunId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'workflowRunId' is set + if (workflowRunId == null) { + throw new ApiException("Missing the required parameter 'workflowRunId' when calling downloadEvidenceFolder(Async)"); + } + + return downloadEvidenceFolderCall(workflowRunId, _callback); + + } + + /** + * Retrieve Workflow Run Evidence Folder + * Retrieves the evidence folder for the designated Workflow Run + * @param workflowRunId Workflow Run ID (required) + * @return FileTransfer + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
302 Found * Location - Link to the Timeline File.
200 The evidence folder binary data. -
0 Unexpected error -
+ */ + public FileTransfer downloadEvidenceFolder(UUID workflowRunId) throws ApiException { + ApiResponse localVarResp = downloadEvidenceFolderWithHttpInfo(workflowRunId); + return localVarResp.getData(); + } + + /** + * Retrieve Workflow Run Evidence Folder + * Retrieves the evidence folder for the designated Workflow Run + * @param workflowRunId Workflow Run ID (required) + * @return ApiResponse<FileTransfer> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
302 Found * Location - Link to the Timeline File.
200 The evidence folder binary data. -
0 Unexpected error -
+ */ + public ApiResponse downloadEvidenceFolderWithHttpInfo(UUID workflowRunId) throws ApiException { + okhttp3.Call localVarCall = downloadEvidenceFolderValidateBeforeCall(workflowRunId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Retrieve Workflow Run Evidence Folder (asynchronously) + * Retrieves the evidence folder for the designated Workflow Run + * @param workflowRunId Workflow Run ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
302 Found * Location - Link to the Timeline File.
200 The evidence folder binary data. -
0 Unexpected error -
+ */ + public okhttp3.Call downloadEvidenceFolderAsync(UUID workflowRunId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = downloadEvidenceFolderValidateBeforeCall(workflowRunId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } /** * Build call for downloadIdPhoto * @param idPhotoId The ID photo's unique identifier. (required) From a562919617f57702b372d3b0a6b56cc816ac9825 Mon Sep 17 00:00:00 2001 From: Miguel Teixeira Date: Tue, 7 Jan 2025 12:36:48 +0000 Subject: [PATCH 2/2] Add downloadEvidenceFolder test --- .../onfido/integration/WorkflowRunTest.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/onfido/integration/WorkflowRunTest.java b/src/test/java/com/onfido/integration/WorkflowRunTest.java index ba6ac68..86b16d8 100644 --- a/src/test/java/com/onfido/integration/WorkflowRunTest.java +++ b/src/test/java/com/onfido/integration/WorkflowRunTest.java @@ -5,9 +5,12 @@ import com.onfido.model.WorkflowRun; import com.onfido.model.WorkflowRunBuilder; import com.onfido.model.WorkflowRunStatus; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.HashMap; import java.util.Map; import java.util.UUID; +import java.util.zip.ZipFile; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,7 +21,8 @@ public class WorkflowRunTest extends TestBase { private UUID workflowRunId; static final UUID WORKFLOW_ID = UUID.fromString("e8c921eb-0495-44fe-b655-bcdcaffdafe5"); - static final UUID WORKFLOW_ID_TIMELINE = UUID.fromString("221f9d24-cf72-4762-ac4a-01bf3ccc09dd"); + static final UUID WORKFLOW_ID_AUTO_APPROVE = + UUID.fromString("221f9d24-cf72-4762-ac4a-01bf3ccc09dd"); @BeforeEach public void setup() throws Exception { @@ -76,7 +80,7 @@ public void evidenceWorkflowRunTest() throws Exception { @Test public void generateTimelineFileTest() throws Exception { - UUID workflowRunId = createWorkflowRun(WORKFLOW_ID_TIMELINE, applicantId).getId(); + UUID workflowRunId = createWorkflowRun(WORKFLOW_ID_AUTO_APPROVE, applicantId).getId(); repeatRequestUntilStatusChanges( "findWorkflowRun", new UUID[] {workflowRunId}, WorkflowRunStatus.APPROVED, 10, 1000); @@ -90,7 +94,7 @@ public void generateTimelineFileTest() throws Exception { @Test public void findTimelineFileTest() throws Exception { - UUID workflowRunId = createWorkflowRun(WORKFLOW_ID_TIMELINE, applicantId).getId(); + UUID workflowRunId = createWorkflowRun(WORKFLOW_ID_AUTO_APPROVE, applicantId).getId(); repeatRequestUntilStatusChanges( "findWorkflowRun", new UUID[] {workflowRunId}, WorkflowRunStatus.APPROVED, 10, 1000); @@ -106,4 +110,21 @@ public void findTimelineFileTest() throws Exception { Assertions.assertEquals("%PDF", new String(byteArray, 0, 4)); Assertions.assertTrue(byteArray.length > 0); } + + @Test + public void downloadEvidenceFolderTest() throws Exception { + UUID workflowRunId = createWorkflowRun(WORKFLOW_ID_AUTO_APPROVE, applicantId).getId(); + + repeatRequestUntilStatusChanges( + "findWorkflowRun", new UUID[] {workflowRunId}, WorkflowRunStatus.APPROVED, 10, 1000); + + byte[] byteArray = onfido.downloadEvidenceFolder(workflowRunId).getByteArray(); + + Path path = Files.createTempFile("evidence-folder", ".zip"); + path.toFile().deleteOnExit(); + Files.write(path, byteArray); + + Assertions.assertDoesNotThrow(() -> new ZipFile(path.toFile())); + Assertions.assertTrue(byteArray.length > 0); + } }