Skip to content

Commit

Permalink
SDK-2507: Allow the Relying Business to set response delay for tasks …
Browse files Browse the repository at this point in the history
…and Liveness checks in the sandbox
  • Loading branch information
MrBurtyyy committed Sep 24, 2024
1 parent 6ecb704 commit 6649c24
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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> {

SandboxStaticLivenessCheckBuilder() {
private Integer responseDelay;

SandboxStaticLivenessCheckBuilder() {}

public SandboxStaticLivenessCheckBuilder withResponseDelay(Integer responseDelay) {
this.responseDelay = responseDelay;
return this;
}

@Override
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
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> {

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");

SandboxCheckReport report = new SandboxCheckReport(recommendation, breakdown);
SandboxCheckResult result = new SandboxCheckResult(report);

return new SandboxLivenessCheck(result, DocScanConstants.ZOOM);
return new SandboxLivenessCheck(result, DocScanConstants.ZOOM, responseDelay);
}

}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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() {
Expand All @@ -37,6 +41,10 @@ public SandboxDocumentFilter getDocumentFilter() {
return documentFilter;
}

public Integer getResponseDelay() {
return responseDelay;
}

/**
* Builder for {@link SandboxDocumentTextDataExtractionTask}
*/
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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() {
Expand All @@ -36,6 +42,10 @@ public SandboxDocumentFilter getDocumentFilter() {
return documentFilter;
}

public Integer getResponseDelay() {
return responseDelay;
}

/**
* Builder for {@link SandboxSupplementaryDocTextDataExtractionTask}
*/
Expand All @@ -45,6 +55,7 @@ public static class Builder {
private SandboxDocumentFilter documentFilter;
private String detectedCountry;
private SandboxTextExtractionTaskRecommendation recommendation;
private Integer responseDelay;

private Builder() {}

Expand Down Expand Up @@ -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);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,13 @@ public void builder_shouldAllowRecommendation() {
assertThat(result.getResult().getRecommendation(), is(recommendationMock));
}

}
@Test
public void builder_shouldSetResponseDelay() {
SandboxSupplementaryDocTextDataExtractionTask result = SandboxSupplementaryDocTextDataExtractionTask.builder()
.withResponseDelay(10)
.build();

assertThat(result.getResponseDelay(), is(10));
}

}

0 comments on commit 6649c24

Please sign in to comment.