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-2467: [AB] Allow the brand ID to be set at session creation (as p… #452

Merged
merged 1 commit into from
Aug 13, 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 @@ -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