1
1
class Domain (object ):
2
+ """
3
+ This represents at Twilio API subdomain.
4
+
5
+ Like, `api.twilio.com` or `lookups.twilio.com'.
6
+ """
2
7
def __init__ (self , twilio ):
3
8
"""
4
9
:param Twilio twilio:
@@ -8,10 +13,27 @@ def __init__(self, twilio):
8
13
self .base_url = None
9
14
10
15
def absolute_url (self , uri ):
16
+ """
17
+ Converts a relative `uri` to an absolute url.
18
+ :param string uri: The relative uri to make absolute.
19
+ :return: An absolute url (based off this domain)
20
+ """
11
21
return '{}/{}' .format (self .base_url .strip ('/' ), uri .strip ('/' ))
12
22
13
23
def request (self , method , uri , params = None , data = None , headers = None ,
14
24
auth = None , timeout = None , allow_redirects = False ):
25
+ """
26
+ Makes an HTTP request to this domain.
27
+ :param string method: The HTTP method.
28
+ :param string uri: The HTTP uri.
29
+ :param dict params: Query parameters.
30
+ :param object data: The request body.
31
+ :param dict headers: The HTTP headers.
32
+ :param tuple auth: Basic auth tuple of (username, password)
33
+ :param int timeout: The request timeout.
34
+ :param bool allow_redirects: True if the client should follow HTTP
35
+ redirects.
36
+ """
15
37
url = self .absolute_url (uri )
16
38
return self .twilio .request (
17
39
method ,
0 commit comments