23
23
OTHER DEALINGS IN THE SOFTWARE.
24
24
"""
25
25
26
- __VERSION__ = "2.0.1 "
26
+ __VERSION__ = "2.0.2 "
27
27
28
28
import urllib , urllib2 , base64 , hmac
29
29
from hashlib import sha1
@@ -166,6 +166,7 @@ def __init__(self, **kwargs):
166
166
self .verbs = []
167
167
self .attrs = {}
168
168
for k , v in kwargs .items ():
169
+ if k == "sender" : k = "from"
169
170
if v : self .attrs [k ] = quoteattr (str (v ))
170
171
171
172
def __repr__ (self ):
@@ -224,6 +225,9 @@ def addDial(self, number=None, **kwargs):
224
225
225
226
def addRecord (self , ** kwargs ):
226
227
return self .append (Record (** kwargs ))
228
+
229
+ def addConference (self , ** kwargs ):
230
+ return self .append (Conference (** kwargs ))
227
231
228
232
class Response (Verb ):
229
233
"""Twilio response object.
@@ -233,7 +237,7 @@ class Response(Verb):
233
237
def __init__ (self , version = None , ** kwargs ):
234
238
Verb .__init__ (self , version = version , ** kwargs )
235
239
self .nestables = ['Say' , 'Play' , 'Gather' , 'Record' , 'Dial' ,
236
- 'Redirect' , 'Pause' , 'Hangup' ]
240
+ 'Redirect' , 'Pause' , 'Hangup' , 'Sms' ]
237
241
238
242
class Say (Verb ):
239
243
"""Say text
@@ -328,6 +332,26 @@ class Number(Verb):
328
332
def __init__ (self , number , sendDigits = None , ** kwargs ):
329
333
Verb .__init__ (self , sendDigits = sendDigits , ** kwargs )
330
334
self .body = number
335
+
336
+ class Sms (Verb ):
337
+ """ Send a Sms Message to a phone number
338
+
339
+ to: whom to send message to, defaults based on the direction of the call
340
+ sender: whom to send message from.
341
+ action: url to request after the message is queued
342
+ method: submit to 'action' url using GET or POST
343
+ statusCallback: url to hit when the message is actually sent
344
+ """
345
+ GET = 'GET'
346
+ POST = 'POST'
347
+
348
+ def __init__ (self , msg , to = None , sender = None , method = None , action = None ,
349
+ statusCallback = None , ** kwargs ):
350
+ Verb .__init__ (self , action = action , method = method , to = to , sender = sender ,
351
+ statusCallback = statusCallback , ** kwargs )
352
+ if method and (method != self .GET and method != self .POST ):
353
+ raise TwilioException ( \
354
+ "Invalid method parameter, must be GET or POST" )
331
355
332
356
class Conference (Verb ):
333
357
"""Specify conference in a nested Dial element.
0 commit comments