How to use mailchimp3 - 10 common examples

To help you get started, we’ve selected a few mailchimp3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github VingtCinq / python-mailchimp / mailchimp3 / entities / campaignactions.py View on Github external
def test(self, campaign_id, data):
        """
        Send a test email.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "test_emails": array*,
            "send_type": string* (Must be one of "html" or "plaintext")
        }
        """
        for email in data['test_emails']:
            check_email(email)
        if data['send_type'] not in ['html', 'plaintext']:
            raise ValueError('The send_type must be either "html" or "plaintext"')
        self.campaign_id = campaign_id
        return self._mc_client._post(url=self._build_path(campaign_id, 'actions/test'), data=data)
github VingtCinq / python-mailchimp / mailchimp3 / entities / reportopendetails.py View on Github external
# coding=utf-8
"""
The Location Report API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/reports/open-details/
Schema: https://api.mailchimp.com/schema/3.0/Reports/OpenDetails/Collection.json
"""
from __future__ import unicode_literals

from mailchimp3.baseapi import BaseApi

class OpenDetails(BaseApi):
    """
    Get a detailed report about any emails in a specific campaign that were opened by the recipient.
    """
    def __init__(self, *args, **kwargs):
        """
        Initialize the endpoint
        """
        super(OpenDetails, self).__init__(*args, **kwargs)
        self.endpoint = 'reports'
        self.campaign_id = None


    def all(self, campaign_id, get_all=False,  **queryparams):
        """
        Get detailed information about any campaign emails that were opened by a list member.
github VingtCinq / python-mailchimp / mailchimp3 / entities / reportsentto.py View on Github external
# coding=utf-8
"""
The Sent To Report API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/reports/sent-to/
Schema: https://api.mailchimp.com/schema/3.0/Reports/SentTo/Instance.json
"""
from __future__ import unicode_literals

from mailchimp3.baseapi import BaseApi
from mailchimp3.helpers import check_subscriber_hash


class ReportSentTo(BaseApi):
    """
    Get details about campaign recipients.
    """
    def __init__(self, *args, **kwargs):
        """
        Initialize the endpoint
        """
        super(ReportSentTo, self).__init__(*args, **kwargs)
        self.endpoint = 'reports'
        self.campaign_id = None
        self.subscriber_hash = None


    def all(self, campaign_id, get_all=False, **queryparams):
        """
        Get information about campaign recipients.
github VingtCinq / python-mailchimp / mailchimp3 / entities / message.py View on Github external
from __future__ import unicode_literals
from ..baseapi import BaseApi


class Message(BaseApi):

    def __init__(self, *args, **kwargs):
        super(Message, self).__init__(*args, **kwargs)
        self.endpoint = 'conversations'

    def all(self, conversation_id, **queryparams):
        return self._mc_client._get(url=self._build_path(conversation_id, 'messages'), **queryparams)

    def get(self, conversation_id, message_id):
        return self._mc_client._get(url=self._build_path(conversation_id, 'messages', message_id))

    def create(self, conversation_id, data):
        return self._mc_client._post(url=self._build_path(conversation_id, 'messages'), data=data)
github VingtCinq / python-mailchimp / mailchimp3 / entities / category.py View on Github external
from __future__ import unicode_literals
from ..baseapi import BaseApi


class Category(BaseApi):

    def __init__(self, *args, **kwargs):
        super(Category, self).__init__(*args, **kwargs)
        self.endpoint = 'lists'

    def all(self, list_id, **queryparams):
        """
        returns first 10 interest categories, or Group Titles, for a list.
        """
        return self._mc_client._get(url=self._build_path(list_id, 'interest-categories'), **queryparams)

    def create(self, list_id, data):
        """
        creates a new interest categories, or Group Title.
        """
        return self._mc_client._post(url=self._build_path(list_id, 'interest-categories'), data=data)
github VingtCinq / python-mailchimp / mailchimp3 / entities / storepromocodes.py View on Github external
# coding=utf-8
"""
The E-commerce Stores Promo CodesAPI endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/promo-rules
"""
from __future__ import unicode_literals
from mailchimp3.baseapi import BaseApi

class StorePromoCodes(BaseApi):
    """
        Promo Promo codes can be created for a given promo rule. All the promo codes under a promo rule share the
        generic information defined for that rule like the amount, type, expiration date etc.
        """
    def __init__(self, *args, **kwargs):
        """
        Initialize the Endpoint
        :param args:
        :param kwargs:
        """
        super(StorePromoCodes, self).__init__(*args, **kwargs)
        self.endpoint = 'ecommerce/stores'
        self.store_id = None

    def create(self, store_id, promo_rule_id, data):
        """
github VingtCinq / python-mailchimp / mailchimp3 / entities / storeproductimages.py View on Github external
# coding=utf-8
"""
The E-commerce Store Product Images API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/images/
Schema: https://api.mailchimp.com/schema/3.0/Ecommerce/Stores/Products/Images/Instance.json
"""
from __future__ import unicode_literals

from mailchimp3.baseapi import BaseApi


class StoreProductImages(BaseApi):
    """
    A Product Image represents a specific product image.
    """
    def __init__(self, *args, **kwargs):
        """
        Initialize the endpoint
        """
        super(StoreProductImages, self).__init__(*args, **kwargs)
        self.endpoint = 'ecommerce/stores'
        self.store_id = None
        self.product_id = None
        self.image_id = None


    def create(self, store_id, product_id, data):
        """
github VingtCinq / python-mailchimp / mailchimp3 / entities / storecarts.py View on Github external
# coding=utf-8
"""
The E-commerce Store Carts endpoint API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/
Schema: https://api.mailchimp.com/schema/3.0/Ecommerce/Stores/Carts/Instance.json
"""
from __future__ import unicode_literals

import re

from mailchimp3.baseapi import BaseApi
from mailchimp3.entities.storecartlines import StoreCartLines


class StoreCarts(BaseApi):
    """
    Use Carts to represent unfinished e-commerce transactions. This can be
    used to create an Abandoned Cart workflow, or to save a consumer’s
    shopping cart pending a successful Order.
    """
    def __init__(self, *args, **kwargs):
        """
        Initialize the endpoint
        """
        super(StoreCarts, self).__init__(*args, **kwargs)
        self.endpoint = 'ecommerce/stores'
        self.store_id = None
        self.cart_id = None
        self.lines = StoreCartLines(self)
github VingtCinq / python-mailchimp / mailchimp3 / entities / reportunsubscribed.py View on Github external
from __future__ import unicode_literals
from ..baseapi import BaseApi


class ReportUnsubscribed(BaseApi):

    """
    Reports Unsubscribed Collection
        A list of unsubscribes for a specific campaign (for various reasons).
        http://developer.mailchimp.com/documentation/mailchimp/http://kb.mailchimp.com/api/resources/reports/unsubscribes
    """

    def __init__(self, *args, **kwargs):
        super(ReportUnsubscribed, self).__init__(*args, **kwargs)
        self.endpoint = 'reports'

    def all(self, campaign_id, **queryparams):
        """
        Returns report of all usubscribes a reason for a given campaign
        """
        return self._mc_client._get(url=self._build_path(campaign_id, 'unsubscribed'), **queryparams)
github VingtCinq / python-mailchimp / mailchimp3 / entities / listgrowthhistory.py View on Github external
# coding=utf-8
"""
The List Growth History API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/lists/growth-history/
Schema: https://api.mailchimp.com/schema/3.0/Lists/Growth/Instance.json
"""
from __future__ import unicode_literals

from mailchimp3.baseapi import BaseApi


class ListGrowthHistory(BaseApi):
    """
    View a summary of the month-by-month growth activity for a specific list.
    """
    def __init__(self, *args, **kwargs):
        """
        Initialize the endpoint
        """
        super(ListGrowthHistory, self).__init__(*args, **kwargs)
        self.endpoint = 'lists'
        self.list_id = None
        self.month = None


    def all(self, list_id, get_all=False, **queryparams):
        """
        Get a month-by-month summary of a specific list’s growth activity.