Skip to content

Commit

Permalink
bulk import: email/sms opt OUT
Browse files Browse the repository at this point in the history
  • Loading branch information
brmeyer committed Nov 17, 2022
1 parent 129f94c commit 045a537
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/com/impactupgrade/nucleus/model/CrmImportEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public class CrmImportEvent {
private String contactMailingZip;
private String contactMailingCountry;
private Boolean contactOptInEmail;
private Boolean contactOptOutEmail;
private Boolean contactOptInSms;
private Boolean contactOptOutSms;
private String contactRecordTypeId;
private String contactRecordTypeName;

Expand Down Expand Up @@ -132,7 +134,9 @@ public static CrmImportEvent fromGeneric(Map<String, String> _data, Environment
importEvent.contactMailingZip = data.get("Contact Mailing PostCode");
importEvent.contactMailingCountry = data.get("Contact Mailing Country");
importEvent.contactOptInEmail = "yes".equalsIgnoreCase(data.get("Contact Email Opt In")) || "true".equalsIgnoreCase(data.get("Contact Email Opt In")) || "1".equalsIgnoreCase(data.get("Contact Email Opt In"));
importEvent.contactOptOutEmail = "no".equalsIgnoreCase(data.get("Contact Email Opt In")) || "false".equalsIgnoreCase(data.get("Contact Email Opt In")) || "0".equalsIgnoreCase(data.get("Contact Email Opt In"));
importEvent.contactOptInSms = "yes".equalsIgnoreCase(data.get("Contact SMS Opt In")) || "true".equalsIgnoreCase(data.get("Contact SMS Opt In")) || "1".equalsIgnoreCase(data.get("Contact SMS Opt In"));
importEvent.contactOptOutSms = "no".equalsIgnoreCase(data.get("Contact SMS Opt In")) || "false".equalsIgnoreCase(data.get("Contact SMS Opt In")) || "0".equalsIgnoreCase(data.get("Contact SMS Opt In"));
importEvent.contactRecordTypeId = data.get("Contact Record Type ID");
importEvent.contactRecordTypeName = data.get("Contact Record Type Name");

Expand Down Expand Up @@ -339,10 +343,18 @@ public Boolean getContactOptInEmail() {
return contactOptInEmail;
}

public Boolean getContactOptOutEmail() {
return contactOptOutEmail;
}

public Boolean getContactOptInSms() {
return contactOptInSms;
}

public Boolean getContactOptOutSms() {
return contactOptOutSms;
}

public String getContactRecordTypeId() {
return contactRecordTypeId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,10 +1015,18 @@ protected void setBulkImportContactFields(SObject contact, CrmImportEvent import
setField(contact, env.getConfig().salesforce.fieldDefinitions.emailOptIn, true);
setField(contact, env.getConfig().salesforce.fieldDefinitions.emailOptOut, false);
}
if (importEvent.getContactOptOutEmail() != null && importEvent.getContactOptOutEmail()) {
setField(contact, env.getConfig().salesforce.fieldDefinitions.emailOptIn, false);
setField(contact, env.getConfig().salesforce.fieldDefinitions.emailOptOut, true);
}
if (importEvent.getContactOptInSms() != null && importEvent.getContactOptInSms()) {
setField(contact, env.getConfig().salesforce.fieldDefinitions.smsOptIn, true);
setField(contact, env.getConfig().salesforce.fieldDefinitions.smsOptOut, false);
}
if (importEvent.getContactOptOutSms() != null && importEvent.getContactOptOutSms()) {
setField(contact, env.getConfig().salesforce.fieldDefinitions.smsOptIn, false);
setField(contact, env.getConfig().salesforce.fieldDefinitions.smsOptOut, true);
}

contact.setField("OwnerId", importEvent.getOwnerId());

Expand Down Expand Up @@ -1078,6 +1086,10 @@ protected Object getCustomBulkValue(String value) {

if (c != null) {
return c;
} else if ("true".equalsIgnoreCase(value)) {
return true;
} else if ("false".equalsIgnoreCase(value)) {
return false;
} else {
return value;
}
Expand Down

0 comments on commit 045a537

Please sign in to comment.