2323OTHER DEALINGS IN THE SOFTWARE.
2424"""
2525
26- __VERSION__ = "2.0.1 "
26+ __VERSION__ = "2.0.2 "
2727
2828import urllib , urllib2 , base64 , hmac
2929from hashlib import sha1
@@ -166,6 +166,7 @@ def __init__(self, **kwargs):
166166 self .verbs = []
167167 self .attrs = {}
168168 for k , v in kwargs .items ():
169+ if k == "sender" : k = "from"
169170 if v : self .attrs [k ] = quoteattr (str (v ))
170171
171172 def __repr__ (self ):
@@ -224,6 +225,9 @@ def addDial(self, number=None, **kwargs):
224225
225226 def addRecord (self , ** kwargs ):
226227 return self .append (Record (** kwargs ))
228+
229+ def addConference (self , ** kwargs ):
230+ return self .append (Conference (** kwargs ))
227231
228232class Response (Verb ):
229233 """Twilio response object.
@@ -233,7 +237,7 @@ class Response(Verb):
233237 def __init__ (self , version = None , ** kwargs ):
234238 Verb .__init__ (self , version = version , ** kwargs )
235239 self .nestables = ['Say' , 'Play' , 'Gather' , 'Record' , 'Dial' ,
236- 'Redirect' , 'Pause' , 'Hangup' ]
240+ 'Redirect' , 'Pause' , 'Hangup' , 'Sms' ]
237241
238242class Say (Verb ):
239243 """Say text
@@ -328,6 +332,26 @@ class Number(Verb):
328332 def __init__ (self , number , sendDigits = None , ** kwargs ):
329333 Verb .__init__ (self , sendDigits = sendDigits , ** kwargs )
330334 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" )
331355
332356class Conference (Verb ):
333357 """Specify conference in a nested Dial element.
0 commit comments