Skip to content

Commit

Permalink
Merge pull request #12 from messagebird/fix_mutable_default_value
Browse files Browse the repository at this point in the history
Fix mutable default value with sentinel
  • Loading branch information
samwierema authored Nov 29, 2017
2 parents 2d373cf + 9ba05f5 commit 19250ff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
23 changes: 15 additions & 8 deletions messagebird/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from messagebird.verify import Verify

ENDPOINT = 'https://rest.messagebird.com'
CLIENT_VERSION = '1.2.0'
CLIENT_VERSION = '1.2.1'
PYTHON_VERSION = '%d.%d.%d' % (sys.version_info[0], sys.version_info[1], sys.version_info[2])


Expand All @@ -33,7 +33,8 @@ def __init__(self, access_key):
self.access_key = access_key
self._supported_status_codes = [200, 201, 204, 401, 404, 405, 422]

def request(self, path, method='GET', params={}):
def request(self, path, method='GET', params=None):
if params is None: params = {}
url = urljoin(ENDPOINT, path)

headers = {
Expand Down Expand Up @@ -74,8 +75,9 @@ def message(self, id):
"""Retrieve the information of a specific message."""
return Message().load(self.request('messages/' + str(id)))

def message_create(self, originator, recipients, body, params={}):
def message_create(self, originator, recipients, body, params=None):
"""Create a new message."""
if params is None: params = {}
if type(recipients) == list:
recipients = ','.join(recipients)

Expand All @@ -86,32 +88,37 @@ def voice_message(self, id):
"Retrieve the information of a specific voice message."
return VoiceMessage().load(self.request('voicemessages/' + str(id)))

def voice_message_create(self, recipients, body, params={}):
def voice_message_create(self, recipients, body, params=None):
"""Create a new voice message."""
if params is None: params = {}
if type(recipients) == list:
recipients = ','.join(recipients)

params.update({ 'recipients' : recipients, 'body' : body })
return VoiceMessage().load(self.request('voicemessages', 'POST', params))

def lookup(self, phonenumber, params={}):
def lookup(self, phonenumber, params=None):
"""Do a new lookup."""
if params is None: params = {}
return Lookup().load(self.request('lookup/' + str(phonenumber), 'GET', params))

def lookup_hlr(self, phonenumber, params={}):
def lookup_hlr(self, phonenumber, params=None):
"""Retrieve the information of a specific HLR lookup."""
if params is None: params = {}
return HLR().load(self.request('lookup/' + str(phonenumber) + '/hlr', 'GET', params))

def lookup_hlr_create(self, phonenumber, params={}):
def lookup_hlr_create(self, phonenumber, params=None):
"""Perform a new HLR lookup."""
if params is None: params = {}
return HLR().load(self.request('lookup/' + str(phonenumber) + '/hlr', 'POST', params))

def verify(self, id):
"""Retrieve the information of a specific verification."""
return Verify().load(self.request('verify/' + str(id)))

def verify_create(self, recipient, params={}):
def verify_create(self, recipient, params=None):
"""Create a new verification."""
if params is None: params = {}
params.update({ 'recipient' : recipient })
return Verify().load(self.request('verify', 'POST', params))

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
setup(
name = 'messagebird',
packages = ['messagebird'],
version = '1.2.0',
version = '1.2.1',
description = "MessageBird's REST API",
author = 'MessageBird',
author_email = 'support@messagebird.com',
url = 'https://github.com/messagebird/python-rest-api',
download_url = 'https://github.com/messagebird/python-rest-api/tarball/1.2.0',
download_url = 'https://github.com/messagebird/python-rest-api/tarball/1.2.1',
keywords = ['messagebird', 'sms'],
install_requires = ['requests>=2.4.1'],
license = 'BSD-2-Clause',
Expand Down

0 comments on commit 19250ff

Please sign in to comment.