8000 update rest api example for 2010-04-01 api, add 2010-04-01 Reject verb · isbo/twilio-python@d3bf850 · GitHub
[go: up one dir, main page]

Skip to content

Commit d3bf850

Browse files
author
phy
committed
update rest api example for 2010-04-01 api, add 2010-04-01 Reject verb
1 parent 81c6e10 commit d3bf850

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

README.markdown

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ Download the source and run
1515
$ python setup.py install
1616

1717
### Usage
18-
To use the Twilio library, just 'import
19-
twilio' in the your current py file. As shown in example-rest.py, you will need to specify the ACCOUNT_ID and ACCOUNT_TOKEN given to you by Twilio before you can make REST requests. In
20-
addition, you will need to choose a 'Caller' and 'Called' before making
18+
To use the Twilio library, just 'import twilio' in the your current python
19+
file. As shown in example-rest.py, you will need to specify the ACCOUNT_ID and
20+
ACCOUNT_TOKEN given to you by Twilio before you can make REST requests. In
21+
addition, you will need to choose a 'To' and 'From' before making
2122
outgoing calls. See http://www.twilio.com/docs for more information.
2223

2324
### Files

examples/example-rest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import twilio
44

55
# Twilio REST API version
6-
API_VERSION = '2008-08-01'
6+
API_VERSION = '2010-04-01'
77

88
# Twilio AccountSid and AuthToken
99
ACCOUNT_SID = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
@@ -19,8 +19,8 @@
1919
# 1. Initiate a new outbound call to 415-555-1212
2020
# uses a HTTP POST
2121
d = {
22-
'Caller' : CALLER_ID,
23-
'Called' : '415-555-1212',
22+
'From' : CALLER_ID,
23+
'To' : '415-555-1212',
2424
'Url' : 'http://demo.twilio.com/welcome',
2525
}
2626
try:

setup.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
setup(
33
name = "twilio",
44
py_modules = ['twilio'],
5-
version = "2.0.7",
5+
version = "2.0.8",
66
description = "Twilio API client and TwiML generator",
77
author = "Twilio",
88
author_email = "help@twilio.com",
@@ -28,12 +28,12 @@
2828
and much more. See http://www.twilio.com/docs for more information.
2929
3030
USAGE
31-
To use the Twilio library, just 'import twilio' in the your current py file.
32-
As shown in example-rest.py, you will need to specify the ACCOUNT_ID and ACCOUNT_TOKEN given to you by Twilio before you can make REST requests. In
33-
addition, you will need to choose a 'Caller' and 'Called' before making
34-
outgoing calls. See http://www.twilio.com/docs for more information.
31+
To use the Twilio library, just 'import twilio' in the your current py
32+
file. As shown in example-rest.py, you will need to specify the ACCOUNT_ID
33+
and ACCOUNT_TOKEN given to you by Twilio before you can make REST
34+
requests. In addition, you will need to choose a 'To' and 'From' before
35+
making outgoing calls. See http://www.twilio.com/docs for more
36+
information.
3537
36-
LICENSE
37-
The Twilio Python Helper Library is distributed under the MIT License
38-
"""
39-
)
38+
LICENSE The Twilio Python Helper Library is distributed under the MIT
39+
License """ )

twilio.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ class Number(Verb):
344344
def __init__(self, number, sendDigits=None, **kwargs):
345345
Verb.__init__(self, sendDigits=sendDigits, **kwargs)
346346
self.body = number
347-
347+
348348
class Sms(Verb):
349349
""" Send a Sms Message to a phone number
350350
@@ -432,6 +432,20 @@ def __init__(self, action=None, method=None, maxLength=None,
432432
raise TwilioException( \
433433
"Invalid method parameter, must be GET or POST")
434434

435+
class Reject(Verb):
436+
"""Reject an incoming call
437+
438+
reason: message to play when rejecting a call
439+
"""
440+
REJECTED = 'rejected'
441+
BUSY = 'busy'
442+
443+
def __init__(self, reason=None, **kwargs):
444+
Verb.__init__(self, reason=reason, **kwargs)
445+
if reason and (reason != self.REJECTED and reason != self.BUSY):
446+
raise TwilioException( \
447+
"Invalid reason parameter, must be BUSY or REJECTED")
448+
435449
# Twilio Utility function and Request Validation
436450
# ===========================================================================
437451

0 commit comments

Comments
 (0)
0