From ec410b6ebb4ada9ffb14e439ff79e3231e8783da Mon Sep 17 00:00:00 2001 From: Alex Burt Date: Tue, 24 Sep 2024 10:28:52 +0100 Subject: [PATCH] SDK-2507: Allow the Relying Business to set response delay for tasks and Liveness checks in the sandbox --- .../request/check/SandboxLivenessCheck.java | 6 ++++- .../SandboxStaticLivenessCheckBuilder.java | 12 +++++++--- .../SandboxZoomLivenessCheckBuilder.java | 14 +++++++---- ...SandboxDocumentTextDataExtractionTask.java | 23 ++++++++++++++---- ...upplementaryDocTextDataExtractionTask.java | 24 +++++++++++++++---- ...boxDocumentTextDataExtractionTaskTest.java | 9 +++++++ ...ementaryDocTextDataExtractionTaskTest.java | 11 ++++++++- 7 files changed, 81 insertions(+), 18 deletions(-) diff --git a/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/check/SandboxLivenessCheck.java b/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/check/SandboxLivenessCheck.java index dbbbbf421..15b8f97f2 100644 --- a/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/check/SandboxLivenessCheck.java +++ b/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/check/SandboxLivenessCheck.java @@ -7,9 +7,13 @@ public class SandboxLivenessCheck extends SandboxCheck { @JsonProperty("liveness_type") private final String livenessType; - SandboxLivenessCheck(SandboxCheckResult result, String livenessType) { + @JsonProperty("response_delay") + private final Integer responseDelay; + + SandboxLivenessCheck(SandboxCheckResult result, String livenessType, Integer responseDelay) { super(result); this.livenessType = livenessType; + this.responseDelay = responseDelay; } public static SandboxZoomLivenessCheckBuilder forZoomLiveness() { diff --git a/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/check/SandboxStaticLivenessCheckBuilder.java b/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/check/SandboxStaticLivenessCheckBuilder.java index 723b0457f..441d0f2ce 100644 --- a/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/check/SandboxStaticLivenessCheckBuilder.java +++ b/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/check/SandboxStaticLivenessCheckBuilder.java @@ -1,13 +1,19 @@ package com.yoti.api.client.sandbox.docs.request.check; -import static com.yoti.api.client.spi.remote.util.Validation.notNull; +import static com.yoti.validation.Validation.notNull; import com.yoti.api.client.docs.DocScanConstants; import com.yoti.api.client.sandbox.docs.request.check.report.SandboxCheckReport; public class SandboxStaticLivenessCheckBuilder extends SandboxCheck.Builder { - SandboxStaticLivenessCheckBuilder() { + private Integer responseDelay; + + SandboxStaticLivenessCheckBuilder() {} + + public SandboxStaticLivenessCheckBuilder withResponseDelay(Integer responseDelay) { + this.responseDelay = responseDelay; + return this; } @Override @@ -22,7 +28,7 @@ public SandboxLivenessCheck build() { SandboxCheckReport report = new SandboxCheckReport(recommendation, breakdown); SandboxCheckResult result = new SandboxCheckResult(report); - return new SandboxLivenessCheck(result, DocScanConstants.STATIC); + return new SandboxLivenessCheck(result, DocScanConstants.STATIC, responseDelay); } } diff --git a/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/check/SandboxZoomLivenessCheckBuilder.java b/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/check/SandboxZoomLivenessCheckBuilder.java index b650f6d0d..262267b95 100644 --- a/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/check/SandboxZoomLivenessCheckBuilder.java +++ b/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/check/SandboxZoomLivenessCheckBuilder.java @@ -1,20 +1,26 @@ package com.yoti.api.client.sandbox.docs.request.check; -import static com.yoti.api.client.spi.remote.util.Validation.notNull; +import static com.yoti.validation.Validation.notNull; import com.yoti.api.client.docs.DocScanConstants; import com.yoti.api.client.sandbox.docs.request.check.report.SandboxCheckReport; public class SandboxZoomLivenessCheckBuilder extends SandboxCheck.Builder { - SandboxZoomLivenessCheckBuilder() { - } + private Integer responseDelay; + + SandboxZoomLivenessCheckBuilder() {} @Override protected SandboxZoomLivenessCheckBuilder self() { return this; } + public SandboxZoomLivenessCheckBuilder withResponseDelay(Integer responseDelay) { + this.responseDelay = responseDelay; + return this; + } + @Override public SandboxLivenessCheck build() { notNull(recommendation, "recommendation"); @@ -22,7 +28,7 @@ public SandboxLivenessCheck build() { SandboxCheckReport report = new SandboxCheckReport(recommendation, breakdown); SandboxCheckResult result = new SandboxCheckResult(report); - return new SandboxLivenessCheck(result, DocScanConstants.ZOOM); + return new SandboxLivenessCheck(result, DocScanConstants.ZOOM, responseDelay); } } diff --git a/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/task/SandboxDocumentTextDataExtractionTask.java b/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/task/SandboxDocumentTextDataExtractionTask.java index 806917a53..ca31eadcd 100644 --- a/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/task/SandboxDocumentTextDataExtractionTask.java +++ b/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/task/SandboxDocumentTextDataExtractionTask.java @@ -1,6 +1,6 @@ package com.yoti.api.client.sandbox.docs.request.task; -import static com.yoti.api.client.spi.remote.util.Validation.notNull; +import static com.yoti.validation.Validation.notNull; import java.util.Base64; import java.util.HashMap; @@ -20,9 +20,13 @@ public class SandboxDocumentTextDataExtractionTask { @JsonProperty("document_filter") private final SandboxDocumentFilter documentFilter; - SandboxDocumentTextDataExtractionTask(SandboxDocumentTextDataExtractionTaskResult result, SandboxDocumentFilter documentFilter) { + @JsonProperty("response_delay") + private final Integer responseDelay; + + SandboxDocumentTextDataExtractionTask(SandboxDocumentTextDataExtractionTaskResult result, SandboxDocumentFilter documentFilter, Integer responseDelay) { this.result = result; this.documentFilter = documentFilter; + this.responseDelay = responseDelay; } public static Builder builder() { @@ -37,6 +41,10 @@ public SandboxDocumentFilter getDocumentFilter() { return documentFilter; } + public Integer getResponseDelay() { + return responseDelay; + } + /** * Builder for {@link SandboxDocumentTextDataExtractionTask} */ @@ -48,9 +56,9 @@ public static class Builder { private String detectedCountry; private String detectedDocumentType; private SandboxTextExtractionTaskRecommendation recommendation; + private Integer responseDelay; - private Builder() { - } + private Builder() {} public Builder withDocumentField(String key, Object value) { if (documentFields == null) { @@ -93,13 +101,18 @@ public Builder withRecommendation(SandboxTextExtractionTaskRecommendation recomm return this; } + public Builder withResponseDelay(Integer responseDelay) { + this.responseDelay = responseDelay; + return this; + } + public SandboxDocumentTextDataExtractionTask build() { SandboxDocumentTextDataExtractionTaskResult result = new SandboxDocumentTextDataExtractionTaskResult(documentFields, documentIdPhoto, detectedCountry, detectedDocumentType, recommendation); - return new SandboxDocumentTextDataExtractionTask(result, documentFilter); + return new SandboxDocumentTextDataExtractionTask(result, documentFilter, responseDelay); } } } diff --git a/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/task/SandboxSupplementaryDocTextDataExtractionTask.java b/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/task/SandboxSupplementaryDocTextDataExtractionTask.java index 2ccba4843..beb290b79 100644 --- a/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/task/SandboxSupplementaryDocTextDataExtractionTask.java +++ b/yoti-sdk-sandbox/src/main/java/com/yoti/api/client/sandbox/docs/request/task/SandboxSupplementaryDocTextDataExtractionTask.java @@ -1,6 +1,6 @@ package com.yoti.api.client.sandbox.docs.request.task; -import static com.yoti.api.client.spi.remote.util.Validation.notNull; +import static com.yoti.validation.Validation.notNull; import java.util.HashMap; import java.util.Map; @@ -19,9 +19,15 @@ public class SandboxSupplementaryDocTextDataExtractionTask { @JsonProperty("document_filter") private final SandboxDocumentFilter documentFilter; - SandboxSupplementaryDocTextDataExtractionTask(SandboxSupplementaryDocTextDataExtractionTaskResult result, SandboxDocumentFilter documentFilter) { + @JsonProperty("response_delay") + private final Integer responseDelay; + + SandboxSupplementaryDocTextDataExtractionTask(SandboxSupplementaryDocTextDataExtractionTaskResult result, + SandboxDocumentFilter documentFilter, + Integer responseDelay) { this.result = result; this.documentFilter = documentFilter; + this.responseDelay = responseDelay; } public static Builder builder() { @@ -36,6 +42,10 @@ public SandboxDocumentFilter getDocumentFilter() { return documentFilter; } + public Integer getResponseDelay() { + return responseDelay; + } + /** * Builder for {@link SandboxSupplementaryDocTextDataExtractionTask} */ @@ -45,6 +55,7 @@ public static class Builder { private SandboxDocumentFilter documentFilter; private String detectedCountry; private SandboxTextExtractionTaskRecommendation recommendation; + private Integer responseDelay; private Builder() {} @@ -78,10 +89,15 @@ public Builder withRecommendation(SandboxTextExtractionTaskRecommendation recomm return this; } + public Builder withResponseDelay(Integer responseDelay) { + this.responseDelay = responseDelay; + return this; + } + public SandboxSupplementaryDocTextDataExtractionTask build() { SandboxSupplementaryDocTextDataExtractionTaskResult result = new SandboxSupplementaryDocTextDataExtractionTaskResult(documentFields, detectedCountry, recommendation); - return new SandboxSupplementaryDocTextDataExtractionTask(result, documentFilter); + return new SandboxSupplementaryDocTextDataExtractionTask(result, documentFilter, responseDelay); } } -} \ No newline at end of file +} diff --git a/yoti-sdk-sandbox/src/test/java/com/yoti/api/client/sandbox/docs/request/task/SandboxDocumentTextDataExtractionTaskTest.java b/yoti-sdk-sandbox/src/test/java/com/yoti/api/client/sandbox/docs/request/task/SandboxDocumentTextDataExtractionTaskTest.java index adc9bb5a1..d8dfc328c 100644 --- a/yoti-sdk-sandbox/src/test/java/com/yoti/api/client/sandbox/docs/request/task/SandboxDocumentTextDataExtractionTaskTest.java +++ b/yoti-sdk-sandbox/src/test/java/com/yoti/api/client/sandbox/docs/request/task/SandboxDocumentTextDataExtractionTaskTest.java @@ -96,4 +96,13 @@ public void builder_shouldAllowRecommendation() { assertThat(result.getResult().getRecommendation(), is(recommendationMock)); } + @Test + public void builder_shouldSetResponseDelay() { + SandboxDocumentTextDataExtractionTask result = SandboxDocumentTextDataExtractionTask.builder() + .withResponseDelay(10) + .build(); + + assertThat(result.getResponseDelay(), is(10)); + } + } diff --git a/yoti-sdk-sandbox/src/test/java/com/yoti/api/client/sandbox/docs/request/task/SandboxSupplementaryDocTextDataExtractionTaskTest.java b/yoti-sdk-sandbox/src/test/java/com/yoti/api/client/sandbox/docs/request/task/SandboxSupplementaryDocTextDataExtractionTaskTest.java index 0cb89d717..93cb6df02 100644 --- a/yoti-sdk-sandbox/src/test/java/com/yoti/api/client/sandbox/docs/request/task/SandboxSupplementaryDocTextDataExtractionTaskTest.java +++ b/yoti-sdk-sandbox/src/test/java/com/yoti/api/client/sandbox/docs/request/task/SandboxSupplementaryDocTextDataExtractionTaskTest.java @@ -81,4 +81,13 @@ public void builder_shouldAllowRecommendation() { assertThat(result.getResult().getRecommendation(), is(recommendationMock)); } -} \ No newline at end of file + @Test + public void builder_shouldSetResponseDelay() { + SandboxSupplementaryDocTextDataExtractionTask result = SandboxSupplementaryDocTextDataExtractionTask.builder() + .withResponseDelay(10) + .build(); + + assertThat(result.getResponseDelay(), is(10)); + } + +}