-
Notifications
You must be signed in to change notification settings - Fork 3
Use Mailchimp api #16
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
base: master
Are you sure you want to change the base?
Conversation
Hm, a similar error is happening during the tests for the payroll PR. I'm seeing that same error in my terminal, but it's the same weirdness where locally it just works afterwards. What do you think @fgregg? |
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.
a few changes to make here.
mailchimp_auth/mailchimp.py
Outdated
client = MailchimpAPI() | ||
|
||
|
||
# SAMPLE_PUT_RESPONSE = json.dumps({ |
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.
let's remove this commented out code
mailchimp_auth/mailchimp.py
Outdated
return None | ||
|
||
|
||
client = MailchimpAPI() |
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.
i think we don't need this line.
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.
Gotcha. I think this initialized client
is what gets imported into views
. Without it, if I do something like
from mailchimp_auth.mailchimp import MailchimpAPI as mailchimp_client
instead, it looks like I have to supply mailchimp_client
as self
each time I use it.
What would be the workaround here? I could instantiate it at the top of views instead?
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.
you could do
from mailchimp_auth.mailchimp import MailchimpAPI
and then everywhere where you currently have mailchimp_client you could do something like
mailchimp_user = MailchimpAPI().get_supporter(email)
Wrapper for supporter methods: | ||
https://mailchimp.com/developer/marketing/api/list-members/ | ||
''' | ||
LIST_ID = settings.MAILCHIMP_LIST_ID |
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.
nice
mailchimp_auth/mailchimp.py
Outdated
subscriber = payload["email_address"] | ||
|
||
try: | ||
client = MailchimpMarketing.Client() |
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.
hm.. what about setting up the client once in an __init__
method for this class?
mailchimp_auth/mailchimp.py
Outdated
response = client.searchMembers.search(query=email_address, fields=["exact_matches"]) | ||
|
||
except ApiClientError as error: | ||
print("Error: {}".format(error.text)) |
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.
this should be logged, not printed.
logging.warning("Error: {}".format(error.text))
Overview
This takes the same idea of our Salsa signup/login process here and adjusts it for the Mailchimp api instead.
Notes
The file
mailchimp.py
is displaying here as being a new file, but it's just a renamed and adjustedsalsa.py
.Also I'm getting an error when bringing up the container that there's
No module named 'mailchimp_auth'
but then it proceeds to finish bringing up the container and everything in the app works just fine. I imagine this temporary error is because of the order in which things are installed?Testing Instructions
docker-compose.yml
in the format- <your path>:/django-salsa-auth