Skip to content
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

Feat/python3 update #43

Merged
merged 9 commits into from
Jul 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ python:
- 3.3
- 3.4
- 3.5
- 3.6
script:
- coverage run --source=createsend nosetests.py
- coverage report
Expand Down
31 changes: 20 additions & 11 deletions createsend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
from .createsend import *
from .client import Client
from .template import Template
from .list import List
from .segment import Segment
from .subscriber import Subscriber
from .campaign import Campaign
from .person import Person
from .administrator import Administrator
from .transactional import Transactional
from . import utils
# -*- coding: utf-8 -*-
__title__ = 'createsend-python'
__author__ = 'Dylan Stein'
__license__ = 'MIT'
__copyright__ = 'Copyright 2017'


from createsend.createsend import *
from createsend.client import Client
from createsend.template import Template
from createsend.list import List
from createsend.segment import Segment
from createsend.subscriber import Subscriber
from createsend.campaign import Campaign
from createsend.person import Person
from createsend.administrator import Administrator
from createsend.transactional import Transactional
from createsend import utils

from createsend.version import __version__
70 changes: 36 additions & 34 deletions createsend/administrator.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
try:
import json
import json
except ImportError:
import simplejson as json
from .createsend import CreateSendBase, BadRequest
from .utils import json_to_py
import simplejson as json
from createsend.createsend import CreateSendBase
from createsend.utils import json_to_py


class Administrator(CreateSendBase):
"""Represents an administrator and associated functionality."""
"""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 __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 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,
"Name": name}
response = self._post("/admins.json", json.dumps(body))
return json_to_py(response)
def add(self, email_address, name):
"""Adds an administrator to an account."""
body = {
"EmailAddress": email_address,
"Name": name}
response = self._post("/admins.json", json.dumps(body))
return json_to_py(response)

def update(self, new_email_address, name):
"""Updates the details for an administrator."""
params = { "email": self.email_address }
body = {
"EmailAddress": new_email_address,
"Name": name}
response = self._put("/admins.json",
body=json.dumps(body), params=params)
# Update self.email_address, so this object can continue to be used reliably
self.email_address = new_email_address
def update(self, new_email_address, name):
"""Updates the details for an administrator."""
params = {"email": self.email_address}
body = {
"EmailAddress": new_email_address,
"Name": name}
response = self._put("/admins.json",
body=json.dumps(body), params=params)
# Update self.email_address, so this object can continue to be used
# reliably
self.email_address = new_email_address

def delete(self):
"""Deletes the administrator from the account."""
params = { "email": self.email_address }
response = self._delete("/admins.json", params=params)
def delete(self):
"""Deletes the administrator from the account."""
params = {"email": self.email_address}
response = self._delete("/admins.json", params=params)
Loading