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

CS-41 feat: add postcode to mailchimp integration properties to send #1332

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -76,7 +76,7 @@ class MailchimpIntegration implements PluginTrait {
return result
}
response.failure = { resp, result ->
logger.error("Mailchimp subscribe to list failed: ${result.status} - ${result.title}: ${result.detail}. More information at: ${result.type}.")
logger.error("Mailchimp subscribe to list failed: ${result.status} - ${result.title}: ${result.detail}, ${result.errors}. More information at: ${result.type}.")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class MailchimpScriptClosure implements ScriptClosureTrait<MailchimpIntegration>
String email
String firstName
String lastName
String postcode
List<String> tags
Map mergeFields = [:]
LocalDate since
Expand Down Expand Up @@ -175,6 +176,19 @@ class MailchimpScriptClosure implements ScriptClosureTrait<MailchimpIntegration>
}
}

/**
* Set subscriber's postcode.
*
* @param postcode of the subscriber
*/
@API
void postcode(String postcode) {
if (postcode) {
this.postcode = postcode
this.mergeFields['POSTCODE'] = postcode
}
}

/**
* Specify contact to take subscriber's email, first and last name from.
*
Expand All @@ -185,6 +199,7 @@ class MailchimpScriptClosure implements ScriptClosureTrait<MailchimpIntegration>
this.email = contact.email
firstName(contact.firstName)
lastName(contact.lastName)
postcode(contact.postcode)
}

/**
Expand Down Expand Up @@ -243,7 +258,7 @@ class MailchimpScriptClosure implements ScriptClosureTrait<MailchimpIntegration>
case MailchimpScriptClosure.SUBSCRIBE:
case MailchimpScriptClosure.UNSUBSCRIBE:
if (!email) {
logger.error("Subscriber email is null, firstName: ${firstName}, lastName: ${lastName}. Abort script.")
logger.error("Subscriber email is null, firstName: ${firstName}, lastName: ${lastName}, postcode: ${postcode}. Abort script.")
break
}
String status = MailchimpScriptClosure.UNSUBSCRIBE == action ? 'unsubscribed' : optIn ? 'pending' : 'subscribed'
Expand All @@ -261,7 +276,7 @@ class MailchimpScriptClosure implements ScriptClosureTrait<MailchimpIntegration>
break
case MailchimpScriptClosure.DELETE_PERMANENTLY:
if (!email) {
logger.error("Subscriber email is null, firstName: ${firstName}, lastName: ${lastName}. Abort script.")
logger.error("Subscriber email is null, firstName: ${firstName}, lastName: ${lastName}, postcode: ${postcode}. Abort script.")
break
}
integration.deletePermanently(email)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ if (integration && record.taggedContact.email && record.taggedContact.allowEmail
email record.taggedContact.email
firstName record.taggedContact.firstName
lastName record.taggedContact.lastName
postcode record.taggedContact.postcode
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ if (record.student.contact.email && record.student.contact.allowEmail) {
email record.student.contact.email
firstName record.student.contact.firstName
lastName record.student.contact.lastName
postcode record.student.contact.postcode
}
}
Loading