Skip to content

Conversation

@KeshSridhar
Copy link
Contributor

@KeshSridhar KeshSridhar commented Oct 9, 2025

Checklist for this pull request:

  • I have added docstrings to my additions if needed
  • I have added the module to docs/index.rst if it is completely new

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

@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 96.29630% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.11%. Comparing base (9323a75) to head (6b1646d).
⚠️ Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
src/stac_utils/mailchimp.py 96.29% 0 Missing and 7 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@KeshSridhar KeshSridhar requested a review from DarrFranco October 9, 2025 03:09
Copy link
Contributor

@DarrFranco DarrFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@KeshSridhar KeshSridhar merged commit 9fff598 into main Oct 12, 2025
5 checks passed
@KeshSridhar KeshSridhar deleted the mailchimp_utils branch October 12, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants