Skip to content

Commit

Permalink
SDK-2309: Add support for setting biometric consent flow for a session
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBurtyyy committed Sep 23, 2024
1 parent 528dbd1 commit e5c0b03
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,7 @@ private DocScanConstants() { }

public static final String GBP = "GBP";

public static final String EAGER = "EAGER";
public static final String JUST_IN_TIME = "JUST_IN_TIME";

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class SdkConfig {
@JsonProperty(Property.BRAND_ID)
private final String brandId;

@JsonProperty(Property.BIOMETRIC_CONSENT_FLOW)
private final String biometricConsentFlow;

SdkConfig(String allowedCaptureMethods,
String primaryColour,
String secondaryColour,
Expand All @@ -55,7 +58,9 @@ public class SdkConfig {
String errorUrl,
String privacyPolicyUrl,
Boolean allowHandoff,
AttemptsConfiguration attemptsConfiguration, String brandId) {
AttemptsConfiguration attemptsConfiguration,
String brandId,
String biometricConsentFlow) {
this.allowedCaptureMethods = allowedCaptureMethods;
this.primaryColour = primaryColour;
this.secondaryColour = secondaryColour;
Expand All @@ -68,6 +73,7 @@ public class SdkConfig {
this.allowHandoff = allowHandoff;
this.attemptsConfiguration = attemptsConfiguration;
this.brandId = brandId;
this.biometricConsentFlow = biometricConsentFlow;
}

public static SdkConfig.Builder builder() {
Expand Down Expand Up @@ -182,6 +188,15 @@ public String getBrandId() {
return brandId;
}

/**
* The configured biometric consent flow for the session
*
* @return the configured biometric consent flow
*/
public String getBiometricConsentFlow() {
return biometricConsentFlow;
}

/**
* Builder to assist in the creation of {@link SdkConfig}.
*/
Expand All @@ -199,6 +214,7 @@ public static class Builder {
private Boolean allowHandoff;
private AttemptsConfiguration attemptsConfiguration;
private String brandId;
private String biometricConsentFlow;

private Builder() {}

Expand Down Expand Up @@ -352,6 +368,35 @@ public Builder withBrandId(String brandId) {
return this;
}

/**
* Sets the Biometric Consent Flow for the session
*
* @param biometricConsentFlow the biometric consent flow
* @return the builder
*/
public Builder withBiometricConsentFlow(String biometricConsentFlow) {
this.biometricConsentFlow = biometricConsentFlow;
return this;
}

/**
* Sets the biometric consent flow to EAGER for the session
*
* @return the builder
*/
public Builder withBiometricConsentFlowEager() {
return withBiometricConsentFlow(DocScanConstants.EAGER);
}

/**
* Sets the biometric consent flow to JUST_IN_TIME for the session
*
* @return the builder
*/
public Builder withBiometricConsentFlowJustInTime() {
return withBiometricConsentFlow(DocScanConstants.JUST_IN_TIME);
}

/**
* Builds the {@link SdkConfig} using the values supplied to the builder
*
Expand All @@ -370,7 +415,8 @@ public SdkConfig build() {
privacyPolicyUrl,
allowHandoff,
attemptsConfiguration,
brandId
brandId,
biometricConsentFlow
);
}
}
Expand All @@ -389,6 +435,7 @@ private static final class Property {
private static final String ALLOW_HANDOFF = "allow_handoff";
private static final String ATTEMPTS_CONFIGURATION = "attempts_configuration";
private static final String BRAND_ID = "brand_id";
private static final String BIOMETRIC_CONSENT_FLOW = "biometric_consent_flow";

private Property() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ public void shouldBuildSimpleSdkConfigWithCameraAndUpload() {
assertThat(result.getAllowedCaptureMethods(), is("CAMERA_AND_UPLOAD"));
}

@Test
public void shouldBuildSimpleSdkConfigWithBiometricConsentFlowEager() {
SdkConfig result = SdkConfig.builder()
.withBiometricConsentFlowEager()
.build();

assertThat(result.getBiometricConsentFlow(), is("EAGER"));
}

@Test
public void shouldBuildSimpleSdkConfigWithBiometricConsentFlowJustInTime() {
SdkConfig result = SdkConfig.builder()
.withBiometricConsentFlowJustInTime()
.build();

assertThat(result.getBiometricConsentFlow(), is("JUST_IN_TIME"));
}

@Test
public void shouldOverridePreviousAllowedCaptureMethods() {
SdkConfig result = SdkConfig.builder()
Expand Down

0 comments on commit e5c0b03

Please sign in to comment.