Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

support for rails 3.1 via reactive_resource 0.7.0. upgrade to 2010-08…

…-01 twilio api version. add OutgoingCallerId endpoint
  • Loading branch information...
commit 533bbfdeb749b6d386acfe17a1ff4b679aacb547 1 parent 16ca89a
Jeff Ching authored
View
33 Gemfile.lock
@@ -1,25 +1,28 @@
PATH
remote: .
specs:
- twilio_resource (0.1.1)
- reactive_resource (~> 0.5.1)
+ twilio_resource (0.2.0)
+ reactive_resource (~> 0.7.0)
GEM
remote: http://rubygems.org/
specs:
- activemodel (3.0.4)
- activesupport (= 3.0.4)
- builder (~> 2.1.2)
- i18n (~> 0.4)
- activeresource (3.0.4)
- activemodel (= 3.0.4)
- activesupport (= 3.0.4)
- activesupport (3.0.4)
- builder (2.1.2)
- i18n (0.5.0)
- rake (0.8.7)
- reactive_resource (0.5.1)
- activeresource (>= 2.3.10)
+ activemodel (3.1.0)
+ activesupport (= 3.1.0)
+ builder (~> 3.0.0)
+ activeresource (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ activesupport (3.1.0)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ builder (3.0.0)
+ i18n (0.6.0)
+ multi_json (1.1.0)
+ rake (0.9.2.2)
+ reactive_resource (0.7.0)
+ activeresource (>= 3.1)
+ activesupport (>= 3.1)
PLATFORMS
ruby
View
1  lib/twilio_resource.rb
@@ -12,6 +12,7 @@ module TwilioResource
autoload :IncomingPhoneNumber, 'twilio_resource/incoming_phone_number'
autoload :LocalIncomingPhoneNumber, 'twilio_resource/local_incoming_phone_number'
autoload :TollFreeIncomingPhoneNumber, 'twilio_resource/toll_free_incoming_phone_number'
+ autoload :OutgoingCallerId, 'twilio_resource/outgoing_caller_id'
class << self
attr_accessor :logger
View
5 lib/twilio_resource/account.rb
@@ -3,4 +3,9 @@
# can be found at
# http://www.twilio.com/docs/api/2008-08-01/rest/account
class TwilioResource::Account < TwilioResource::Base
+
+ ACTIVE = "active"
+ SUSPENDED = "suspended"
+ CLOSED = "closed"
+
end
View
2  lib/twilio_resource/base.rb
@@ -73,6 +73,6 @@ def save(*params)
self.site = "https://api.twilio.com"
- self.prefix = '/2008-08-01/'
+ self.prefix = '/2010-04-01/'
self.format = :twilio
end
View
31 lib/twilio_resource/call.rb
@@ -5,16 +5,27 @@
class TwilioResource::Call < TwilioResource::Base
belongs_to :account
- NOT_DIALED = 0
- IN_PROGRESS = 1
- COMPLETE = 2
+ NOT_DIALED = "queued"
+ IN_PROGRESS = "in-progress"
+ COMPLETE = "completed"
+ RINGING = "ringing"
+ FAILED = "failed"
+ BUSY = "busy"
+ NO_ANSWER = "no-answer"
- # Returns the status of the call. Can be
- # TwilioResource::Call::NOT_DIALED,
- # TwilioResource::Call::IN_PROGRESS, or
- # TwilioResource::Call::COMPLETE
- def status
- attributes["status"].to_i if attributes["status"]
+ # old end-point
+ def called
+ self.to
end
-
+
+ # old end-point
+ def caller
+ self.from
+ end
+
+ # old end-point
+ def call_segment_sid
+ self.parent_call_sid
+ end
+
end
View
3  lib/twilio_resource/outgoing_caller_id.rb
@@ -0,0 +1,3 @@
+class TwilioResource::OutgoingCallerId < TwilioResource::Base
+ belongs_to :account
+end
View
2  test/account_test.rb
@@ -11,7 +11,7 @@ def setup
def test_find_account
TwilioResource::Base.user = 1
account = TwilioResource::Account.find(1)
- assert_equal "2", account.status
+ assert_equal TwilioResource::Account::ACTIVE, account.status
end
end
View
6 test/call_test.rb
@@ -14,8 +14,10 @@ def test_find_all
# check attributes were assigned correctly
call = calls.first
- assert_equal('4159633717', call.called)
- assert_equal('4156767925', call.caller)
+ assert_equal('+15304551166', call.called)
+ assert_equal('+15304551166', call.to)
+ assert_equal('+15105555555', call.caller)
+ assert_equal('+15105555555', call.from)
assert(call.call_segment_sid.blank?)
end
View
11 test/local_incoming_phone_number_test.rb
@@ -5,8 +5,14 @@ class TwilioResource::LocalIncomingPhoneNumberTest < Test::Unit::TestCase
def setup
super
+ @old_user = TwilioResource::Base.user
TwilioMock.setup_remote_fixtures
end
+
+ def teardown
+ TwilioResource::Base.user = @old_user
+ super
+ end
def test_provision_local_number
phone = TwilioResource::LocalIncomingPhoneNumber.new(:url => "http://example.com/calls",
@@ -14,7 +20,7 @@ def test_provision_local_number
:method => 'POST',
:friendly_name => "My Local Number",
:account_id => 1)
- assert_equal "AreaCode=206&FriendlyName=My+Local+Number&Method=POST&Url=http%3A%2F%2Fexample.com%2Fcalls", phone.encode
+ assert_equal "AccountId=1&AreaCode=206&FriendlyName=My+Local+Number&Method=POST&Url=http%3A%2F%2Fexample.com%2Fcalls", phone.encode
phone.save
assert_equal '2064567890', phone.phone_number
@@ -27,11 +33,10 @@ def test_save_with_unavailable_number_throws_exception
:method => 'POST',
:friendly_name => "My Local Number",
:account_id => TwilioResource::Base.user)
- assert_equal "AreaCode=815&FriendlyName=My+Local+Number&Method=POST&Url=http%3A%2F%2Fexample.com%2Fcalls", phone.encode
+ assert_equal "AccountId=2&AreaCode=815&FriendlyName=My+Local+Number&Method=POST&Url=http%3A%2F%2Fexample.com%2Fcalls", phone.encode
assert_raises TwilioResource::NoPhoneNumbersFoundException do
phone.save
end
-
end
# test find, update
View
29 test/outgoing_caller_id_test.rb
@@ -0,0 +1,29 @@
+require 'test_helper'
+require 'twilio_mock'
+
+class TwilioResource::OutgoingCallerIdTest < Test::Unit::TestCase
+
+ def setup
+ super
+ TwilioMock.setup_remote_fixtures
+ end
+
+ def test_find_all
+ caller_ids = TwilioResource::OutgoingCallerId.find(:all, :params => {:account_id => 1})
+ assert_equal 1, caller_ids.length
+
+ # check attributes were assigned correctly
+ caller_id = caller_ids.first
+ assert_equal('+15105555555', caller_id.phone_number)
+ end
+
+ def test_find_by_phone_number
+ caller_ids = TwilioResource::OutgoingCallerId.find(:all, :params => {:account_id => 1, :friendly_name => "Foo"})
+ assert_equal 1, caller_ids.length
+
+ # check attributes were assigned correctly
+ caller_id = caller_ids.first
+ assert_equal('+15105555555', caller_id.phone_number)
+ end
+
+end
View
2  test/toll_free_incoming_phone_number_test.rb
@@ -14,7 +14,7 @@ def test_provision_toll_free_number
:method => 'POST',
:friendly_name => "My Local Number",
:account_id => TwilioResource::Base.user)
- assert_equal "FriendlyName=My+Local+Number&Method=POST&Url=http%3A%2F%2Fexample.com%2Fcalls", phone.encode
+ assert_equal "AccountId=1&FriendlyName=My+Local+Number&Method=POST&Url=http%3A%2F%2Fexample.com%2Fcalls", phone.encode
phone.save
assert_equal '8774567890', phone.phone_number
View
536 test/twilio_mock.rb
@@ -4,20 +4,22 @@ class TwilioMock
def self.setup_remote_fixtures
ActiveResource::HttpMock.respond_to do |mock|
- mock.get '/2008-08-01/Accounts/1', auth_get(1), main_account
- mock.post '/2008-08-01/Accounts/1/IncomingPhoneNumbers/Local', auth_post(1), local_number_provision_success
- mock.post '/2008-08-01/Accounts/2/IncomingPhoneNumbers/Local', auth_post(2), no_local_number, 400
- mock.post '/2008-08-01/Accounts/1/IncomingPhoneNumbers/TollFree', auth_post(1), toll_free_number_provision_success
+ mock.get '/2010-04-01/Accounts/1', auth_get(1), main_account
+ mock.post '/2010-04-01/Accounts/1/IncomingPhoneNumbers/Local', auth_post(1), local_number_provision_success
+ mock.post '/2010-04-01/Accounts/2/IncomingPhoneNumbers/Local', auth_post(2), no_local_number, 400
+ mock.post '/2010-04-01/Accounts/1/IncomingPhoneNumbers/TollFree', auth_post(1), toll_free_number_provision_success
- mock.get '/2008-08-01/Accounts/1/Calls', auth_get(1), all_calls
- mock.get '/2008-08-01/Accounts/1/Calls?StartTime=2009-09-01', auth_get(1), recent_calls
- mock.get '/2008-08-01/Accounts/1/Calls?Status=2', auth_get(1), succeeded_recent_calls
- mock.get '/2008-08-01/Accounts/1/Calls?StartTime=2009-09-01&Status=2', auth_get(1), no_calls
+ mock.get '/2010-04-01/Accounts/1/Calls', auth_get(1), all_calls
+ mock.get '/2010-04-01/Accounts/1/Calls?StartTime=2009-09-01', auth_get(1), recent_calls
+ mock.get '/2010-04-01/Accounts/1/Calls?Status=completed', auth_get(1), succeeded_recent_calls
+ mock.get '/2010-04-01/Accounts/1/Calls?StartTime=2009-09-01&Status=completed', auth_get(1), no_calls
- mock.get '/2008-08-01/Accounts/1/IncomingPhoneNumbers/1', auth_get(1), phone_number_data
- mock.delete '/2008-08-01/Accounts/1/IncomingPhoneNumbers/1', auth_delete(1), phone_number_delete_success
- mock.delete '/2008-08-01/Accounts/2/IncomingPhoneNumbers/2', auth_delete(2), "", 404
+ mock.get '/2010-04-01/Accounts/1/IncomingPhoneNumbers/1', auth_get(1), phone_number_data
+ mock.delete '/2010-04-01/Accounts/1/IncomingPhoneNumbers/1', auth_delete(1), phone_number_delete_success
+ mock.delete '/2010-04-01/Accounts/2/IncomingPhoneNumbers/2', auth_delete(2), "", 404
+ mock.get '/2010-04-01/Accounts/1/OutgoingCallerIds', auth_get(1), all_caller_ids
+ mock.get '/2010-04-01/Accounts/1/OutgoingCallerIds?FriendlyName=Foo', auth_get(1), friendly_name_caller_ids
end
end
@@ -56,17 +58,34 @@ def self.auth_get(account_id)
def self.phone_number_data
<<END
-<TwilioResponse>
- <IncomingPhoneNumber>
+<TwilioResponse>
+ <IncomingPhoneNumber>
<Sid>PNe536dfda7c6184afab78d980cb8cdf43</Sid>
<AccountSid>AC35542fc30a091bed0c1ed511e1d9935d</AccountSid>
- <FriendlyName>My Home Phone Number</FriendlyName>
- <PhoneNumber>4158675309</PhoneNumber>
- <Url>http://mycompany.com/handleMainLineCall.asp</Url>
- <Method>GET</Method>
- <DateCreated>Tue, 01 Apr 2008 11:26:32 -0700</DateCreated>
- <DateUpdated>Tue, 01 Apr 2008 11:26:32 -0700</DateUpdated>
- </IncomingPhoneNumber>
+ <FriendlyName>My Home Phone Number</FriendlyName>
+ <PhoneNumber>4158675309</PhoneNumber>
+ <VoiceUrl>http://mycompany.com/handleNewCall.php</VoiceUrl>
+ <VoiceMethod>POST</VoiceMethod>
+ <VoiceFallbackUrl/>
+ <VoiceFallbackMethod>POST</VoiceFallbackMethod>
+ <StatusCallback/>
+ <StatusCallbackMethod/>
+ <VoiceCallerIdLookup>false</VoiceCallerIdLookup>
+ <VoiceApplicationSid/>
+ <DateCreated>Mon, 16 Aug 2010 23:00:23 +0000</DateCreated>
+ <DateUpdated>Mon, 16 Aug 2010 23:00:23 +0000</DateUpdated>
+ <SmsUrl/>
+ <SmsMethod>POST</SmsMethod>
+ <SmsFallbackUrl/>
+ <SmsFallbackMethod>GET</SmsFallbackMethod>
+ <SmsApplicationSid>AP9b2e38d8c592488c397fc871a82a74ec</SmsApplicationSid>
+ <Capabilities>
+ <Voice>true</Voice>
+ <SMS>true</SMS>
+ </Capabilities>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <Uri>/2010-04-01/Accounts/ACdc5f1e11047ebd6fe7a55f120be3a900/IncomingPhoneNumbers/PN2a0747eba6abf96b7e3c3ff0b4530f6e</Uri>
+ </IncomingPhoneNumber>
</TwilioResponse>
END
end
@@ -74,16 +93,29 @@ def self.phone_number_data
def self.main_account
<<END
<TwilioResponse>
- <Account>
- <Sid>AC309475e5fede1b49e100272a8640f438</Sid>
- <FriendlyName>My Twilio Account</FriendlyName>
- <Status>2</Status>
- <StatusText>Active</StatusText>
- <DateCreated>Wed, 02 Apr 2008 17:33:38 -0700</DateCreated>
- <DateUpdated>Wed, 02 Apr 2008 17:34:18 -0700</DateUpdated>
- <AuthToken>3a2630a909aadbf60266234756fb15a0</AuthToken>
- </Account>
-</TwilioResponse>
+ <Account>
+ <Sid>AC309475e5fede1b49e100272a8640f438</Sid>
+ <FriendlyName>My Twilio Account</FriendlyName>
+ <Type>Full</Type>
+ <Status>active</Status>
+ <DateCreated>Wed, 04 Aug 2010 21:37:41 +0000</DateCreated>
+ <DateUpdated>Fri, 06 Aug 2010 01:15:02 +0000</DateUpdated>
+ <AuthToken>redacted</AuthToken>
+ <Uri>/2010-04-01/Accounts/ACba8bc05eacf94afdae398e642c9cc32d</Uri>
+ <SubresourceUris>
+ <AvailablePhoneNumbers>/2010-04-01/Accounts/ACba8bc05eacf94afdae398e642c9cc32d/AvailablePhoneNumbers</AvailablePhoneNumbers>
+ <Calls>/2010-04-01/Accounts/ACba8bc05eacf94afdae398e642c9cc32d/Calls</Calls>
+ <Conferences>/2010-04-01/Accounts/ACba8bc05eacf94afdae398e642c9cc32d/Conferences</Conferences>
+ <IncomingPhoneNumbers>/2010-04-01/Accounts/ACba8bc05eacf94afdae398e642c9cc32d/IncomingPhoneNumbers</IncomingPhoneNumbers>
+ <Notifications>/2010-04-01/Accounts/ACba8bc05eacf94afdae398e642c9cc32d/Notifications</Notifications>
+ <OutgoingCallerIds>/2010-04-01/Accounts/ACba8bc05eacf94afdae398e642c9cc32d/OutgoingCallerIds</OutgoingCallerIds>
+ <Recordings>/2010-04-01/Accounts/ACba8bc05eacf94afdae398e642c9cc32d/Recordings</Recordings>
+ <Sandbox>/2010-04-01/Accounts/ACba8bc05eacf94afdae398e642c9cc32d/Sandbox</Sandbox>
+ <SMSMessages>/2010-04-01/Accounts/ACba8bc05eacf94afdae398e642c9cc32d/SMS/Messages</SMSMessages>
+ <Transcriptions>/2010-04-01/Accounts/ACba8bc05eacf94afdae398e642c9cc32d/Transcriptions</Transcriptions>
+ </SubresourceUris>
+ </Account>
+</TwilioResponse>
END
end
@@ -97,38 +129,56 @@ def self.all_calls
<<END
<TwilioResponse>
<Calls page="0" numpages="1" pagesize="50" total="38" start="0" end="37">
- <Call>
+ <Call>
<Sid>CA42ed11f93dc08b952027ffbc406d0868</Sid>
- <DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
- <DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
- <CallSegmentSid/>
- <AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
- <Called>4159633717</Called>
- <Caller>4156767925</Caller>
- <PhoneNumberSid>PN01234567890123456789012345678900</PhoneNumberSid>
- <Status>2</Status>
- <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
- <EndTime>Thu, 03 Apr 2008 04:36:47 -0400</EndTime>
- <Duration>14</Duration>
- <Price/>
- <Flags>1</Flags>
- </Call>
- <Call>
+ <DateCreated>Fri, 13 Aug 2010 01:16:22 +0000</DateCreated>
+ <DateUpdated>Fri, 13 Aug 2010 01:16:22 +0000</DateUpdated>
+ <ParentCallSid/>
+ <AccountSid>AC5ef877a5fe4238be081ea6f3c44186f3</AccountSid>
+ <To>+15304551166</To>
+ <From>+15105555555</From>
+ <PhoneNumberSid>PNe2d8e63b37f46f2adb16f228afdb9058</PhoneNumberSid>
+ <Status>queued</Status>
+ <StartTime>Thu, 12 Aug 2010 01:37:05 +0000</StartTime>
+ <EndTime>Thu, 12 Aug 2010 01:37:40 +0000</EndTime>
+ <Duration/>
+ <Price/>
+ <Direction>outbound-api</Direction>
+ <AnsweredBy/>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <ForwardedFrom/>
+ <CallerName/>
+ <Uri>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c</Uri>
+ <SubresourceUris>
+ <Notifications>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Notifications</Notifications>
+ <Recordings>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Recordings</Recordings>
+ </SubresourceUris>
+ </Call>
+ <Call>
<Sid>CA751e8fa0a0105cf26a0d7a9775fb4bfb</Sid>
- <DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
- <DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
- <CallSegmentSid/>
- <AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
- <Called>2064287985</Called>
- <Caller>4156767925</Caller>
- <PhoneNumberSid>PNd59c2ba27ef48264773edb90476d1674</PhoneNumberSid>
- <Status>2</Status>
- <StartTime>Thu, 03 Apr 2008 01:37:05 -0400</StartTime>
- <EndTime>Thu, 03 Apr 2008 01:37:40 -0400</EndTime>
- <Duration>35</Duration>
- <Price/>
- <Flags>1</Flags>
- </Call>
+ <DateCreated>Fri, 13 Aug 2010 01:16:22 +0000</DateCreated>
+ <DateUpdated>Fri, 13 Aug 2010 01:16:22 +0000</DateUpdated>
+ <ParentCallSid/>
+ <AccountSid>AC5ef877a5fe4238be081ea6f3c44186f3</AccountSid>
+ <To>+15304551166</To>
+ <From>+15105555555</From>
+ <PhoneNumberSid>PNe2d8e63b37f46f2adb16f228afdb9058</PhoneNumberSid>
+ <Status>queued</Status>
+ <StartTime>Thu, 12 Aug 2010 01:37:05 +0000</StartTime>
+ <EndTime>Thu, 12 Aug 2010 01:37:40 +0000</EndTime>
+ <Duration/>
+ <Price/>
+ <Direction>outbound-api</Direction>
+ <AnsweredBy/>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <ForwardedFrom/>
+ <CallerName/>
+ <Uri>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c</Uri>
+ <SubresourceUris>
+ <Notifications>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Notifications</Notifications>
+ <Recordings>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Recordings</Recordings>
+ </SubresourceUris>
+ </Call>
</Calls>
</TwilioResponse>
END
@@ -138,101 +188,155 @@ def self.succeeded_calls
<<END
<TwilioResponse>
<Calls page="0" numpages="1" pagesize="50" total="38" start="0" end="37">
- <Call>
+ <Call>
<Sid>CA42ed11f93dc08b952027ffbc406d0868</Sid>
<DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
<DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
- <CallSegmentSid/>
- <AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
- <Called>4159633717</Called>
- <Caller>4156767925</Caller>
- <PhoneNumberSid>PN01234567890123456789012345678900</PhoneNumberSid>
- <Status>2</Status>
- <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
- <EndTime>Thu, 03 Apr 2008 04:36:47 -0400</EndTime>
- <Duration>14</Duration>
- <Price/>
- <Flags>1</Flags>
- </Call>
- <Call>
+ <ParentCallSid/>
+ <AccountSid>AC5ef877a5fe4238be081ea6f3c44186f3</AccountSid>
+ <To>+15304551166</To>
+ <From>+15105555555</From>
+ <PhoneNumberSid>PNe2d8e63b37f46f2adb16f228afdb9058</PhoneNumberSid>
+ <Status>completed</Status>
+ <StartTime>Thu, 12 Aug 2010 01:37:05 +0000</StartTime>
+ <EndTime>Thu, 12 Aug 2010 01:37:40 +0000</EndTime>
+ <Duration>14</Duration>
+ <Price/>
+ <Direction>outbound-api</Direction>
+ <AnsweredBy/>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <ForwardedFrom/>
+ <CallerName/>
+ <Uri>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c</Uri>
+ <SubresourceUris>
+ <Notifications>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Notifications</Notifications>
+ <Recordings>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Recordings</Recordings>
+ </SubresourceUris>
+ </Call>
+ <Call>
<Sid>1000</Sid>
<DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
<DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
- <CallSegmentSid>10001</CallSegmentSid>
- <AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
- <Called>4159633717</Called>
- <Caller>4156767925</Caller>
- <PhoneNumberSid>ABC123</PhoneNumberSid>
- <Status>2</Status>
- <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
- <EndTime>Thu, 03 Apr 2008 04:36:47 -0400</EndTime>
- <Duration>14</Duration>
- <Price/>
- <Flags>1</Flags>
+ <ParentCallSid/>
+ <AccountSid>AC5ef877a5fe4238be081ea6f3c44186f3</AccountSid>
+ <To>+15304551166</To>
+ <From>+15105555555</From>
+ <PhoneNumberSid>PNe2d8e63b37f46f2adb16f228afdb9058</PhoneNumberSid>
+ <Status>completed</Status>
+ <StartTime>Thu, 12 Aug 2010 01:37:05 +0000</StartTime>
+ <EndTime>Thu, 12 Aug 2010 01:37:40 +0000</EndTime>
+ <Duration>14</Duration>
+ <Price/>
+ <Direction>outbound-api</Direction>
+ <AnsweredBy/>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <ForwardedFrom/>
+ <CallerName/>
+ <Uri>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c</Uri>
+ <SubresourceUris>
+ <Notifications>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Notifications</Notifications>
+ <Recordings>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Recordings</Recordings>
+ </SubresourceUris>
</Call>
- <Call>
+ <Call>
<Sid>1001</Sid>
<DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
<DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
- <CallSegmentSid>10002</CallSegmentSid>
- <AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
- <Called>4159633717</Called>
- <Caller>4156767925</Caller>
- <PhoneNumberSid>ABC123</PhoneNumberSid>
- <Status>2</Status>
- <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
- <EndTime>Thu, 03 Apr 2008 04:36:47 -0400</EndTime>
- <Duration>14</Duration>
- <Price/>
- <Flags>1</Flags>
+ <ParentCallSid/>
+ <AccountSid>AC5ef877a5fe4238be081ea6f3c44186f3</AccountSid>
+ <To>+15304551166</To>
+ <From>+15105555555</From>
+ <PhoneNumberSid>PNe2d8e63b37f46f2adb16f228afdb9058</PhoneNumberSid>
+ <Status>completed</Status>
+ <StartTime>Thu, 12 Aug 2010 01:37:05 +0000</StartTime>
+ <EndTime>Thu, 12 Aug 2010 01:37:40 +0000</EndTime>
+ <Duration>14</Duration>
+ <Price/>
+ <Direction>outbound-api</Direction>
+ <AnsweredBy/>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <ForwardedFrom/>
+ <CallerName/>
+ <Uri>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c</Uri>
+ <SubresourceUris>
+ <Notifications>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Notifications</Notifications>
+ <Recordings>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Recordings</Recordings>
+ </SubresourceUris>
</Call>
- <Call>
+ <Call>
<Sid>1002</Sid>
<DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
<DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
- <CallSegmentSid>10003</CallSegmentSid>
- <AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
- <Called>4159633717</Called>
- <Caller>4156767925</Caller>
- <PhoneNumberSid>ABC123</PhoneNumberSid>
- <Status>2</Status>
- <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
- <EndTime>Thu, 03 Apr 2008 04:36:47 -0400</EndTime>
- <Duration>14</Duration>
- <Price/>
- <Flags>1</Flags>
+ <ParentCallSid/>
+ <AccountSid>AC5ef877a5fe4238be081ea6f3c44186f3</AccountSid>
+ <To>+15304551166</To>
+ <From>+15105555555</From>
+ <PhoneNumberSid>PNe2d8e63b37f46f2adb16f228afdb9058</PhoneNumberSid>
+ <Status>completed</Status>
+ <StartTime>Thu, 12 Aug 2010 01:37:05 +0000</StartTime>
+ <EndTime>Thu, 12 Aug 2010 01:37:40 +0000</EndTime>
+ <Duration>14</Duration>
+ <Price/>
+ <Direction>outbound-api</Direction>
+ <AnsweredBy/>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <ForwardedFrom/>
+ <CallerName/>
+ <Uri>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c</Uri>
+ <SubresourceUris>
+ <Notifications>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Notifications</Notifications>
+ <Recordings>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Recordings</Recordings>
+ </SubresourceUris>
</Call>
- <Call>
+ <Call>
<Sid>1003</Sid>
<DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
<DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
- <CallSegmentSid>10004</CallSegmentSid>
- <AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
- <Called>4159633717</Called>
- <Caller>4156767925</Caller>
- <PhoneNumberSid>UNKNOWN</PhoneNumberSid>
- <Status>2</Status>
- <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
- <EndTime>Thu, 03 Apr 2008 04:36:47 -0400</EndTime>
- <Duration>14</Duration>
- <Price/>
- <Flags>1</Flags>
+ <ParentCallSid/>
+ <AccountSid>AC5ef877a5fe4238be081ea6f3c44186f3</AccountSid>
+ <To>+15304551166</To>
+ <From>+15105555555</From>
+ <PhoneNumberSid>PNe2d8e63b37f46f2adb16f228afdb9058</PhoneNumberSid>
+ <Status>completed</Status>
+ <StartTime>Thu, 12 Aug 2010 01:37:05 +0000</StartTime>
+ <EndTime>Thu, 12 Aug 2010 01:37:40 +0000</EndTime>
+ <Duration>14</Duration>
+ <Price/>
+ <Direction>outbound-api</Direction>
+ <AnsweredBy/>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <ForwardedFrom/>
+ <CallerName/>
+ <Uri>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c</Uri>
+ <SubresourceUris>
+ <Notifications>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Notifications</Notifications>
+ <Recordings>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Recordings</Recordings>
+ </SubresourceUris>
</Call>
- <Call>
+ <Call>
<Sid>AVENDORIDAVENDORIDAVENDORID</Sid>
<DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
<DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
- <CallSegmentSid>10004</CallSegmentSid>
- <AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
- <Called>4159633717</Called>
- <Caller>4156767925</Caller>
- <PhoneNumberSid>ABC123</PhoneNumberSid>
- <Status>2</Status>
- <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
- <EndTime>Thu, 03 Apr 2008 04:36:47 -0400</EndTime>
- <Duration>14</Duration>
- <Price/>
- <Flags>1</Flags>
+ <ParentCallSid/>
+ <AccountSid>AC5ef877a5fe4238be081ea6f3c44186f3</AccountSid>
+ <To>+15304551166</To>
+ <From>+15105555555</From>
+ <PhoneNumberSid>PNe2d8e63b37f46f2adb16f228afdb9058</PhoneNumberSid>
+ <Status>completed</Status>
+ <StartTime>Thu, 12 Aug 2010 01:37:05 +0000</StartTime>
+ <EndTime>Thu, 12 Aug 2010 01:37:40 +0000</EndTime>
+ <Duration>14</Duration>
+ <Price/>
+ <Direction>outbound-api</Direction>
+ <AnsweredBy/>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <ForwardedFrom/>
+ <CallerName/>
+ <Uri>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c</Uri>
+ <SubresourceUris>
+ <Notifications>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Notifications</Notifications>
+ <Recordings>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Recordings</Recordings>
+ </SubresourceUris>
</Call>
</Calls>
</TwilioResponse>
@@ -243,21 +347,30 @@ def self.recent_calls
<<END
<TwilioResponse>
<Calls page="0" numpages="1" pagesize="50" total="38" start="0" end="37">
- <Call>
+ <Call>
<Sid>CA42ed11f93dc08b952027ffbc406d0868</Sid>
<DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
<DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
- <CallSegmentSid/>
- <AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
- <Called>4159633717</Called>
- <Caller>4156767925</Caller>
- <PhoneNumberSid>PN01234567890123456789012345678900</PhoneNumberSid>
- <Status>1</Status>
- <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
- <EndTime>Thu, 03 Apr 2008 04:36:47 -0400</EndTime>
- <Duration>14</Duration>
- <Price/>
- <Flags>1</Flags>
+ <ParentCallSid/>
+ <AccountSid>AC5ef877a5fe4238be081ea6f3c44186f3</AccountSid>
+ <To>+15304551166</To>
+ <From>+15105555555</From>
+ <PhoneNumberSid>PNe2d8e63b37f46f2adb16f228afdb9058</PhoneNumberSid>
+ <Status>completed</Status>
+ <StartTime>Thu, 12 Aug 2010 01:37:05 +0000</StartTime>
+ <EndTime>Thu, 12 Aug 2010 01:37:40 +0000</EndTime>
+ <Duration>14</Duration>
+ <Price/>
+ <Direction>outbound-api</Direction>
+ <AnsweredBy/>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <ForwardedFrom/>
+ <CallerName/>
+ <Uri>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c</Uri>
+ <SubresourceUris>
+ <Notifications>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Notifications</Notifications>
+ <Recordings>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Recordings</Recordings>
+ </SubresourceUris>
</Call>
</Calls>
</TwilioResponse>
@@ -269,21 +382,30 @@ def self.succeeded_recent_calls
<<END
<TwilioResponse>
<Calls page="0" numpages="1" pagesize="50" total="38" start="0" end="37">
- <Call>
+ <Call>
<Sid>CA42ed11f93dc08b952027ffbc406d0868</Sid>
<DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
<DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
- <CallSegmentSid>8142ed11f93dc08b952027ffbc406d0868</CallSegmentSid>
- <AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
- <Called>4159633717</Called>
- <Caller>4156767925</Caller>
- <PhoneNumberSid>PN01234567890123456789012345678900</PhoneNumberSid>
- <Status>2</Status>
- <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
- <EndTime>Thu, 03 Apr 2008 04:36:47 -0400</EndTime>
- <Duration>14</Duration>
- <Price/>
- <Flags>1</Flags>
+ <ParentCallSid/>
+ <AccountSid>AC5ef877a5fe4238be081ea6f3c44186f3</AccountSid>
+ <To>+15304551166</To>
+ <From>+15105555555</From>
+ <PhoneNumberSid>PNe2d8e63b37f46f2adb16f228afdb9058</PhoneNumberSid>
+ <Status>completed</Status>
+ <StartTime>Thu, 12 Aug 2010 01:37:05 +0000</StartTime>
+ <EndTime>Thu, 12 Aug 2010 01:37:40 +0000</EndTime>
+ <Duration>14</Duration>
+ <Price/>
+ <Direction>outbound-api</Direction>
+ <AnsweredBy/>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <ForwardedFrom/>
+ <CallerName/>
+ <Uri>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c</Uri>
+ <SubresourceUris>
+ <Notifications>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Notifications</Notifications>
+ <Recordings>/2010-04-01/Accounts/AC5ef877a5fe4238be081ea6f3c44186f3/Calls/CA92d4405c9237c4ea04b56cbda88e128c/Recordings</Recordings>
+ </SubresourceUris>
</Call>
</Calls>
</TwilioResponse>
@@ -301,34 +423,68 @@ def self.no_calls
def self.local_number_provision_success
<<END
-<TwilioResponse>
- <IncomingPhoneNumber>
+<TwilioResponse>
+ <IncomingPhoneNumber>
<Sid>PNe536dfda7c6184afab78d980cb8cdf43</Sid>
- <AccountSid>AC35542fc30a091bed0c1ed511e1d9935d</AccountSid>
+ <AccountSid>AC755325d45d80675a4727a7a54e1b4ce4</AccountSid>
<FriendlyName>My Local Number</FriendlyName>
<PhoneNumber>2064567890</PhoneNumber>
- <Url>http://example.com/calls</Url>
- <Method>GET</Method>
- <DateCreated>Tue, 01 Apr 2008 11:26:32 -0700</DateCreated>
- <DateUpdated>Tue, 01 Apr 2008 11:26:32 -0700</DateUpdated>
- </IncomingPhoneNumber>
-</TwilioResponse>
+ <VoiceUrl>http://myapp.com/awesome</VoiceUrl>
+ <VoiceMethod>POST</VoiceMethod>
+ <VoiceFallbackUrl/>
+ <VoiceFallbackMethod>POST</VoiceFallbackMethod>
+ <VoiceCallerIdLookup>false</VoiceCallerIdLookup>
+ <VoiceApplicationSid/>
+ <DateCreated>Mon, 16 Aug 2010 23:00:23 +0000</DateCreated>
+ <DateUpdated>Mon, 16 Aug 2010 23:00:23 +0000</DateUpdated>
+ <SmsUrl>http://myapp.com/awesome</SmsUrl>
+ <SmsMethod>POST</SmsMethod>
+ <SmsFallbackUrl/>
+ <SmsFallbackMethod>GET</SmsFallbackMethod>
+ <SmsApplicationSid/>
+ <Capabilities>
+ <Voice>true</Voice>
+ <SMS>true</SMS>
+ </Capabilities>
+ <StatusCallback/>
+ <StatusCallbackMethod/>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <Uri>/2010-04-01/Accounts/AC755325d45d80675a4727a7a54e1b4ce4/IncomingPhoneNumbers/PN2a0747eba6abf96b7e3c3ff0b4530f6e</Uri>
+ </IncomingPhoneNumber>
+</TwilioResponse>
END
end
def self.toll_free_number_provision_success
<<END
<TwilioResponse>
- <IncomingPhoneNumber>
+ <IncomingPhoneNumber>
<Sid>PNe536dfda7c6184afab78d980cb8cdf43</Sid>
<AccountSid>AC35542fc30a091bed0c1ed511e1d9935d</AccountSid>
<FriendlyName>My Toll Free Number</FriendlyName>
<PhoneNumber>8774567890</PhoneNumber>
- <Url>http://example.com/calls</Url>
- <Method>GET</Method>
- <DateCreated>Tue, 01 Apr 2008 11:26:32 -0700</DateCreated>
- <DateUpdated>Tue, 01 Apr 2008 11:26:32 -0700</DateUpdated>
- </IncomingPhoneNumber>
+ <VoiceUrl>http://myapp.com/awesome</VoiceUrl>
+ <VoiceMethod>POST</VoiceMethod>
+ <VoiceFallbackUrl/>
+ <VoiceFallbackMethod>POST</VoiceFallbackMethod>
+ <VoiceCallerIdLookup>false</VoiceCallerIdLookup>
+ <VoiceApplicationSid/>
+ <DateCreated>Mon, 16 Aug 2010 23:00:23 +0000</DateCreated>
+ <DateUpdated>Mon, 16 Aug 2010 23:00:23 +0000</DateUpdated>
+ <SmsUrl>http://myapp.com/awesome</SmsUrl>
+ <SmsMethod>POST</SmsMethod>
+ <SmsFallbackUrl/>
+ <SmsFallbackMethod>GET</SmsFallbackMethod>
+ <SmsApplicationSid/>
+ <Capabilities>
+ <Voice>true</Voice>
+ <SMS>true</SMS>
+ </Capabilities>
+ <StatusCallback/>
+ <StatusCallbackMethod/>
+ <ApiVersion>2010-04-01</ApiVersion>
+ <Uri>/2010-04-01/Accounts/AC755325d45d80675a4727a7a54e1b4ce4/IncomingPhoneNumbers/PN2a0747eba6abf96b7e3c3ff0b4530f6e</Uri>
+ </IncomingPhoneNumber>
</TwilioResponse>
END
end
@@ -339,4 +495,40 @@ def self.no_local_number
END
end
+ def self.all_caller_ids
+<<END
+<TwilioResponse>
+ <OutgoingCallerIds page="0" numpages="1" pagesize="50" total="1" start="0" end="0" uri="/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/OutgoingCallerIds" firstpageuri="/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/OutgoingCallerIds?Page=0&amp;PageSize=50" previouspageuri="" nextpageuri="" lastpageuri="/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/OutgoingCallerIds?Page=0&amp;PageSize=50">
+ <OutgoingCallerId>
+ <Sid>PNe905d7e6b410746a0fb08c57e5a186f3</Sid>
+ <AccountSid>AC228ba7a5fe4238be081ea6f3c44186f3</AccountSid>
+ <FriendlyName>Foo</FriendlyName>
+ <PhoneNumber>+15105555555</PhoneNumber>
+ <DateCreated>Tue, 27 Jul 2010 20:21:11 +0000</DateCreated>
+ <DateUpdated>Tue, 27 Jul 2010 20:21:11 +0000</DateUpdated>
+ <Uri>/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/OutgoingCallerIds/PNe905d7e6b410746a0fb08c57e5a186f3</Uri>
+ </OutgoingCallerId>
+ </OutgoingCallerIds>
+</TwilioResponse>
+END
+ end
+
+ def self.friendly_name_caller_ids
+<<END
+<TwilioResponse>
+ <OutgoingCallerIds page="0" numpages="1" pagesize="50" total="1" start="0" end="0" uri="/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/OutgoingCallerIds" firstpageuri="/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/OutgoingCallerIds?Page=0&amp;PageSize=50" previouspageuri="" nextpageuri="" lastpageuri="/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/OutgoingCallerIds?Page=0&amp;PageSize=50">
+ <OutgoingCallerId>
+ <Sid>PNe905d7e6b410746a0fb08c57e5a186f3</Sid>
+ <AccountSid>AC228ba7a5fe4238be081ea6f3c44186f3</AccountSid>
+ <FriendlyName>Foo</FriendlyName>
+ <PhoneNumber>+15105555555</PhoneNumber>
+ <DateCreated>Tue, 27 Jul 2010 20:21:11 +0000</DateCreated>
+ <DateUpdated>Tue, 27 Jul 2010 20:21:11 +0000</DateUpdated>
+ <Uri>/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/OutgoingCallerIds/PNe905d7e6b410746a0fb08c57e5a186f3</Uri>
+ </OutgoingCallerId>
+ </OutgoingCallerIds>
+</TwilioResponse>
+END
+ end
+
end
View
2  twilio_resource.gemspec
@@ -2,7 +2,7 @@ spec = Gem::Specification.new do |s|
s.name = 'twilio_resource'
s.version = '0.2.0'
s.summary = 'An ActiveResource API wrapper for Twilio'
- s.add_dependency "reactive_resource", '~> 0.5.1'
+ s.add_dependency "reactive_resource", '~> 0.7.0'
s.author = "Justin Weiss"
s.email = "justin@uberweiss.org"
s.homepage = "http://github.com/justinweiss/twilio_resource"
Please sign in to comment.
Something went wrong with that request. Please try again.