How to use the createsend.createsend.CreateSendBase function in createsend

To help you get started, we’ve selected a few createsend 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 campaignmonitor / createsend-python / lib / createsend / client.py View on Github external
from __future__ import absolute_import

import json

from createsend.createsend import CreateSendBase
from createsend.utils import json_to_py


class Client(CreateSendBase):
    """Represents a client and associated functionality."""

    def __init__(self, auth=None, client_id=None):
        self.client_id = client_id
        super(Client, self).__init__(auth)

    def create(self, company, timezone, country):
        """Creates a client."""

        body = {
            "CompanyName": company,
            "TimeZone": timezone,
            "Country": country}
        response = self._post("/clients.json", json.dumps(body))
        self.client_id = json_to_py(response)
        return self.client_id
github campaignmonitor / createsend-python / lib / createsend / person.py View on Github external
from __future__ import absolute_import

import json

from createsend.createsend import CreateSendBase
from createsend.utils import json_to_py


class Person(CreateSendBase):
    """Represents a person and associated functionality."""

    def __init__(self, auth=None, client_id=None, email_address=None):
        self.client_id = client_id
        self.email_address = email_address
        super(Person, self).__init__(auth)

    def get(self, client_id=None, email_address=None):
        """Gets a person by client ID and email address."""
        params = {"email": email_address or self.email_address}
        response = self._get("/clients/%s/people.json" %
                             (client_id or self.client_id), params=params)
        return json_to_py(response)

    def add(self, client_id, email_address, name, access_level, password):
        """Adds a person to a client. Password is optional and if not supplied, an invitation will be emailed to the person"""
github campaignmonitor / createsend-python / lib / createsend / list.py View on Github external
from __future__ import absolute_import

import json
from six.moves.urllib.parse import quote

from createsend.createsend import CreateSendBase
from createsend.utils import json_to_py


class List(CreateSendBase):
    """Represents a subscriber list and associated functionality."""

    def __init__(self, auth=None, list_id=None):
        self.list_id = list_id
        super(List, self).__init__(auth)

    def create(self, client_id, title, unsubscribe_page, confirmed_opt_in,
               confirmation_success_page, unsubscribe_setting="AllClientLists"):
        """Creates a new list for a client."""
        body = {
            "Title": title,
            "UnsubscribePage": unsubscribe_page,
            "ConfirmedOptIn": confirmed_opt_in,
            "ConfirmationSuccessPage": confirmation_success_page,
            "UnsubscribeSetting": unsubscribe_setting}
        response = self._post("/lists/%s.json" % client_id, json.dumps(body))
github campaignmonitor / createsend-python / lib / createsend / journey_email.py View on Github external
from __future__ import absolute_import

from createsend.createsend import CreateSendBase
from createsend.utils import json_to_py


class JourneyEmail(CreateSendBase):
    """Represents a journey and associated functionality"""

    def __init__(self, auth=None, journey_email_id=None):
        self.journey_email_id = journey_email_id
        super(JourneyEmail, self).__init__(auth)

    def bounces(self, date=None, page=None, page_size=None, order_direction=None):
        """Retrieves the bounces for this journey email."""
        return self.get_journey_email_response(date, page, page_size, order_direction, "bounces")

    def clicks(self, date=None, page=None, page_size=None, order_direction=None):
        """Retrieves the clicks for this journey email."""
        return self.get_journey_email_response(date, page, page_size, order_direction, "clicks")

    def opens(self, date=None, page=None, page_size=None, order_direction=None):
        """Retrieves the opens for this journey email."""
github campaignmonitor / createsend-python / lib / createsend / transactional.py View on Github external
from __future__ import absolute_import

import json

from createsend.createsend import CreateSendBase
from createsend.utils import json_to_py, validate_consent_to_track


class Transactional(CreateSendBase):
    """Represents transactional functionality."""

    def __init__(self, auth=None, client_id=None):
        self.client_id = client_id
        super(Transactional, self).__init__(auth)

    def smart_email_list(self, status="all", client_id=None):
        """Gets the smart email list."""
        if client_id is None:
            response = self._get(
                "/transactional/smartEmail?status=%s" % status)
        else:
            response = self._get(
                "/transactional/smartEmail?status=%s&clientID=%s" % (status, client_id))
        return json_to_py(response)
github campaignmonitor / createsend-python / lib / createsend / segment.py View on Github external
from __future__ import absolute_import

import json

from createsend.createsend import CreateSendBase
from createsend.utils import json_to_py


class Segment(CreateSendBase):
    """Represents a subscriber list segment and associated functionality."""

    def __init__(self, auth=None, segment_id=None):
        self.segment_id = segment_id
        super(Segment, self).__init__(auth)

    def create(self, list_id, title, rulegroups):
        """Creates a new segment."""
        body = {
            "Title": title,
            "RuleGroups": rulegroups}
        response = self._post("/segments/%s.json" % list_id, json.dumps(body))
        self.segment_id = json_to_py(response)
        return self.segment_id

    def update(self, title, rulegroups):
github campaignmonitor / createsend-python / lib / createsend / template.py View on Github external
from __future__ import absolute_import

import json

from createsend.createsend import CreateSendBase
from createsend.utils import json_to_py


class Template(CreateSendBase):
    """Represents an email template and associated functionality."""

    def __init__(self, auth=None, template_id=None):
        self.template_id = template_id
        super(Template, self).__init__(auth)

    def create(self, client_id, name, html_url, zip_url):
        """Creates a new email template."""
        body = {
            "Name": name,
            "HtmlPageURL": html_url,
            "ZipFileURL": zip_url}
        response = self._post("/templates/%s.json" %
                              client_id, json.dumps(body))
        self.template_id = json_to_py(response)
        return self.template_id
github campaignmonitor / createsend-python / lib / createsend / campaign.py View on Github external
from __future__ import absolute_import

import json

from createsend.createsend import CreateSendBase
from createsend.utils import json_to_py


class Campaign(CreateSendBase):
    """Represents a campaign and provides associated functionality."""

    def __init__(self, auth=None, campaign_id=None):
        self.campaign_id = campaign_id
        super(Campaign, self).__init__(auth)

    def create(self, client_id, subject, name, from_name, from_email, reply_to, html_url,
               text_url, list_ids, segment_ids):
        """Creates a new campaign for a client.

        :param client_id: String representing the ID of the client for whom the
          campaign will be created.
        :param subject: String representing the subject of the campaign.
        :param name: String representing the name of the campaign.
        :param from_name: String representing the from name for the campaign.
        :param from_email: String representing the from address for the campaign.
github campaignmonitor / createsend-python / lib / createsend / administrator.py View on Github external
from __future__ import absolute_import

import json

from createsend.createsend import CreateSendBase
from createsend.utils import json_to_py


class Administrator(CreateSendBase):
    """Represents an administrator and associated functionality."""

    def __init__(self, auth=None, email_address=None):
        self.email_address = email_address
        super(Administrator, self).__init__(auth)

    def get(self, email_address=None):
        """Gets an administrator by  email address."""
        params = {"email": email_address or self.email_address}
        response = self._get("/admins.json", params=params)
        return json_to_py(response)

    def add(self, email_address, name):
        """Adds an administrator to an account."""
        body = {
            "EmailAddress": email_address,
github campaignmonitor / createsend-python / lib / createsend / subscriber.py View on Github external
from __future__ import absolute_import

import json

from createsend.createsend import CreateSendBase, BadRequest
from createsend.utils import json_to_py, validate_consent_to_track


class Subscriber(CreateSendBase):
    """Represents a subscriber and associated functionality."""

    def __init__(self, auth=None, list_id=None, email_address=None):
        self.list_id = list_id
        self.email_address = email_address
        super(Subscriber, self).__init__(auth)

    def get(self, list_id=None, email_address=None, include_tracking_preference=False):
        """Gets a subscriber by list ID and email address."""
        params = {
            "email": email_address or self.email_address,
            "includetrackingpreference": include_tracking_preference,
        }
        response = self._get("/subscribers/%s.json" %
                             (list_id or self.list_id), params=params)
        return json_to_py(response)