Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK-2507: Allow the Relying Business to set response delay for tasks … #465

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we have a common base class for these, to avoid duplicating everything...?

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

}