Skip to content

Commit

Permalink
SDK-2467: [AB] Allow the brand ID to be set at session creation (as p…
Browse files Browse the repository at this point in the history
…art of the sdk_config)
  • Loading branch information
MrBurtyyy committed Aug 13, 2024
1 parent d5da728 commit 528dbd1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -64,6 +67,7 @@ public class SdkConfig {
this.privacyPolicyUrl = privacyPolicyUrl;
this.allowHandoff = allowHandoff;
this.attemptsConfiguration = attemptsConfiguration;
this.brandId = brandId;
}

public static SdkConfig.Builder builder() {
Expand Down Expand Up @@ -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}.
*/
Expand All @@ -185,6 +198,7 @@ public static class Builder {
private String privacyPolicyUrl;
private Boolean allowHandoff;
private AttemptsConfiguration attemptsConfiguration;
private String brandId;

private Builder() {}

Expand Down Expand Up @@ -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
*
Expand All @@ -344,7 +369,8 @@ public SdkConfig build() {
errorUrl,
privacyPolicyUrl,
allowHandoff,
attemptsConfiguration
attemptsConfiguration,
brandId
);
}
}
Expand All @@ -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() {}

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

0 comments on commit 528dbd1

Please sign in to comment.