8000 Merge branch 'release-3.2.1' · MC6/twilio-python@37c71d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 37c71d4

Browse files
committed
Merge branch 'release-3.2.1'
2 parents 426fe43 + 7be2d9b commit 37c71d4

File tree

7 files changed

+35
-8
lines changed

7 files changed

+35
-8
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
# The short X.Y version.
5757
version = '3.2'
5858
# The full version, including alpha/beta/rc tags.
59-
release = '3.2.0'
59+
release = '3.2.1'
6060

6161
# The language for content autogenerated by Sphinx. Refer to documentation
6262
# for a list of supported languages.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup, find_packages
22
setup(
33
name = "twilio",
4-
version = "3.2.0",
4+
version = "3.2.1",
55
description = "Twilio API client and TwiML generator",
66
author = "Twilio",
77
author_email = "help@twilio.com",

tests/test_make_request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
44
Uses the awesome httpbin.org to validate responses
55
"""
6-
76
import json
7+
import twilio
88
from nose.tools import assert_equals
99
from nose.tools import raises
1010
from mock import patch
@@ -14,7 +14,7 @@
1414
from twilio.rest.resources import make_twilio_request
1515

1616
get_headers = {
17-
"User-Agent": "twilio-python",
17+
"User-Agent": "twilio-python/{}".format(twilio.__version__),
1818
"Accept": "application/json",
1919
}
2020

tests/test_twiml.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,20 @@ def testAddConference(self):
330330
r = self.strip(r)
331331
self.assertEquals(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Conference>My Room</Conference></Dial></Response>')
332332

333+
def test_add_empty_client(self):
334+
""" add an empty client to a dial"""
335+
r = Response()
336+
d = r.dial()
337+
d.client("")
338+
self.assertEquals(str(r), '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Client /></Dial></Response>')
339+
340+
def test_add_client(self):
341+
""" add a client to a dial"""
342+
r = Response()
343+
d = r.dial()
344+
d.client("alice")
345+
self.assertEquals(str(r), '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Client>alice</Client></Dial></Response>')
346+
333347
def testAddConferenceConvenceMethod(self):
334348
""" add a conference to a dial, conviently"""
335349
r = Response()

twilio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version_info__ = ('3', '2', '0')
1+
__version_info__ = ('3', '2', '1')
22
__version__ = '.'.join(__version_info__)
33

44

twilio/rest/resources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22
import logging
3-
3+
import twilio
44
from twilio import TwilioException
55
from twilio import TwilioRestException
66
from urllib import urlencode
@@ -144,7 +144,7 @@ def make_twilio_request(method, uri, **kwargs):
144144
Make a request to Twilio. Throws an error
145145
"""
146146
headers = kwargs.get("headers", {})
147-
headers["User-Agent"] = "twilio-python/3.2.0" # Add user aggent string
147+
headers["User-Agent"] = "twilio-python/%s" % twilio.__version__
148148

149149
if method == "POST" and "Content-Type" not in headers:
150150
headers["Content-Type"] = "application/x-www-form-urlencoded"

twilio/twiml.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,16 @@ def __init__(self, number, sendDigits=None, **kwargs):
315315
self.body = number
316316

317317

318+
class Client(Verb):
319+
"""Specify a client name to call in a nested Dial element.
320+
321+
:param name: Client name to connect to
322+
"""
323+
def __init__(self, name, **kwargs):
324+
Verb.__init__(self, **kwargs)
325+
self.body = name
326+
327+
318328
class Sms(Verb):
319329
""" Send a Sms Message to a phone number
320330
@@ -375,7 +385,7 @@ class Dial(Verb):
375385

376386
def __init__(self, number=None, action=None, method=None, **kwargs):
377387
Verb.__init__(self, action=action, method=method, **kwargs)
378-
self.nestables = ['Number', 'Conference']
388+
self.nestables = ['Number', 'Conference', 'Client']
379389
if number and len(number.split(',')) > 1:
380390
for n in number.split(','):
381391
self.append(Number(n.strip()))
@@ -385,6 +395,9 @@ def __init__(self, number=None, action=None, method=None, **kwargs):
385395
raise TwimlException( \
386396
"Invalid method parameter, must be GET or POST")
387397

398+
def client(self, name, **kwargs):
399+
return self.append(Client(name, **kwargs))
400+
388401
def number(self, number, **kwargs):
389402
return self.append(Number(number, **kwargs))
390403

0 commit comments

Comments
 (0)
0