-
Notifications
You must be signed in to change notification settings - Fork 1
Mailchimp utils #78
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
Mailchimp utils #78
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #78 +/- ##
==========================================
+ Coverage 93.76% 94.11% +0.35%
==========================================
Files 26 27 +1
Lines 1170 1359 +189
Branches 136 172 +36
==========================================
+ Hits 1097 1279 +182
Misses 61 61
- Partials 12 19 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…e_for_rate_limit, paginate_endpoint, and get_subscriber_hash
…tead of mocking http directly where relevant
DarrFranco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Checklist for this pull request:
Description:
This is the script portion of MailChimp Utils. No new reqs need to be added.
The script closely follows the structure of action_network utils , for the creation of the MailChimpClient Class and the create_session, transform_response, and the unused check_response_for_rate_limit methods.
The base_url for the API is not universal due to the suffix of the API key being used to grab the data center portion of the base_url (can differ)
The paginate_endpoint method is similar to the action_network one, but uses a (more conventional?) offset/page structure to move through pages. Works for GET HTTP requests to any of the relevant MailChimp endpoints
A MailChimp member's unique id is based on the MD5 hash of the lowercase version of the contact’s email address. This is generated in the get_subscriber_hash method
Everything in MailChimp revolves around audiences (also called lists). In the script, there is no functionality for changes to more than one audience at a time, which is likely a good thing.
Hence, a list_id /Audience ID (which you can get on the front end of MailChimp in the "Audience settings" section) is required for the following methods:
update_member_tags: adds or removes tags from a MailChimp member, in a given audience.
upsert_member: Add or update a MailChimp member. The fields that you can update, besides for the always required email, are governed by "Merge tags", which can be found on the front end of MailChimp in the "Audience fields and merge tags" section. Merge tags are formatted per MailChimps reqs using the methods below:
get_merge_fields_data_type_map: gets the mapping of the merge field tags and data types for a given audience
format_merge_fields_for_list: formats MailChimp merge fields for a given audience, based on merge field reqs. Uses these static methods: format_date, format_birthday, format_address, format_number,
API Documentation can be found here
Tests will be in another commit