Permalink
Browse files

Version 3.0.0 - see changelog for new and breaking changes

  • Loading branch information...
1 parent 393d907 commit 564d99add6b40699e0cdffda318b03ff03a07cb0 @philm committed Mar 26, 2011
Showing with 877 additions and 944 deletions.
  1. +27 −0 CHANGELOG.rdoc
  2. +1 −6 Gemfile
  3. +16 −4 README.rdoc
  4. +5 −32 Rakefile
  5. +0 −5 VERSION.yml
  6. +18 −4 lib/twilio.rb
  7. +1 −1 lib/twilio/account.rb
  8. +15 −13 lib/twilio/available_phone_numbers.rb
  9. +4 −4 lib/twilio/call.rb
  10. +6 −6 lib/twilio/conference.rb
  11. +0 −26 lib/twilio/connection.rb
  12. +16 −2 lib/twilio/incoming_phone_number.rb
  13. +0 −26 lib/twilio/local_phone_number.rb
  14. +2 −2 lib/twilio/notification.rb
  15. +5 −4 lib/twilio/outgoing_caller_id.rb
  16. +2 −2 lib/twilio/recording.rb
  17. +2 −2 lib/twilio/sms.rb
  18. +0 −26 lib/twilio/toll_free_phone_number.rb
  19. +8 −5 lib/twilio/twilio_object.rb
  20. +1 −1 lib/twilio/version.rb
  21. +23 −0 spec/fixtures/xml/account.xml
  22. 0 {test → spec}/fixtures/xml/account_renamed.xml
  23. 0 {test → spec}/fixtures/xml/available_phone_numbers_local.xml
  24. 0 {test → spec}/fixtures/xml/available_phone_numbers_local_search.xml
  25. 0 {test → spec}/fixtures/xml/available_phone_numbers_toll_free.xml
  26. 0 {test → spec}/fixtures/xml/available_phone_numbers_toll_free_search.xml
  27. 0 {test → spec}/fixtures/xml/call.xml
  28. 0 {test → spec}/fixtures/xml/call_new.xml
  29. 0 {test → spec}/fixtures/xml/call_redirected.xml
  30. 0 {test → spec}/fixtures/xml/calls.xml
  31. +1 −1 {test → spec}/fixtures/xml/conference.xml
  32. 0 {test → spec}/fixtures/xml/conference_participant.xml
  33. 0 {test → spec}/fixtures/xml/conference_participant_muted.xml
  34. 0 {test → spec}/fixtures/xml/conference_participants.xml
  35. 0 {test → spec}/fixtures/xml/conferences.xml
  36. 0 {test → spec}/fixtures/xml/incoming_phone_number.xml
  37. 0 {test → spec}/fixtures/xml/incoming_phone_numbers.xml
  38. 0 {test → spec}/fixtures/xml/notification.xml
  39. 0 {test → spec}/fixtures/xml/notifications.xml
  40. 0 {test → spec}/fixtures/xml/outgoing_caller_id.xml
  41. 0 {test → spec}/fixtures/xml/outgoing_caller_id_new.xml
  42. 0 {test → spec}/fixtures/xml/outgoing_caller_ids.xml
  43. 0 {test → spec}/fixtures/xml/recording.xml
  44. 0 {test → spec}/fixtures/xml/recordings.xml
  45. 0 {test → spec}/fixtures/xml/sms.xml
  46. 0 {test → spec}/fixtures/xml/sms_messages.xml
  47. 0 {test → spec}/fixtures/xml/sms_new.xml
  48. 0 {test → spec}/fixtures/xml/sms_new_with_callback.xml
  49. 0 {test → spec}/fixtures/xml/transcription.xml
  50. 0 {test → spec}/fixtures/xml/transcriptions.xml
  51. 0 {test → spec}/fixtures/yml/verb_responses.yml
  52. +17 −0 spec/spec_helper.rb
  53. +52 −0 spec/support/twilio_helpers.rb
  54. +21 −0 spec/twilio/account_spec.rb
  55. +53 −0 spec/twilio/available_phone_numbers_spec.rb
  56. +64 −0 spec/twilio/call_spec.rb
  57. +58 −0 spec/twilio/conference_spec.rb
  58. +42 −0 spec/twilio/incoming_phone_number_spec.rb
  59. +21 −0 spec/twilio/live_connection_spec.rb
  60. +29 −0 spec/twilio/notification_spec.rb
  61. +43 −0 spec/twilio/outgoing_caller_id_spec.rb
  62. +44 −0 spec/twilio/recording_spec.rb
  63. +36 −0 spec/twilio/sms_spec.rb
  64. +235 −0 spec/twilio/verb_spec.rb
  65. +0 −11 test/fixtures/xml/account.xml
  66. +0 −33 test/test_helper.rb
  67. +0 −28 test/twilio/account_test.rb
  68. +0 −43 test/twilio/available_phone_numbers_test.rb
  69. +0 −66 test/twilio/call_test.rb
  70. +0 −46 test/twilio/conference_test.rb
  71. +0 −25 test/twilio/connection_test.rb
  72. +0 −31 test/twilio/incoming_phone_number_test.rb
  73. +0 −37 test/twilio/local_phone_number_test.rb
  74. +0 −35 test/twilio/notification_test.rb
  75. +0 −45 test/twilio/outgoing_caller_id_test.rb
  76. +0 −47 test/twilio/recording_test.rb
  77. +0 −27 test/twilio/sms_test.rb
  78. +0 −38 test/twilio/toll_free_phone_number_test.rb
  79. +0 −244 test/twilio/verb_test.rb
  80. +9 −16 twilio.gemspec
View
@@ -0,0 +1,27 @@
+= Twilio Gem Changelog
+
+== 3.0
+
+* SSL validation (thanks Kyle Humberto)
+* Available phone numbers search support (thanks Mark Turner)
+* Deprecated Twilio::Connection method has been removed, use Twilio.connect(...)
+* LocalPhoneNumber and TollFreeNumber have been removed to reflect API changes
+* New phone numbers are now provisioned via the IncomingPhoneNumber class
+* Several classes improved to avoid adding a stray "?" when no params were set
+* Compatibility with 1.9.2 (and tested on 1.8.7 MRI and REE)
+* Now uses Bundler, Rspec 2, and WebMock
+
+== 2.9
+
+* Compatibility with Twilio's 2010-04-01 API publish
+
+== 2.8
+
+* SMS callback URLs
+* Ability to delete phone numbers
+
+== 2.7
+
+* SMS functionality
+
+For earlier versions, see https://github.com/webficient/twilio/commits/master
View
@@ -1,9 +1,4 @@
source "http://rubygems.org"
# Specify your gem's dependencies in twilio.gemspec
-gemspec
-
-group :test do
- gem 'fakeweb'
- gem 'shoulda'
-end
+gemspec
View
@@ -34,14 +34,26 @@ and you can nest multiple verbs inside a block:
== Installation
- sudo gem install twilio -s http://gemcutter.org
+ gem install twilio
-If you need to tweak the source code, clone this repository and do a rake build and rake install.
+== Contributing
+
+1. Run 'bundle' from the command line to install dependencies
+2. Write test(s) for your patch
+3. Submit a pull request
+
+Note: don't require 'rubygems' in any file (http://www.rubyinside.com/why-using-require-rubygems-is-wrong-1478.html)
== Copyright
-Copyright (c) 2009-2010 Phil Misiowiec, Webficient LLC. See LICENSE for details.
+Copyright (c) 2009-2011 Phil Misiowiec, Webficient LLC. See LICENSE for details.
== Contributors
-Kyle Daigle, Yuri Gadow, Jonathan Rudenberg, Jeff Wigal, Alex K Wolfe
+* Kyle Daigle
+* Yuri Gadow
+* Kyle Humberto
+* Jonathan Rudenberg
+* Mark Turner
+* Jeff Wigal
+* Alex K Wolfe
View
@@ -1,36 +1,9 @@
-require "rubygems"
-begin
-require 'bundler'
+require 'bundler/setup'
Bundler::GemHelper.install_tasks
-rescue LoadError
- puts "bundler not installed"
-end
-require 'rake/rdoctask'
-Rake::RDocTask.new do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'twilio'
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README*')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
+require 'rake'
+require 'rspec/core/rake_task'
-require 'rake/testtask'
-Rake::TestTask.new(:test) do |test|
- test.libs << 'lib' << 'test'
- test.pattern = 'test/**/*_test.rb'
- test.verbose = false
-end
+RSpec::Core::RakeTask.new
-begin
- require 'rcov/rcovtask'
- Rcov::RcovTask.new do |test|
- test.libs << 'test'
- test.pattern = 'test/**/*_test.rb'
- test.verbose = true
- end
-rescue LoadError
- task :rcov do
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
- end
-end
+task :default => :spec
View
@@ -1,5 +0,0 @@
----
-:major: 2
-:build:
-:minor: 9
-:patch: 0
View
@@ -23,17 +23,31 @@
require 'httparty'
require 'builder'
+
require 'twilio/twilio_object'
+
require 'twilio/account'
require 'twilio/available_phone_numbers'
require 'twilio/call'
require 'twilio/conference'
-require 'twilio/connection'
require 'twilio/incoming_phone_number'
-require 'twilio/local_phone_number'
require 'twilio/notification'
require 'twilio/outgoing_caller_id'
require 'twilio/recording'
require 'twilio/sms'
-require 'twilio/toll_free_phone_number'
-require 'twilio/verb'
+require 'twilio/verb'
+
+module Twilio
+ include HTTParty
+ TWILIO_URL = "https://api.twilio.com/2010-04-01/Accounts"
+ SSL_CA_PATH = "/etc/ssl/certs"
+
+ # The connect method caches your Twilio account id and authentication token
+ # Example:
+ # Twilio.connect('AC309475e5fede1b49e100272a8640f438', '3a2630a909aadbf60266234756fb15a0')
+ def self.connect(account_sid, auth_token)
+ self.base_uri "#{TWILIO_URL}/#{account_sid}"
+ self.basic_auth account_sid, auth_token
+ self.default_options[:ssl_ca_path] ||= SSL_CA_PATH unless self.default_options[:ssl_ca_file]
+ end
+end
View
@@ -2,7 +2,7 @@ module Twilio
# The Account resource represents your Twilio Account.
class Account < TwilioObject
def get
- Twilio.get('')
+ Twilio.get('')
end
def update_name(name)
@@ -11,19 +11,21 @@ class AvailablePhoneNumbers < TwilioObject
# numbers.
def search(opts={})
iso_country_code = opts[:iso_country_code] || 'US'
- resource = opts[:resource]
- Twilio.get("/AvailablePhoneNumbers/#{iso_country_code}/#{resource}",
- :query => {
- :AreaCode => opts[:area_code],
- :InPostalCode => opts[:postal_code],
- :InRegion => opts[:in_region],
- :Contains => opts[:contains],
- :NearLatLong => opts[:near_lat_long],
- :NearNumber => opts[:near_number],
- :InLata => opts[:in_lata],
- :InRateCenter => opts[:in_rate_center],
- :Distance => opts[:distance]
- }.reject {|k,v| v == nil})
+ resource = opts.delete(:resource)
+
+ params = {
+ :AreaCode => opts[:area_code],
+ :InPostalCode => opts[:postal_code],
+ :InRegion => opts[:in_region],
+ :Contains => opts[:contains],
+ :NearLatLong => opts[:near_lat_long],
+ :NearNumber => opts[:near_number],
+ :InLata => opts[:in_lata],
+ :InRateCenter => opts[:in_rate_center],
+ :Distance => opts[:distance]
+ }.reject {|k,v| v == nil} unless opts.empty?
+
+ Twilio.get("/AvailablePhoneNumbers/#{iso_country_code}/#{resource}", :query => params)
end
# The search_local method searches for numbers in local areas (i.e. state, zip, etc..)
View
@@ -6,12 +6,12 @@ class Call < TwilioObject
# Example:
# Twilio.connect('my_twilio_sid', 'my_auth_token')
# Twilio::Call.make(CALLER_ID, user_number, 'http://myapp.com/twilio_response_handler')
- def make(from, to, url, optional = {})
- Twilio.post("/Calls", :body => {:From => from, :To => to, :Url => url}.merge(optional))
+ def make(from, to, url, opts = {})
+ Twilio.post("/Calls", :body => {:From => from, :To => to, :Url => url}.merge(opts))
end
- def list(optional = {})
- Twilio.get("/Calls", :query => optional)
+ def list(opts = {})
+ Twilio.get("/Calls", :query => (opts.empty? ? nil : opts))
end
def get(call_sid)
View
@@ -4,20 +4,20 @@ module Twilio
# a Conference Instance Resource is created to represent the conference room
# and a Participant Instance Resource is created to represent the caller who joined.
class Conference < TwilioObject
- def list(optional = {})
- Twilio.get("/Conferences", :query => optional)
+ def list(opts = {})
+ Twilio.get("/Conferences", :query => (opts.empty? ? nil : opts))
end
def get(conference_sid)
- Twilio.get("/Conferences/#{conference_sid}")
+ Twilio.get("/Conferences/#{conference_sid}")
end
- def participants(conference_sid, optional = {})
- Twilio.get("/Conferences/#{conference_sid}/Participants", :query => optional)
+ def participants(conference_sid, opts = {})
+ Twilio.get("/Conferences/#{conference_sid}/Participants", :query => (opts.empty? ? nil : opts))
end
def participant(conference_sid, call_sid)
- Twilio.get("/Conferences/#{conference_sid}/Participants/#{call_sid}")
+ Twilio.get("/Conferences/#{conference_sid}/Participants/#{call_sid}")
end
def mute_participant(conference_sid, call_sid)
View
@@ -1,26 +0,0 @@
-module Twilio
- include HTTParty
- TWILIO_URL = "https://api.twilio.com/2010-04-01/Accounts"
- SSL_CA_PATH = "/etc/ssl/certs"
- # The connect method caches your Twilio account id and authentication token
- # Example:
- # Twilio.connect('AC309475e5fede1b49e100272a8640f438', '3a2630a909aadbf60266234756fb15a0')
- def self.connect(account_sid, auth_token)
- self.base_uri "#{TWILIO_URL}/#{account_sid}"
- self.basic_auth account_sid, auth_token
- self.default_options[:ssl_ca_path] ||= SSL_CA_PATH unless self.default_options[:ssl_ca_file]
- end
-
- # DEPRECATED - use Twilio.connect
- class Connection
- include HTTParty
- TWILIO_URL = "https://api.twilio.com/2008-08-01/Accounts"
-
- def initialize(account_sid, auth_token)
- self.class.base_uri "#{TWILIO_URL}/#{account_sid}"
- self.class.basic_auth account_sid, auth_token
- self.class.default_options[:ssl_ca_path] ||= SSL_CA_PATH unless self.class.default_options[:ssl_ca_file]
- end
- end
-
-end
@@ -5,12 +5,26 @@ module Twilio
# Twilio.connect('my_twilio_sid', 'my_auth_token')
# Twilio::IncomingPhoneNumber.list
class IncomingPhoneNumber < TwilioObject
- def list(optional = {})
- Twilio.get("/IncomingPhoneNumbers", :query => optional)
+ def list(opts = {})
+ Twilio.get("/IncomingPhoneNumbers", :query => (opts.empty? ? nil : opts))
end
def get(incoming_sid)
Twilio.get("/IncomingPhoneNumbers/#{incoming_sid}")
end
+
+ # Creates a phone number in Twilio. You must first find an existing number using
+ # the AvailablePhoneNumber class before creating one here.
+ #
+ # Required: you must either set PhoneNumber or AreaCode as a required option
+ # For additional options, see http://www.twilio.com/docs/api/rest/incoming-phone-numbers
+ def create(opts)
+ raise "You must set either :PhoneNumber or :AreaCode" if !opts.include?(:AreaCode) && !opts.include?(:PhoneNumber)
+ Twilio.post("/IncomingPhoneNumbers", :body => opts)
+ end
+
+ def delete(incoming_sid)
+ Twilio.delete("/IncomingPhoneNumbers/#{incoming_sid}")
+ end
end
end
@@ -1,26 +0,0 @@
-module Twilio
- # This sub-resource represents only Local phone numbers, or in other words, not toll-free numbers.
- # Also allows you to request a new local phone number be added to your account.
- # Example:
- # Twilio.connect('my_twilio_sid', 'my_auth_token')
- # Twilio::LocalPhoneNumber.list
- class LocalPhoneNumber < TwilioObject
- def create(url, area_code = nil, method = 'POST', friendly_name = nil, options = {})
- Twilio.post("/IncomingPhoneNumbers/Local", :body => {
- :VoiceUrl => url,
- :AreaCode => area_code,
- :VoiceMethod => method,
- :FriendlyName => friendly_name
- }.merge(options))
- end
-
- def list
- Twilio.get("/IncomingPhoneNumbers/Local")
- end
-
- def delete(phone_number_sid)
- Twilio.delete("/IncomingPhoneNumbers/#{phone_number_sid}")
- end
-
- end
-end
@@ -5,8 +5,8 @@ module Twilio
# Twilio.connect('my_twilio_sid', 'my_auth_token')
# Twilio::Notification.list
class Notification < TwilioObject
- def list(optional = {})
- Twilio.get('/Notifications', :query => optional)
+ def list(opts = {})
+ Twilio.get('/Notifications', :query => (opts.empty? ? nil : opts))
end
def get(notification_sid)
@@ -5,16 +5,17 @@ module Twilio
# Twilio.connect('my_twilio_sid', 'my_auth_token')
# Twilio::OutgoingCallerId.list
class OutgoingCallerId < TwilioObject
- def create(phone_number, friendly_name = phone_number, call_delay = 0)
+ def create(phone_number, friendly_name = phone_number, call_delay = 0, extension = nil)
Twilio.post("/OutgoingCallerIds", :body => {
:PhoneNumber => phone_number,
:FriendlyName => friendly_name,
- :CallDelay => call_delay
+ :CallDelay => call_delay,
+ :Extension => extension
})
end
- def list(optional = {})
- Twilio.get("/OutgoingCallerIds", :query => optional)
+ def list(opts = {})
+ Twilio.get("/OutgoingCallerIds", :query => (opts.empty? ? nil : opts))
end
def get(callerid_sid)
View
@@ -5,8 +5,8 @@ module Twilio
# Twilio.connect('my_twilio_sid', 'my_auth_token')
# Twilio::Recording.list
class Recording < TwilioObject
- def list(optional = {})
- Twilio.get("/Recordings", :query => optional)
+ def list(opts = {})
+ Twilio.get("/Recordings", :query => (opts.empty? ? nil : opts))
end
def get(recording_sid)
View
@@ -10,8 +10,8 @@ def message(from, to, body, callback_url=nil)
Twilio.post("/SMS/Messages", :body => {:From => from, :To => to, :Body => body}.merge(callback))
end
- def list(optional = {})
- Twilio.get("/SMS/Messages", :query => optional)
+ def list(opts = {})
+ Twilio.get("/SMS/Messages", :query => (opts.empty? ? nil : opts))
end
def get(sms_message_sid)
Oops, something went wrong.

0 comments on commit 564d99a

Please sign in to comment.