Skip to content

Commit

Permalink
Create Parsons Mailchimp connector (#239)
Browse files Browse the repository at this point in the history
* Create Parsons Mailchimp connector

* pep8 compliance

* pep8 compliance

* Added RST documentation for Mailchimp class

* Used Parsons check_env for API key in __init__

* Substituted f-strings where appropriate

* pep8 compliance

* Completed docstrings for three functions

* Completed docstrings

* pep8 compliance

* Removed transform_table function (not directly in use within Parsons)

* Initial testing structure (functionality incomplete)

* Fixed syntax and boolean references

* Fixed API key structure

* Continued work on test JSON

* Fixed incorrectly formatted booleans

* Added args for function calls

* Fixed references to copy/pasted functions

* Testing URI fixes

* Added members JSON to tests

* Added unsubscribe data to expected JSON

* Fixed stray punctuation

* Fixed punctuation

* Added some basic asserts

* Added Mailchimp to __init__.py

* Return empty tables instead of None

* Fixed Mailchimp references in __init__.py

Co-authored-by: Eliot Stone <eliot@movementcooperative.org>
  • Loading branch information
SorenSpicknall and Eliot Stone authored May 14, 2020
1 parent c10b8c2 commit 189fd50
Show file tree
Hide file tree
Showing 8 changed files with 863 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ Indices and tables
google_sheets
google_cloud
hustle
mailchimp
mobilize_america
newmode
ngpvan
Expand Down
32 changes: 32 additions & 0 deletions docs/mailchimp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Mailchimp
=========

`Mailchimp <https://www.mailchimp.com>`_ is a platform used for creating and sending mass emails.
`The Mailchimp API <https://developers.braintreepayments.com/>`_ allows users to interact with data from existing
email campaigns under their account and to configure further campaigns; this Parsons integration focuses on accessing
information about previous email campaigns and the recipients of those campaigns.

***********
Quick Start
***********

.. code-block:: python
from parsons import Mailchimp
mc = Mailchimp()
# Get all recipient lists under a Mailchimp account
lists = mc.get_lists()
# Get campaigns sent since the beginning of 2020
recent_campaigns = mc.get_campaigns(since_send_time='2020-01-01T00:00:00Z')
# Get all unsubscribes from a campaign
unsubscribes = mc.get_unsubscribes('dd693a3e74')
***
API
***
.. autoclass :: parsons.mailchimp.Mailchimp
:inherited-members:
6 changes: 4 additions & 2 deletions parsons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from parsons.newmode.newmode import Newmode
from parsons.databases.mysql.mysql import MySQL
from parsons.rockthevote.rtv import RockTheVote
from parsons.mailchimp.mailchimp import Mailchimp
from parsons.zoom.zoom import Zoom
from parsons.action_network.action_network import ActionNetwork

Expand Down Expand Up @@ -78,9 +79,10 @@
'Newmode',
'MySQL',
'RockTheVote',
'Mailchimp',
'Zoom',
'ActionNetwork'
]
'ActionNetwork',
]

# Define the default logging config for Parsons and its submodules. For now the
# logger gets a StreamHandler by default. At some point a NullHandler may be more
Expand Down
5 changes: 5 additions & 0 deletions parsons/mailchimp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from parsons.mailchimp.mailchimp import Mailchimp

__all__ = [
'Mailchimp'
]
391 changes: 391 additions & 0 deletions parsons/mailchimp/mailchimp.py

Large diffs are not rendered by default.

Empty file added test/test_mailchimp/__init__.py
Empty file.
Loading

0 comments on commit 189fd50

Please sign in to comment.