Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding more examples & adding caller id pages

  • Loading branch information...
commit 68d30116241883f9e1af2358e81a23bcd8f6a8ee 1 parent 5047f49
@arfrank authored
View
20 handlers/main.py
@@ -30,7 +30,7 @@
from libraries.gaesessions import get_current_session
-from models import accounts, incoming_phone_numbers, phone_numbers, calls, messages, twimls
+from models import accounts, incoming_phone_numbers, outgoing_caller_ids, phone_numbers, calls, messages, twimls
from helpers import application, authorization, request, twiml
@@ -469,9 +469,25 @@ class Test(webapp.RequestHandler):
except Exception, e:
print e
+class CallerIds(webapp.RequestHandler):
+ @webapp_decorator.check_logged_in
+ def get(self):
+ self.data['PhoneNumbers'] = outgoing_caller_ids.Outgoing_Caller_Id.all().filter('AccountSid =',self.data['Account'].Sid)
+ path = os.path.join(os.path.dirname(__file__), '../templates/caller-ids.html')
+ self.response.out.write(template.render(path,{'data':self.data}))
+
+
+class CallerId(webapp.RequestHandler):
+ @webapp_decorator.check_logged_in
+ def get(self, Sid):
+ path = os.path.join(os.path.dirname(__file__), '../templates/caller-id.html')
+ self.response.out.write(template.render(path,{'data':self.data}))
+
class Examples(webapp.RequestHandler):
@webapp_decorator.check_logged_in
def get(self):
+ import urlparse
+ self.data['host'] = urlparse.urlparse(self.request.url).netloc
path = os.path.join(os.path.dirname(__file__), '../templates/examples.html')
self.response.out.write(template.render(path,{'data':self.data}))
@@ -490,6 +506,8 @@ def main():
('/examples',Examples),
('/calls', Calls),
('/calls/(.*)',Call),
+ ('/caller-ids',CallerIds),
+ ('/caller-ids/(.*)',CallerId),
('/phone-numbers',PhoneNumbers),
('/phone-numbers/sms/(.*)',FakeSms),
('/phone-numbers/voice/(.*)',FakeVoice),
View
2  models/outgoing_caller_ids.py
@@ -8,5 +8,5 @@
from helpers import parameters
-class OutGoing_Caller_Id(phone_numbers.Phone_Number):
+class Outgoing_Caller_Id(phone_numbers.Phone_Number):
pass
View
3  templates/account.html
@@ -11,7 +11,8 @@ <h1 id="account_information">Account Information</h1>
</p>
<h2>Links</h2>
<p>
- <a href="/phone-numbers">Phone Numbers</a><br>
+ <a href="/caller-ids">Caller Ids</a><br>
+ <a href="/phone-numbers">Incoming Phone Numbers</a><br>
<a href="/examples">Example API Calls</a><br>
<a href="/calls">Calls</a><br>
<a href="/logout">Logout</a>
View
6 templates/caller-id.html
@@ -0,0 +1,6 @@
+{% extends "../templates/base.html" %}
+{% block 'content' %}
+ <h1 id="account_information">Outgoing Phone Numbers</h1>
+ <div id="content">
+ </div>
+{% endblock %}
View
12 templates/caller-ids.html
@@ -0,0 +1,12 @@
+{% extends "../templates/base.html" %}
+{% block 'content' %}
+ <h1 id="account_information">Outgoing Phone Numbers</h1>
+ <div id="content">
+ <h2>Select a Phone Number</h2>
+ {% for phone_number in data.PhoneNumbers %}
+ <div id="" class="PhoneNumber">
+ <a href="/phone-numbers/{{phone_number.Sid}}">{{phone_number.FriendlyName}} {{phone_number.PhoneNumber}}</a>
+ </div>
+ {%endfor%}
+ </div>
+{% endblock %}
View
37 templates/examples.html
@@ -3,13 +3,34 @@
<h1 id="fake_twilio_api">Fake Twilio API Examples</h1>
<div id="content">
<h2>Messages</h2>
- <p class="wrap">
- curl {{data.Account.Sid}}:{{data.Account.AuthToken}}@localhost:8094/2010-04-01/Accounts/{{data.Account.Sid}}/SMS/Messages.json
- </p>
- <h2>Phone Numbers</h2>
- <h3>Requisition a number with Area Code(301) and assign a Friendly Name</h3>
- <p class="wrap">
- curl -d "AreaCode=301&amp;FriendlyName=Phone Number Example" --user {{data.Account.Sid}}:{{data.Account.AuthToken}} localhost:8094/2010-04-01/Accounts/{{data.Account.Sid}}/IncomingPhoneNumbers.json
- </p>
+ <li>Retrieve a list of messages sent
+ <p class="wrap">
+ curl {{data.Account.Sid}}:{{data.Account.AuthToken}}@{{data.host}}/2010-04-01/Accounts/{{data.Account.Sid}}/SMS/Messages.json
+ </p>
+ </li>
+ <h2>Incoming Phone Numbers</h2>
+ <li>Requisition an incoming number with Area Code(301) and assign a Friendly Name
+ <p class="wrap">
+ curl -d "AreaCode=301&amp;FriendlyName=Phone Number Example" --user {{data.Account.Sid}}:{{data.Account.AuthToken}} {{data.host}}/2010-04-01/Accounts/{{data.Account.Sid}}/IncomingPhoneNumbers.json
+ </p>
+ </li>
+ <li>Get an incoming phone numbers information
+ <p class="wrap">
+ curl --user {{data.Account.Sid}}:{{data.Account.AuthToken}} {{data.host}}/2010-04-01/Accounts/{{data.Account.Sid}}/IncomingPhoneNumbers/*SID*
+ </p>
+
+ </li>
+ <li>Update an incoming phone number's VoiceUrl and FriendlyName
+ <p class="wrap">
+ curl -d "FriendlyName=TVSHOW&amp;VoiceUrl=http://www.cnn.com" --user {{data.Account.Sid}}:{{data.Account.AuthToken}} {{data.host}}/2010-04-01/Accounts/{{data.Account.Sid}}/IncomingPhoneNumbers/*SID*
+ </p>
+ </li>
+ <li>Delete an incoming phone number
+ <p class="wrap">
+ curl -v -X DELETE --user {{data.Account.Sid}}:{{data.Account.AuthToken}} {{data.host}}/2010-04-01/Accounts/{{data.Account.Sid}}/IncomingPhoneNumbers/*SID*
+
+ </p>
+ </li>
</div>
+
{% endblock %}
Please sign in to comment.
Something went wrong with that request. Please try again.