From 22d612d989b53c68ea671abdded7846f7cb103c3 Mon Sep 17 00:00:00 2001 From: Alex Burt Date: Fri, 9 Aug 2024 15:10:58 +0100 Subject: [PATCH] SDK-2467: [AB] Allow the brand ID to be set at session creation (as part of the sdk_config) --- .../client/docs/session/create/SdkConfig.java | 31 +++++++++++++++++-- .../docs/session/create/SdkConfigTest.java | 3 ++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/SdkConfig.java b/yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/SdkConfig.java index 63fedf3a..9a157fc6 100644 --- a/yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/SdkConfig.java +++ b/yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/SdkConfig.java @@ -42,6 +42,9 @@ public class SdkConfig { @JsonProperty(Property.ATTEMPTS_CONFIGURATION) private final AttemptsConfiguration attemptsConfiguration; + @JsonProperty(Property.BRAND_ID) + private final String brandId; + SdkConfig(String allowedCaptureMethods, String primaryColour, String secondaryColour, @@ -52,7 +55,7 @@ public class SdkConfig { String errorUrl, String privacyPolicyUrl, Boolean allowHandoff, - AttemptsConfiguration attemptsConfiguration) { + AttemptsConfiguration attemptsConfiguration, String brandId) { this.allowedCaptureMethods = allowedCaptureMethods; this.primaryColour = primaryColour; this.secondaryColour = secondaryColour; @@ -64,6 +67,7 @@ public class SdkConfig { this.privacyPolicyUrl = privacyPolicyUrl; this.allowHandoff = allowHandoff; this.attemptsConfiguration = attemptsConfiguration; + this.brandId = brandId; } public static SdkConfig.Builder builder() { @@ -169,6 +173,15 @@ public AttemptsConfiguration getAttemptsConfiguration() { return attemptsConfiguration; } + /** + * The Brand ID to use for the session + * + * @return the configured brand ID + */ + public String getBrandId() { + return brandId; + } + /** * Builder to assist in the creation of {@link SdkConfig}. */ @@ -185,6 +198,7 @@ public static class Builder { private String privacyPolicyUrl; private Boolean allowHandoff; private AttemptsConfiguration attemptsConfiguration; + private String brandId; private Builder() {} @@ -327,6 +341,17 @@ public Builder withAttemptsConfiguration(AttemptsConfiguration attemptsConfigura return this; } + /** + * Sets the brand ID to be used for the session + * + * @param brandId the brand ID + * @return the builder + */ + public Builder withBrandId(String brandId) { + this.brandId = brandId; + return this; + } + /** * Builds the {@link SdkConfig} using the values supplied to the builder * @@ -344,7 +369,8 @@ public SdkConfig build() { errorUrl, privacyPolicyUrl, allowHandoff, - attemptsConfiguration + attemptsConfiguration, + brandId ); } } @@ -362,6 +388,7 @@ private static final class Property { private static final String PRIVACY_POLICY_URL = "privacy_policy_url"; 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 Property() {} diff --git a/yoti-sdk-api/src/test/java/com/yoti/api/client/docs/session/create/SdkConfigTest.java b/yoti-sdk-api/src/test/java/com/yoti/api/client/docs/session/create/SdkConfigTest.java index d8b78737..b128429e 100644 --- a/yoti-sdk-api/src/test/java/com/yoti/api/client/docs/session/create/SdkConfigTest.java +++ b/yoti-sdk-api/src/test/java/com/yoti/api/client/docs/session/create/SdkConfigTest.java @@ -17,6 +17,7 @@ public class SdkConfigTest { private static final String SOME_FONT_COLOUR = "#b40c12"; private static final String SOME_LOCALE = "en"; private static final String SOME_PRESET_ISSUING_COUNTRY = "USA"; + private static final String SOME_BRAND_ID = "someBrandId"; private static final String SOME_SUCCESS_URL = "https://yourdomain.com/some/success/endpoint"; private static final String SOME_ERROR_URL = "https://yourdomain.com/some/error/endpoint"; @@ -38,6 +39,7 @@ public void shouldBuildSimpleSdkConfigWithAllOptions() { .withPrivacyPolicyUrl(SOME_PRIVACY_POLICY_URL) .withAllowHandoff(true) .withAttemptsConfiguration(attemptsConfigurationMock) + .withBrandId(SOME_BRAND_ID) .build(); assertThat(result, is(instanceOf(SdkConfig.class))); @@ -53,6 +55,7 @@ public void shouldBuildSimpleSdkConfigWithAllOptions() { assertThat(result.getPrivacyPolicyUrl(), is(SOME_PRIVACY_POLICY_URL)); assertThat(result.getAllowHandoff(), is(true)); assertThat(result.getAttemptsConfiguration(), is(attemptsConfigurationMock)); + assertThat(result.getBrandId(), is(SOME_BRAND_ID)); } @Test