Skip to content

Commit 2504daa

Browse files
committed
SDK-2579: Add support for suppressing certain screens on the end-user flow
1 parent d3270cd commit 2504daa

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/SdkConfig.java

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.yoti.api.client.docs.session.create;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
5+
36
import com.yoti.api.client.docs.DocScanConstants;
47

58
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -54,6 +57,9 @@ public class SdkConfig {
5457
@JsonProperty(Property.BIOMETRIC_CONSENT_FLOW)
5558
private final String biometricConsentFlow;
5659

60+
@JsonProperty(Property.SUPPRESSED_SCREENS)
61+
private final List<String> suppressedScreens;
62+
5763
SdkConfig(String allowedCaptureMethods,
5864
String primaryColour,
5965
String primaryColourDarkMode,
@@ -68,7 +74,8 @@ public class SdkConfig {
6874
Boolean allowHandoff,
6975
AttemptsConfiguration attemptsConfiguration,
7076
String brandId,
71-
String biometricConsentFlow) {
77+
String biometricConsentFlow,
78+
List<String> suppressedScreens) {
7279
this.allowedCaptureMethods = allowedCaptureMethods;
7380
this.primaryColour = primaryColour;
7481
this.primaryColourDarkMode = primaryColourDarkMode;
@@ -84,6 +91,7 @@ public class SdkConfig {
8491
this.attemptsConfiguration = attemptsConfiguration;
8592
this.brandId = brandId;
8693
this.biometricConsentFlow = biometricConsentFlow;
94+
this.suppressedScreens = suppressedScreens;
8795
}
8896

8997
public static SdkConfig.Builder builder() {
@@ -225,6 +233,15 @@ public String getBiometricConsentFlow() {
225233
return biometricConsentFlow;
226234
}
227235

236+
/**
237+
* The list of screens to suppress in the end-user flow
238+
*
239+
* @return the list of suppressed screens
240+
*/
241+
public List<String> getSuppressedScreens() {
242+
return suppressedScreens;
243+
}
244+
228245
/**
229246
* Builder to assist in the creation of {@link SdkConfig}.
230247
*/
@@ -245,8 +262,10 @@ public static class Builder {
245262
private AttemptsConfiguration attemptsConfiguration;
246263
private String brandId;
247264
private String biometricConsentFlow;
265+
private List<String> suppressedScreens;
248266

249-
private Builder() {}
267+
private Builder() {
268+
}
250269

251270
/**
252271
* Sets the allowed capture method to "CAMERA"
@@ -476,6 +495,20 @@ public Builder withBiometricConsentFlowJustInTime() {
476495
return withBiometricConsentFlow(DocScanConstants.JUST_IN_TIME);
477496
}
478497

498+
/**
499+
* Add a named screen to the list of suppressed screen in the end-user flow
500+
*
501+
* @param suppressedScreen the name of the screen to suppress
502+
* @return the builder
503+
*/
504+
public Builder withSuppressedScreen(String suppressedScreen) {
505+
if (suppressedScreens == null) {
506+
suppressedScreens = new ArrayList<>();
507+
}
508+
suppressedScreens.add(suppressedScreen);
509+
return this;
510+
}
511+
479512
/**
480513
* Builds the {@link SdkConfig} using the values supplied to the builder
481514
*
@@ -497,7 +530,8 @@ public SdkConfig build() {
497530
allowHandoff,
498531
attemptsConfiguration,
499532
brandId,
500-
biometricConsentFlow
533+
biometricConsentFlow,
534+
suppressedScreens
501535
);
502536
}
503537
}
@@ -519,6 +553,7 @@ private static final class Property {
519553
private static final String ATTEMPTS_CONFIGURATION = "attempts_configuration";
520554
private static final String BRAND_ID = "brand_id";
521555
private static final String BIOMETRIC_CONSENT_FLOW = "biometric_consent_flow";
556+
private static final String SUPPRESSED_SCREENS = "suppressed_screens";
522557

523558
private Property() {}
524559

yoti-sdk-api/src/test/java/com/yoti/api/client/docs/session/create/SdkConfigTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class SdkConfigTest {
2020
private static final String SOME_DARK_MODE = "ON";
2121
private static final String SOME_PRESET_ISSUING_COUNTRY = "USA";
2222
private static final String SOME_BRAND_ID = "someBrandId";
23+
private static final String SOME_SUPPRESSED_SCREEN = "someSuppressedScreen";
24+
private static final String SOME_OTHER_SUPPRESSED_SCREEN = "someOtherSuppressedScreen";
2325

2426
private static final String SOME_SUCCESS_URL = "https://yourdomain.com/some/success/endpoint";
2527
private static final String SOME_ERROR_URL = "https://yourdomain.com/some/error/endpoint";
@@ -44,6 +46,8 @@ public void shouldBuildSimpleSdkConfigWithAllOptions() {
4446
.withAllowHandoff(true)
4547
.withAttemptsConfiguration(attemptsConfigurationMock)
4648
.withBrandId(SOME_BRAND_ID)
49+
.withSuppressedScreen(SOME_SUPPRESSED_SCREEN)
50+
.withSuppressedScreen(SOME_OTHER_SUPPRESSED_SCREEN)
4751
.build();
4852

4953
assertThat(result, is(instanceOf(SdkConfig.class)));
@@ -62,6 +66,8 @@ public void shouldBuildSimpleSdkConfigWithAllOptions() {
6266
assertThat(result.getAllowHandoff(), is(true));
6367
assertThat(result.getAttemptsConfiguration(), is(attemptsConfigurationMock));
6468
assertThat(result.getBrandId(), is(SOME_BRAND_ID));
69+
assertThat(result.getSuppressedScreens(), hasSize(2));
70+
assertThat(result.getSuppressedScreens(), hasItems(SOME_SUPPRESSED_SCREEN, SOME_OTHER_SUPPRESSED_SCREEN));
6571
}
6672

6773
@Test
@@ -145,4 +151,12 @@ public void shouldSetDarkModeToAuto() {
145151
assertThat(result.getDarkMode(), is("AUTO"));
146152
}
147153

154+
@Test
155+
public void suppressedScreens_shouldBeNullIfNotSet() {
156+
SdkConfig result = SdkConfig.builder()
157+
.build();
158+
159+
assertThat(result.getSuppressedScreens(), is(nullValue()));
160+
}
161+
148162
}

0 commit comments

Comments
 (0)