Skip to content

Commit

Permalink
Added sms and voice routes. Set up command line parsing in configure.…
Browse files Browse the repository at this point in the history
… Added trollop gem
  • Loading branch information
labcoder committed May 17, 2012
1 parent e5cb2cc commit 71877aa
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Gemfile
@@ -1,4 +1,5 @@
source :rubygems
gem 'sinatra'
gem 'thin'
gem 'twilio-ruby'
gem 'twilio-ruby'
gem 'trollop'
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -20,6 +20,7 @@ GEM
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
tilt (1.3.3)
trollop (1.16.2)
twilio-ruby (3.7.0)
builder (>= 2.1.2)
jwt (>= 0.1.2)
Expand All @@ -31,4 +32,5 @@ PLATFORMS
DEPENDENCIES
sinatra
thin
trollop
twilio-ruby
20 changes: 16 additions & 4 deletions app.rb
Expand Up @@ -7,15 +7,27 @@ def get_or_post(path, opts={}, &block)
post(path, opts, &block)
end

get_or_post '/' do
# Home page and reference
get '/' do
@title = "Home"
erb :home
end

get '/voice/?' do
#build response
# Voice Request URL
get_or_post '/voice/?' do
response = Twilio::TwiML::Response.new do |r|
r.Say 'Hello' , :voice => 'woman'
r.Say 'Congratulations! You\'ve successfully deployed' \
'the Twilio HackPack for Heroku and Sinatra!'
,:voice => 'woman'
end
response.text
end

# SMS Request URL
get_or_post '/sms/?' do
response = Twilio::TwiML::Response.new do |r|
r.Sms 'Congratulations! You\'ve successully deployed' \
'the Twilio HackPack for Heroku and Sinatra!'
end
response.text
end
39 changes: 35 additions & 4 deletions configure.rb
Expand Up @@ -2,18 +2,49 @@
Hackpack Configure
A script to configure your TwiML apps and Twilio phone numbers to use in
your hackpack's Heroku app.
USAGE:
Just run this file:
See what this thing can do:
ruby configure.rb -h | --help
Let me figure out what needs to be done:
ruby configure.rb
Set up an app with a new app ID and number:
ruby configure.rb -n | --new
Set up app with specific App Sid:
ruby configure.rb -a APxxxxxxxxxxxxxx | --app APxxxxxxxxxxxxxx
Set up app with Specific Twilio Number:
ruby configure.rb -c +15556667777 | --caller +15556667777
Set up app with custom domain:
ruby configure.rb -d example.com | --domain example.com
=end

require 'trollop'

opts = Trollop::options do
version "Twilio HackPack for Heroku and Sinatra v0.1 (c) 2012 Oscar Sanchez"
banner "USAGE: ruby configure.rb [options]\n" \
"where [options] are:"
opt :new, "We need to set up a new AppSID and Number"
opt :app, "Use this Twilio App SID", :type => :string
opt :caller, "Use this Twilio Number", :type => :string
opt :domain, "Use this custom Domain", :type => :string
end

#p opts

=begin
puts "Enter your twilio SID:"
TWILIO_ACCOUNT_SID = STDIN.gets.chomp()
puts "Enter your twilio auth token:"
TWILIO_AUTH_TOKEN = STDIN.gets.chomp()
ENV['TWILIO_ACCOUNT_SID'] = TWILIO_ACCOUNT_SID
ENV['TWILIO_AUTH_TOKEN'] = TWILIO_AUTH_TOKEN
ENV['TWILIO_AUTH_TOKEN'] = TWILIO_AUTH_TOKEN
=end

0 comments on commit 71877aa

Please sign in to comment.