8000 Fix region support · robscc/twilio-python@e8d01c2 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e8d01c2

Browse files
committed
Fix region support
1 parent 18a80b2 commit e8d01c2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

examples/basic_usage.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import os
22

3-
from twilio.twiml import Response
4-
53
from twilio.rest import Client
4+
from twilio.twiml.voice_response import VoiceResponse
65

76
ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID')
87
AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN')
@@ -35,10 +34,10 @@ def example():
3534
new_call = client.calls.create(to='XXXX', from_='YYYY', method='GET')
3635

3736
print('Serving TwiML')
38-
twiml_response = Response()
37+
twiml_response = VoiceResponse()
3938
twiml_response.say('Hello!')
4039
twiml_response.hangup()
41-
twiml_xml = twiml_response.toxml()
40+
twiml_xml = twiml_response.to_xml()
4241
print('Generated twiml: {}'.format(twiml_xml))
4342

4443

twilio/rest/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@ def request(self, method, uri, params=None, data=None, headers=None, auth=None,
9999
if 'Accept' not in headers:
100100
headers['Accept'] = 'application/json'
101101

102+
102103
if self.region:
103104
head, tail = uri.split('.', 1)
104-
uri = '.'.join([head, self.region, tail])
105+
106+
if not tail.startswith(self.region):
107+
uri = '.'.join([head, self.region, tail])
105108

106109
return self.http_client.request(
107110
method,

0 commit comments

Comments
 (0)
0