Skip to content

Commit

Permalink
improvement: [PLA-10528] add sms pending and double-opt-in opt-out ty…
Browse files Browse the repository at this point in the history
…pes to user profile (#81)
  • Loading branch information
d-staehler authored Feb 25, 2024
1 parent 0bc559e commit 5f3ae57
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/main/com/sailthru/client/params/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ public ApiAction getApiCall() {

public enum OptOutType {
OPT_OUT_TYPE_STOP("opt-out"),
OPT_OUT_TYPE_START("opt-in");

OPT_OUT_TYPE_START("opt-in"),
OPT_OUT_TYPE_PENDING("pending"),
OPT_OUT_TYPE_DOUBLE_OPT_IN("double-opt-in");
public final String optOutTypeStr;

OptOutType(String optOutTypeStr) {
Expand Down
52 changes: 50 additions & 2 deletions src/test/com/sailthru/client/params/UserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,70 @@ public void testSetOptoutSmsStatus() {
assertEquals(expected, result);
}

public void testSetSmsMarketingStatus() {
public void testSetSmsMarketingStatusTypeStart() {
user.setSmsMarketingStatus(User.OptOutType.OPT_OUT_TYPE_START);

String expected = "{\"sms_marketing_status\":\"opt-in\"}";
String result = gson.toJson(user);
assertEquals(expected, result);
}

public void testSetSmsTransactionalStatus() {
public void testSetSmsTransactionalStatusTypeStart() {
user.setSmsTransactionalStatus(User.OptOutType.OPT_OUT_TYPE_START);

String expected = "{\"sms_transactional_status\":\"opt-in\"}";
String result = gson.toJson(user);
assertEquals(expected, result);
}

public void testSetSmsMarketingStatusTypeStop() {
user.setSmsMarketingStatus(User.OptOutType.OPT_OUT_TYPE_STOP);

String expected = "{\"sms_marketing_status\":\"opt-out\"}";
String result = gson.toJson(user);
assertEquals(expected, result);
}

public void testSetSmsTransactionalStatusTypeStop() {
user.setSmsTransactionalStatus(User.OptOutType.OPT_OUT_TYPE_STOP);

String expected = "{\"sms_transactional_status\":\"opt-out\"}";
String result = gson.toJson(user);
assertEquals(expected, result);
}

public void testSetSmsMarketingStatusTypePending() {
user.setSmsMarketingStatus(User.OptOutType.OPT_OUT_TYPE_PENDING);

String expected = "{\"sms_marketing_status\":\"pending\"}";
String result = gson.toJson(user);
assertEquals(expected, result);
}

public void testSetSmsTransactionalStatusTypePending() {
user.setSmsTransactionalStatus(User.OptOutType.OPT_OUT_TYPE_PENDING);

String expected = "{\"sms_transactional_status\":\"pending\"}";
String result = gson.toJson(user);
assertEquals(expected, result);
}

public void testSetSmsMarketingStatusTypeDoubleOptIn() {
user.setSmsMarketingStatus(User.OptOutType.OPT_OUT_TYPE_DOUBLE_OPT_IN);

String expected = "{\"sms_marketing_status\":\"double-opt-in\"}";
String result = gson.toJson(user);
assertEquals(expected, result);
}

public void testSetSmsTransactionalStatusTypeDoubleOptIn() {
user.setSmsTransactionalStatus(User.OptOutType.OPT_OUT_TYPE_DOUBLE_OPT_IN);

String expected = "{\"sms_transactional_status\":\"double-opt-in\"}";
String result = gson.toJson(user);
assertEquals(expected, result);
}

public void testSetLogin() {
Map<String, Object> login = new HashMap<String, Object>();
login.put("ip", "123.456.789.0");
Expand Down

0 comments on commit 5f3ae57

Please sign in to comment.