Skip to content

Commit

Permalink
Merge pull request #43 from getbento/feat/python3-update
Browse files Browse the repository at this point in the history
Feat/python3 update
  • Loading branch information
jdennes committed Jul 1, 2017
2 parents 957a097 + 09bbf5d commit 665cc4c
Show file tree
Hide file tree
Showing 29 changed files with 3,111 additions and 2,709 deletions.
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

0 comments on commit 665cc4c

Please sign in to comment.