Skip to content

Commit

Permalink
Merge pull request #108 from uphold/feature/marketing-consent
Browse files Browse the repository at this point in the history
Add marketing consent setting
  • Loading branch information
d-moreira authored May 22, 2018
2 parents f2c04a0 + c3980b7 commit eb2a648
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ public void getUserShouldReturnTheUser() throws Exception {
"\"settings\": {" +
"\"theme\": \"minimalistic\"," +
"\"currency\": \"USD\"," +
"\"hasMarketingConsent\": \"true\"," +
"\"hasNewsSubscription\": \"true\"," +
"\"intl\": {" +
"\"language\": {" +
Expand Down Expand Up @@ -384,6 +385,7 @@ public Promise<User> call(UpholdRestAdapter adapter) {
Assert.assertFalse(user.getSettings().getOtp().getTransactions().getSend().getEnabled());
Assert.assertTrue(user.getSettings().getOtp().getTransactions().getTransfer().getEnabled());
Assert.assertTrue(user.getSettings().getOtp().getTransactions().getWithdraw().getCrypto().getEnabled());
Assert.assertTrue(user.getSettings().getHasMarketingConsent());
Assert.assertTrue(user.getSettings().getHasNewsSubscription());
Assert.assertEquals(user.getVerifications().getAddress().getStatus(), "required");
Assert.assertEquals(user.getVerifications().getBirthdate().getStatus(), "required");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ public Promise<List<Phone>> call(UpholdRestAdapter adapter) {
public void getSettingsShouldReturnTheSettings() {
HashMap<String, String> data = new HashMap<String, String>() {{
put("currency", "USD");
put("hasMarketingConsent", "true");
put("hasNewsSubscription", "true");
put("theme", "minimalistic");
put("internationalizationUserSettingLanguage", "en-US");
Expand All @@ -552,6 +553,7 @@ public void getSettingsShouldReturnTheSettings() {
User user = Fixtures.loadUser(data);

Assert.assertEquals(user.getSettings().getCurrency(), "USD");
Assert.assertTrue(user.getSettings().getHasMarketingConsent());
Assert.assertTrue(user.getSettings().getHasNewsSubscription());
Assert.assertEquals(user.getSettings().getTheme(), "minimalistic");
Assert.assertEquals(user.getSettings().getIntl().getLanguage().getLocale(), "en-US");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ public static User loadUser(HashMap<String, String> fields) {
put("currency", faker.lorem().fixedString(3));
put("email", faker.internet().emailAddress());
put("firstName", faker.name().firstName());
put("hasMarketingConsent", "true");
put("hasNewsSubscription", "true");
put("internationalizationUserSettingDateTimeFormat", faker.lorem().fixedString(5));
put("internationalizationUserSettingLanguage", faker.lorem().fixedString(5));
Expand Down Expand Up @@ -379,7 +380,7 @@ public static User loadUser(HashMap<String, String> fields) {
InternationalizationUserSetting internationalizationUserSettingNumberFormat = new InternationalizationUserSetting(fakerFields.get("internationalizationUserSettingNumberFormat"));
InternationalizationUserSettings internationalizationUserSettings = new InternationalizationUserSettings(internationalizationUserSettingLanguage, internationalizationUserSettingDateTimeFormat, internationalizationUserSettingNumberFormat);
Otp otp = new Otp(new Login(Boolean.valueOf(fakerFields.get("settingsOTPLogin"))), new Transactions(new Send(Boolean.valueOf(fakerFields.get("settingsOTPTransactionsSend"))), new Transfer(Boolean.valueOf(fakerFields.get("settingsOTPTransactionsTransfer"))), new Withdraw(new Crypto(Boolean.valueOf(fakerFields.get("settingsOTPTransactionsWithdrawCrypto"))))));
Settings settings = new Settings(fakerFields.get("currency"), Boolean.valueOf(fakerFields.get("hasNewsSubscription")), Boolean.valueOf(fakerFields.get("hasOtpEnabled")), internationalizationUserSettings, otp, fakerFields.get("theme"));
Settings settings = new Settings(fakerFields.get("currency"), Boolean.valueOf(fakerFields.get("hasMarketingConsent")), Boolean.valueOf(fakerFields.get("hasNewsSubscription")), Boolean.valueOf(fakerFields.get("hasOtpEnabled")), internationalizationUserSettings, otp, fakerFields.get("theme"));
VerificationParameter verificationsAddress = new VerificationParameter(fakerFields.get("verificationsReasonAddress"), fakerFields.get("verificationsStatusAddress"));
VerificationParameter verificationsBirthdate = new VerificationParameter(fakerFields.get("verificationsReasonBirthdate"), fakerFields.get("verificationsStatusBirthdate"));
VerificationParameter verificationsDocuments = new VerificationParameter(fakerFields.get("verificationsReasonDocuments"), fakerFields.get("verificationsStatusDocuments"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public class Settings implements Serializable {

private final String currency;
private final Boolean hasMarketingConsent;
private final Boolean hasNewsSubscription;
private final InternationalizationUserSettings intl;
private final Otp otp;
Expand All @@ -21,14 +22,16 @@ public class Settings implements Serializable {
* Constructor.
*
* @param currency The currency selected at the user settings.
* @param hasNewsSubscription A boolean indicating if the user has the news subscription enable.
* @param hasMarketingConsent A boolean indicating if the user has the marketing consent enabled.
* @param hasNewsSubscription A boolean indicating if the user has the news subscription enabled.
* @param intl The user internationalization settings.
* @param otp The user otp settings.
* @param theme The user theme.
*/

public Settings(String currency, Boolean hasNewsSubscription, Boolean hasOtpEnabled, InternationalizationUserSettings intl, Otp otp, String theme) {
public Settings(String currency, Boolean hasMarketingConsent, Boolean hasNewsSubscription, Boolean hasOtpEnabled, InternationalizationUserSettings intl, Otp otp, String theme) {
this.currency = currency;
this.hasMarketingConsent = hasMarketingConsent;
this.hasNewsSubscription = hasNewsSubscription;
this.intl = intl;
this.otp = otp;
Expand All @@ -45,10 +48,21 @@ public String getCurrency() {
return currency;
}


/**
* Gets a boolean indicating if the user has the marketing consent enabled.
*
* @return the a boolean indicating if the user has the marketing consent enabled.
*/

public Boolean getHasMarketingConsent() {
return hasMarketingConsent;
}

/**
* Gets a boolean indicating if the user has the news subscription enable.
* Gets a boolean indicating if the user has the news subscription enabled.
*
* @return the a boolean indicating if the user has the news subscription enable
* @return the a boolean indicating if the user has the news subscription enabled.
*/

public Boolean getHasNewsSubscription() {
Expand All @@ -58,7 +72,7 @@ public Boolean getHasNewsSubscription() {
/**
* Gets the user internationalization settings.
*
* @return the {@link InternationalizationUserSettings}
* @return the {@link InternationalizationUserSettings}.
*/

public InternationalizationUserSettings getIntl() {
Expand All @@ -78,7 +92,7 @@ public Otp getOtp() {
/**
* Gets the user theme.
*
* @return the user theme
* @return the user theme.
*/

public String getTheme() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void shouldBeSerializable() {
InternationalizationUserSetting internationalizationUserSettingNumberFormat = new InternationalizationUserSetting("FOOBAR");
InternationalizationUserSettings internationalizationUserSettings = new InternationalizationUserSettings(internationalizationUserSettingLanguage, internationalizationUserSettingDateTimeFormat, internationalizationUserSettingNumberFormat);
Otp otp = new Otp(new Login(false), new Transactions(new Send(false), new Transfer(false), new Withdraw(new Crypto(true))));
Settings settings = new Settings("FIZ", true, false, internationalizationUserSettings, otp, "FUZ");
Settings settings = new Settings("FIZ", true, true, false, internationalizationUserSettings, otp, "FUZ");
ArrayList<String> currencies = new ArrayList<>();
VerificationParameter addressVerification = new VerificationParameter("address", "required");
VerificationParameter birthdateVerification = new VerificationParameter("birthdate", "required");
Expand Down

0 comments on commit eb2a648

Please sign in to comment.