Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e760619

Browse files
committed
Add Region support
1 parent 985de29 commit e760619

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

twilio/rest/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Client(object):
2626
""" A client for accessing the Twilio API. """
2727

2828
def __init__(self, username=None, password=None, account_sid=None,
29-
http_client=None, environment=None):
29+
http_client=None, environment=None, region=None):
3030
"""
3131
Initializes the Twilio Client
3232
@@ -55,7 +55,9 @@ def __init__(self, username=None, password=None, account_sid=None,
5555
""" :type : tuple(str, str) """
5656
self.http_client = http_client or Httplib2Client()
5757
""" :type : HttpClient """
58-
58+
self.region = region
59+
""" :type: str"""
60+
5961
# Domains
6062
self._api = None
6163
self._ip_messaging = None
@@ -99,7 +101,11 @@ def request(self, method, uri, params=None, data=None, headers=None, auth=None,
99101

100102
if 'Accept' not in headers:
101103
headers['Accept'] = 'application/json'
102-
104+
105+
if self.region:
106+
parts = uri.split('.')
107+
uri = '.'.join([parts[0], self.region] + parts[1:])
108+
103109
return self.http_client.request(
104110
method,
105111
uri,

0 commit comments

Comments
 (0)