2828
2929def find_credentials ():
3030 """
31- Look in the current environment for Twilio credentails
31+ Look in the current environment for Twilio credentials
3232 """
3333 try :
3434 account = os .environ ["TWILIO_ACCOUNT_SID" ]
@@ -41,59 +41,13 @@ def find_credentials():
4141class TwilioRestClient (object ):
4242 """
4343 A client for accessing the Twilio REST API
44- """
45-
46- def request (self , path , method = None , vars = None ):
47- """sends a request and gets a response from the Twilio REST API
48-
49- .. deprecated:: 3.0
50-
51- :param path: the URL (relative to the endpoint URL, after the /v1
52- :param url: the HTTP method to use, defaults to POST
53- :param vars: for POST or PUT, a dict of data to send
54-
55- :returns: Twilio response in XML or raises an exception on error
56-
57- This method is only included for backwards compatability reasons.
58- It will be removed in a future version
59- """
60- logging .warning (":meth:`TwilioRestClient.request` is deprecated and "
61- "will be removed in a future version" )
62-
63- vars = vars or {}
64- params = None
65- data = None
66-
67- if not path or len (path ) < 1 :
68- raise ValueError ('Invalid path parameter' )
69- if method and method not in ['GET' , 'POST' , 'DELETE' , 'PUT' ]:
70- raise NotImplementedError (
71- 'HTTP %s method not implemented' % method )
72-
73- if path [0 ] == '/' :
74- uri = self .base + path
75- else :
76- uri = self .base + '/' + path
77-
78- if method == "GET" :
79- params = vars
80- elif method == "POST" or method == "PUT" :
81- data = vars
8244
83- user_agent = "twilio-python %s (python-%s)" % (
84- LIBRARY_VERSION ,
85- platform .python_version (),
86- )
87-
88- headers = {
89- "User-Agent" : user_agent ,
90- "Accept-Charset" : "utf-8" ,
91- }
92-
93- resp = make_request (method , uri , auth = self .auth , data = data ,
94- params = params , headers = headers )
95-
96- return resp .content
45+ :param str account: Your Account SID from `your dashboard
46+ <https://twilio.com/user/account>`_
47+ :param str token: Your Auth Token from `your dashboard
48+ <https://twilio.com/user/account>`_
49+ :param float timeout: The socket and read timeout for making requests to Twilio
50+ """
9751
9852 def __init__ (self , account = None , token = None , base = "https://api.twilio.com" ,
9953 version = "2010-04-01" , client = None , timeout = UNSET_TIMEOUT ):
@@ -154,16 +108,70 @@ def __init__(self, account=None, token=None, base="https://api.twilio.com",
154108
155109 def participants (self , conference_sid ):
156110 """
157- Return a :class:`Participants` instance for the :class:`Conference`
158- with the given conference_sid
111+ Return a :class:`~twilio.rest.resources. Participants` instance for the
112+ :class:`~twilio.rest.resources.Conference` with the given conference_sid
159113 """
160114 base_uri = "{}/Conferences/{}" .format (self .account_uri , conference_sid )
161115 return Participants (base_uri , self .auth , self .timeout )
162116
163117 def members (self , queue_sid ):
164118 """
165- Return a :class:`Members` instance for the :class:`Queue`
166- with the given queue_sid
119+ Return a :class:`Members <twilio.rest.resources.Members> ` instance for
120+ the :class:`Queue <twilio.rest.resources.Queue>` with the given queue_sid
167121 """
168122 base_uri = "{}/Queues/{}" .format (self .account_uri , queue_sid )
169123 return Members (base_uri , self .auth , self .timeout )
124+
125+
126+ def request (self , path , method = None , vars = None ):
127+ """sends a request and gets a response from the Twilio REST API
128+
129+ .. deprecated:: 3.0
130+
131+ :param path: the URL (relative to the endpoint URL, after the /v1
132+ :param url: the HTTP method to use, defaults to POST
133+ :param vars: for POST or PUT, a dict of data to send
134+
135+ :returns: Twilio response in XML or raises an exception on error
136+
137+ This method is only included for backwards compatability reasons.
138+ It will be removed in a future version
139+ """
140+ logging .warning (":meth:`TwilioRestClient.request` is deprecated and "
141+ "will be removed in a future version" )
142+
143+ vars = vars or {}
144+ params = None
145+ data = None
146+
147+ if not path or len (path ) < 1 :
148+ raise ValueError ('Invalid path parameter' )
149+ if method and method not in ['GET' , 'POST' , 'DELETE' , 'PUT' ]:
150+ raise NotImplementedError (
151+ 'HTTP %s method not implemented' % method )
152+
153+ if path [0 ] == '/' :
154+ uri = self .base + path
155+ else :
156+ uri = self .base + '/' + path
157+
158+ if method == "GET" :
159+ params = vars
160+ elif method == "POST" or method == "PUT" :
161+ data = vars
162+
163+ user_agent = "twilio-python %s (python-%s)" % (
164+ LIBRARY_VERSION ,
165+ platform .python_version (),
166+ )
167+
168+ headers = {
169+ "User-Agent" : user_agent ,
170+ "Accept-Charset" : "utf-8" ,
171+ }
172+
173+ resp = make_request (method , uri , auth = self .auth , data = data ,
174+ params = params , headers = headers )
175+
176+ return resp .content
177+
0 commit comments