8000 Move redirect to xml value · codegician/twilio-python@d28056c · GitHub
[go: up one dir, main page]

Skip to content

Commit d28056c

Browse files
committed
Move redirect to xml value
1 parent 1a5da72 commit d28056c

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

tests/unit/twiml/test_messaging_response.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ def test_response(self):
1919

2020
assert_equal(
2121
self.strip(r),
22-
'<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello</Message><Redirect url="example.com" /></Response>'
22+
'<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello</Message><Redirect>example.com</Redirect></Response>'
2323
)
2424

2525
def test_response_chain(self):
2626
r = MessagingResponse().message('Hello').redirect(url='example.com')
2727

2828
assert_equal(
2929
self.strip(r),
30-
'<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello</Message><Redirect url="example.com" /></Response>'
30+
'<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello</Message><Redirect>example.com</Redirect></Response>'
3131
)
3232

3333

@@ -74,5 +74,5 @@ def test_redirect(self):
7474

7575
assert_equal(
7676
self.strip(r),
77-
'<?xml version="1.0" encoding="UTF-8"?><Response><Redirect url="example.com" /></Response>'
77+
'<?xml version="1.0" encoding="UTF-8"?><Response><Redirect>example.com</Redirect></Response>'
7878
)

twilio/twiml/messaging_response.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ def message(self,
4242
**kwargs
4343
))
4444

45-
def redirect(self, method=None, url=None, **kwargs):
45+
def redirect(self, url, method=None, **kwargs):
4646
"""
4747
Add a <Redirect> element
4848
49-
:param method: HTTP method
5049
:param url: URL to redirect to
50+
:param method: HTTP method
5151
:param kwargs: other attributes
5252
:return: <Redirect> element
5353
"""
@@ -124,5 +124,12 @@ class Redirect(TwiML):
124124
"""
125125
<Redirect> element
126126
"""
127-
pass
127+
def __init__(self, url, **kwargs):
128+
"""
129+
Create a new <Redirect> element
130+
131+
:param url: redirect URL location
132+
"""
133+
super(Redirect, self).__init__(**kwargs)
134+
self.value = url
128135

0 commit comments

Comments
 (0)
0