twilio 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +24 -0
  3. data/Rakefile +49 -0
  4. data/VERSION.yml +4 -0
  5. data/lib/twilio.rb +42 -0
  6. data/lib/twilio/account.rb +12 -0
  7. data/lib/twilio/call.rb +34 -0
  8. data/lib/twilio/connection.rb +17 -0
  9. data/lib/twilio/incoming_phone_number.rb +13 -0
  10. data/lib/twilio/local_phone_number.rb +18 -0
  11. data/lib/twilio/notification.rb +17 -0
  12. data/lib/twilio/outgoing_caller_id.rb +29 -0
  13. data/lib/twilio/recording.rb +21 -0
  14. data/lib/twilio/toll_free_phone_number.rb +18 -0
  15. data/lib/twilio/twilio_object.rb +11 -0
  16. data/lib/twilio/verb.rb +186 -0
  17. data/test/fixtures/xml/account.xml +11 -0
  18. data/test/fixtures/xml/account_renamed.xml +11 -0
  19. data/test/fixtures/xml/call.xml +18 -0
  20. data/test/fixtures/xml/call_new.xml +14 -0
  21. data/test/fixtures/xml/calls.xml +36 -0
  22. data/test/fixtures/xml/incoming_phone_number.xml +12 -0
  23. data/test/fixtures/xml/incoming_phone_numbers.xml +24 -0
  24. data/test/fixtures/xml/notification.xml +19 -0
  25. data/test/fixtures/xml/notifications.xml +32 -0
  26. data/test/fixtures/xml/outgoing_caller_id.xml +10 -0
  27. data/test/fixtures/xml/outgoing_caller_id_new.xml +7 -0
  28. data/test/fixtures/xml/outgoing_caller_ids.xml +20 -0
  29. data/test/fixtures/xml/recording.xml +10 -0
  30. data/test/fixtures/xml/recordings.xml +20 -0
  31. data/test/fixtures/xml/transcription.xml +13 -0
  32. data/test/fixtures/xml/transcriptions.xml +26 -0
  33. data/test/fixtures/yml/verb_responses.yml +89 -0
  34. data/test/test_helper.rb +29 -0
  35. data/test/twilio/account_test.rb +23 -0
  36. data/test/twilio/call_test.rb +59 -0
  37. data/test/twilio/connection_test.rb +15 -0
  38. data/test/twilio/incoming_phone_number_test.rb +22 -0
  39. data/test/twilio/local_phone_number_test.rb +23 -0
  40. data/test/twilio/notification_test.rb +28 -0
  41. data/test/twilio/outgoing_caller_id_test.rb +42 -0
  42. data/test/twilio/recording_test.rb +42 -0
  43. data/test/twilio/toll_free_phone_number_test.rb +23 -0
  44. data/test/twilio/verb_test.rb +126 -0
  45. metadata +126 -0
@@ -0,0 +1,11 @@
1
+ <TwilioResponse>
2
+ <Account>
3
+ <Sid>mysid</Sid>
4
+ <FriendlyName>My Nice Twilio Account</FriendlyName>
5
+ <Status>2</Status>
6
+ <StatusText>Active</StatusText>
7
+ <DateCreated>Wed, 02 Apr 2008 17:33:38 -0700</DateCreated>
8
+ <DateUpdated>Wed, 02 Apr 2008 17:34:18 -0700</DateUpdated>
9
+ <AuthToken>mytoken</AuthToken>
10
+ </Account>
11
+ </TwilioResponse>
@@ -0,0 +1,11 @@
1
+ <TwilioResponse>
2
+ <Account>
3
+ <Sid>mysid</Sid>
4
+ <FriendlyName>Bubba</FriendlyName>
5
+ <Status>2</Status>
6
+ <StatusText>Active</StatusText>
7
+ <DateCreated>Wed, 02 Apr 2008 17:33:38 -0700</DateCreated>
8
+ <DateUpdated>Wed, 02 Apr 2008 17:34:18 -0700</DateUpdated>
9
+ <AuthToken>mytoken</AuthToken>
10
+ </Account>
11
+ </TwilioResponse>
@@ -0,0 +1,18 @@
1
+ <TwilioResponse>
2
+ <Call>
3
+ <Sid>CA42ed11f93dc08b952027ffbc406d0868</Sid>
4
+ <DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
5
+ <DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
6
+ <CallSegmentSid/>
7
+ <AccountSid>mysid</AccountSid>
8
+ <Called>4159633717</Called>
9
+ <Caller>4156767925</Caller>
10
+ <PhoneNumberSid>PN01234567890123456789012345678900</PhoneNumberSid>
11
+ <Status>2</Status>
12
+ <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
13
+ <EndTime>Thu, 03 Apr 2008 04:36:47 -0400</EndTime>
14
+ <Duration>14</Duration>
15
+ <Price/>
16
+ <Flags>1</Flags>
17
+ </Call>
18
+ </TwilioResponse>
@@ -0,0 +1,14 @@
1
+ <TwilioResponse>
2
+ <Call>
3
+ <Sid>CA42ed11f93dc08b952027ffbc406d0868</Sid>
4
+ <CallSegmentSid/> <AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
5
+ <Called>4155551212</Called>
6
+ <Caller>4158675309</Caller>
7
+ <PhoneNumberSid>PN01234567890123456789012345678900</PhoneNumberSid>
8
+ <Status>0</Status>
9
+ <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
10
+ <EndTime/>
11
+ <Price/>
12
+ <Flags>1</Flags>
13
+ </Call>
14
+ </TwilioResponse>
@@ -0,0 +1,36 @@
1
+ <TwilioResponse>
2
+ <Calls page="0" numpages="1" pagesize="50" total="38" start="0" end="37">
3
+ <Call>
4
+ <Sid>CA42ed11f93dc08b952027ffbc406d0868</Sid>
5
+ <DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
6
+ <DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
7
+ <CallSegmentSid/>
8
+ <AccountSid>mysid</AccountSid>
9
+ <Called>4159633717</Called>
10
+ <Caller>4156767925</Caller>
11
+ <PhoneNumberSid>PN01234567890123456789012345678900</PhoneNumberSid>
12
+ <Status>2</Status>
13
+ <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
14
+ <EndTime>Thu, 03 Apr 2008 04:36:47 -0400</EndTime>
15
+ <Duration>14</Duration>
16
+ <Price/>
17
+ <Flags>1</Flags>
18
+ </Call>
19
+ <Call>
20
+ <Sid>CA751e8fa0a0105cf26a0d7a9775fb4bfb</Sid>
21
+ <DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
22
+ <DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
23
+ <CallSegmentSid/>
24
+ <AccountSid>mysid</AccountSid>
25
+ <Called>2064287985</Called>
26
+ <Caller>4156767925</Caller>
27
+ <PhoneNumberSid>PNd59c2ba27ef48264773edb90476d1674</PhoneNumberSid>
28
+ <Status>2</Status>
29
+ <StartTime>Thu, 03 Apr 2008 01:37:05 -0400</StartTime>
30
+ <EndTime>Thu, 03 Apr 2008 01:37:40 -0400</EndTime>
31
+ <Duration>35</Duration>
32
+ <Price/>
33
+ <Flags>1</Flags>
34
+ </Call>
35
+ </Calls>
36
+ </TwilioResponse>
@@ -0,0 +1,12 @@
1
+ <TwilioResponse>
2
+ <IncomingPhoneNumber>
3
+ <Sid>PNe536dfda7c6184afab78d980cb8cdf43</Sid>
4
+ <AccountSid>mysid</AccountSid>
5
+ <FriendlyName>My Home Phone Number</FriendlyName>
6
+ <PhoneNumber>4158675309</PhoneNumber>
7
+ <Url>http://mycompany.com/handleMainLineCall.asp</Url>
8
+ <Method>GET</Method>
9
+ <DateCreated>Tue, 01 Apr 2008 11:26:32 -0700</DateCreated>
10
+ <DateUpdated>Tue, 01 Apr 2008 11:26:32 -0700</DateUpdated>
11
+ </IncomingPhoneNumber>
12
+ </TwilioResponse>
@@ -0,0 +1,24 @@
1
+ <TwilioResponse>
2
+ <IncomingPhoneNumbers page="0" numpages="1" pagesize="50" total="2" start="0" end="0">
3
+ <IncomingPhoneNumber>
4
+ <Sid>PNe536dfda7c6184afab78d980cb8cdf43</Sid>
5
+ <AccountSid>mysid</AccountSid>
6
+ <FriendlyName>Company Main Line</FriendlyName>
7
+ <PhoneNumber>4158675309</PhoneNumber>
8
+ <Url>http://mycompany.com/handleMainLineCall.asp</Url>
9
+ <Method>GET</Method>
10
+ <DateCreated>Tue, 01 Apr 2008 11:26:32 -0700</DateCreated>
11
+ <DateUpdated>Tue, 01 Apr 2008 11:26:32 -0700</DateUpdated>
12
+ </IncomingPhoneNumber>
13
+ <IncomingPhoneNumber>
14
+ <Sid>PNe536dfda7c6DDd455fed980cb83345FF</Sid>
15
+ <AccountSid>mysid</AccountSid>
16
+ <FriendlyName>Company Support Line</FriendlyName>
17
+ <PhoneNumber>4158675310</PhoneNumber>
18
+ <Url>http://mycompany.com/handleSupportCall.php</Url>
19
+ <Method>POST</Method>
20
+ <DateCreated>Tue, 01 Apr 2008 11:26:32 -0700</DateCreated>
21
+ <DateUpdated>Tue, 01 Apr 2008 11:26:32 -0700</DateUpdated>
22
+ </IncomingPhoneNumber>
23
+ </IncomingPhoneNumbers>
24
+ </TwilioResponse>
@@ -0,0 +1,19 @@
1
+ <TwilioResponse>
2
+ <Notification>
3
+ <Sid>NO1fb7086ceb85caed2265f17d7bf7981c</Sid>
4
+ <DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
5
+ <DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
6
+ <AccountSid>mysid</AccountSid>
7
+ <CallSid>CA42ed11f93dc08b952027ffbc406d0868</CallSid>
8
+ <Log>0</Log>
9
+ <ErrorCode>12345</ErrorCode>
10
+ <MoreInfo>http://www.twilio.com/docs/errors/12345</MoreInfo>
11
+ <MessageText>Unable to parse XML response</MessageText>
12
+ <MessageDate>Thu, 03 Apr 2008 04:36:32 -0400</MessageDate>
13
+ <RequestURL>http://yourserver.com/handleCall.php</RequestURL>
14
+ <RequestMethod>POST</RequestMethod>
15
+ <RequestVariables>Caller=4158675309&Called=4155551212...</RequestVariables>
16
+ <ResponseHeaders>Content-Length: 500</ResponseHeaders>
17
+ <ResponseBody>&lt;h1&gt;Error parsing PHP script&lt;/h1&gt;</ResponseBody>
18
+ </Notification>
19
+ </TwilioResponse>
@@ -0,0 +1,32 @@
1
+ <TwilioResponse>
2
+ <Notifications page="0" numpages="10" pagesize="50" total="498" start="0" end="49">
3
+ <Notification>
4
+ <Sid>NO1fb7086ceb85caed2265f17d7bf7981c</Sid>
5
+ <DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
6
+ <DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
7
+ <AccountSid>mysid</AccountSid>
8
+ <CallSid>CA42ed11f93dc08b952027ffbc406d0868</CallSid>
9
+ <Log>0</Log>
10
+ <ErrorCode>12345</ErrorCode>
11
+ <MoreInfo>http://www.twilio.com/docs/errors/12345</MoreInfo>
12
+ <RequestURL>http://yourserver.com/handleCall.php</RequestURL>
13
+ <RequestMethod>POST</RequestMethod>
14
+ <MessageText>Unable to parse XML response</MessageText>
15
+ <MessageDate>Thu, 03 Apr 2008 04:36:32 -0400</MessageDate>
16
+ </Notification>
17
+ <Notification>
18
+ <Sid>NOe936fdac57d238e56fd346b89820d342</Sid>
19
+ <DateCreated>Sat, 07 Feb 2009 13:15:19 -0800</DateCreated>
20
+ <DateUpdated>Sat, 07 Feb 2009 13:15:19 -0800</DateUpdated>
21
+ <AccountSid>mysid</AccountSid>
22
+ <CallSid></CallSid>
23
+ <Log>1</Log>
24
+ <ErrorCode>67890</ErrorCode>
25
+ <MoreInfo>http://www.twilio.com/docs/errors/67890</MoreInfo>
26
+ <RequestURL>http://api.twilio.com/2008-08-01/Accounts/AC309475e5fede1b49e100272a8640f438/Calls</RequestURL>
27
+ <RequestMethod>POST</RequestMethod>
28
+ <MessageText>Unknown parameter received by the REST API: foo=bar</MessageText>
29
+ <MessageDate>Thu, 03 Apr 2008 04:36:32 -0400</MessageDate>
30
+ </Notification>
31
+ </Notifications>
32
+ </TwilioResponse>
@@ -0,0 +1,10 @@
1
+ <TwilioResponse>
2
+ <OutgoingCallerId>
3
+ <Sid>PNe536dfda7c6184afab78d980cb8cdf43</Sid>
4
+ <AccountSid>mysid</AccountSid>
5
+ <FriendlyName>My Home Phone Number</FriendlyName>
6
+ <PhoneNumber>4158675309</PhoneNumber>
7
+ <DateCreated>Tue, 01 Apr 2008 11:26:32 -0700</DateCreated>
8
+ <DateUpdated>Tue, 01 Apr 2008 11:26:32 -0700</DateUpdated>
9
+ </OutgoingCallerId>
10
+ </TwilioResponse>
@@ -0,0 +1,7 @@
1
+ <TwilioResponse>
2
+ <ValidationRequest>
3
+ <AccountSid>mysid</AccountSid>
4
+ <PhoneNumber>4158675309</PhoneNumber>
5
+ <ValidationCode>123456</ValidationCode>
6
+ </ValidationRequest>
7
+ </TwilioResponse>
@@ -0,0 +1,20 @@
1
+ <TwilioResponse>
2
+ <OutgoingCallerIds page="0" numpages="1" pagesize="50" total="2" start="0" end="0">
3
+ <OutgoingCallerId>
4
+ <Sid>PNe536dfda7c6184afab78d980cb8cdf43</Sid>
5
+ <AccountSid>mysid</AccountSid>
6
+ <FriendlyName>Bob Cell Phone</FriendlyName>
7
+ <PhoneNumber>4158675309</PhoneNumber>
8
+ <DateCreated>Tue, 01 Apr 2008 11:26:32 -0700</DateCreated>
9
+ <DateUpdated>Tue, 01 Apr 2008 11:26:32 -0700</DateUpdated>
10
+ </OutgoingCallerId>
11
+ <OutgoingCallerId>
12
+ <Sid>PNe536dfda7c6DDd455fed980cb83345FF</Sid>
13
+ <AccountSid>mysid</AccountSid>
14
+ <FriendlyName>Company Main Line</FriendlyName>
15
+ <PhoneNumber>4158675310</PhoneNumber>
16
+ <DateCreated>Tue, 01 Apr 2008 11:26:32 -0700</DateCreated>
17
+ <DateUpdated>Tue, 01 Apr 2008 11:26:32 -0700</DateUpdated>
18
+ </OutgoingCallerId>
19
+ </OutgoingCallerIds>
20
+ </TwilioResponse>
@@ -0,0 +1,10 @@
1
+ <TwilioResponse>
2
+ <Recording>
3
+ <Sid>RE41331862605f3d662488fdafda2e175f</Sid>
4
+ <AccountSid>mysid</AccountSid>
5
+ <CallSid>CAcd420fcb3c4b86e360ea0cc27ebc8698</CallSid>
6
+ <Duration>15</Duration>
7
+ <DateCreated>Tue, 01 Apr 2008 01:07:15 -0400</DateCreated>
8
+ <DateUpdated>Tue, 01 Apr 2008 01:07:15 -0400</DateUpdated>
9
+ </Recording>
10
+ </TwilioResponse>
@@ -0,0 +1,20 @@
1
+ <TwilioResponse>
2
+ <Recordings page="0" numpages="1" pagesize="50" total="16" start="0" end="15">
3
+ <Recording>
4
+ <Sid>RE41331862605f3d662488fdafda2e175f</Sid>
5
+ <AccountSid>mysid</AccountSid>
6
+ <CallSid>CAcd420fcb3c4b86e360ea0cc27ebc8698</CallSid>
7
+ <Duration>123</Duration>
8
+ <DateCreated>Tue, 01 Apr 2008 01:07:15 -0400</DateCreated>
9
+ <DateUpdated>Tue, 01 Apr 2008 01:07:15 -0400</DateUpdated>
10
+ </Recording>
11
+ <Recording>
12
+ <Sid>RE50358f2565ad3c542e004161c3aecfd2</Sid>
13
+ <AccountSid>mysid</AccountSid>
14
+ <CallSid>CAcd420fcb3c4b86e360ea0cc27ebc8698</CallSid>
15
+ <Duration>45</Duration>
16
+ <DateCreated>Tue, 01 Apr 2008 01:07:10 -0400</DateCreated>
17
+ <DateUpdated>Tue, 01 Apr 2008 01:07:10 -0400</DateUpdated>
18
+ </Recording>
19
+ </Recordings>
20
+ </TwilioResponse>
@@ -0,0 +1,13 @@
1
+ <TwilioResponse>
2
+ <Transcription>
3
+ <Sid>TRbdece5b75f2cd8f6ef38e0a10f5c4447</Sid>
4
+ <DateCreated>1235986685</DateCreated>
5
+ <DateUpdated>1235957924</DateUpdated>
6
+ <AccountSid>mysid</AccountSid>
7
+ <Status>completed</Status>
8
+ <RecordingSid>RE3870404da563592ef6a72136438a879c</RecordingSid>
9
+ <Duration>9</Duration>
10
+ <TranscriptionText>This is the body a transcribed recording</TranscriptionText>
11
+ <Price>-0.03000</Price>
12
+ </Transcription>
13
+ </TwilioResponse>
@@ -0,0 +1,26 @@
1
+ <TwilioResponse>
2
+ <Transcriptions page="0" numpages="1" pagesize="50" total="2" start="0" end="1">
3
+ <Transcription>
4
+ <Sid>TR685e9a2bdf89b978491b1afada63f078</Sid>
5
+ <DateCreated>1235986685</DateCreated>
6
+ <DateUpdated>1235957975</DateUpdated>
7
+ <AccountSid>mysid</AccountSid>
8
+ <Status>completed</Status>
9
+ <RecordingSid>RE3870404da563592ef6a72136438a879c</RecordingSid>
10
+ <Duration>9</Duration>
11
+ <TranscriptionText>This is the body of one transcribed recording</TranscriptionText>
12
+ <Price>-0.25000</Price>
13
+ </Transcription>
14
+ <Transcription>
15
+ <Sid>TRbdece5b75f2cd8f6ef38e0a10f5c4447</Sid>
16
+ <DateCreated>1235986685</DateCreated>
17
+ <DateUpdated>1235957924</DateUpdated>
18
+ <AccountSid>mysid</AccountSid>
19
+ <Status>completed</Status>
20
+ <RecordingSid>RE3870404da563592ef6a72136438a879c</RecordingSid>
21
+ <Duration>9</Duration>
22
+ <TranscriptionText>This is the body of another transcribed recording</TranscriptionText>
23
+ <Price>-0.03000</Price>
24
+ </Transcription>
25
+ </Transcriptions>
26
+ </TwilioResponse>
@@ -0,0 +1,89 @@
1
+ say_hi:
2
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Say loop="1" language="en" voice="man">hi</Say></Response>
3
+
4
+ say_hi_with_female_voice:
5
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Say loop="1" language="en" voice="woman">hi</Say></Response>
6
+
7
+ say_hi_in_spanish_with_female_voice:
8
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Say loop="1" language="es" voice="woman">hola</Say></Response>
9
+
10
+ say_hi_three_times:
11
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Say loop="3" language="en" voice="man">hi</Say></Response>
12
+
13
+ say_hi_three_times_with_pause:
14
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Say language="en" voice="man">hi</Say><Pause/><Say language="en" voice="man">hi</Say><Pause/><Say language="en" voice="man">hi</Say></Response>
15
+
16
+ play_mp3:
17
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Play loop="1">http://foo.com/cowbell.mp3</Play></Response>
18
+
19
+ play_mp3_two_times:
20
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Play loop="2">http://foo.com/cowbell.mp3</Play></Response>
21
+
22
+ play_mp3_two_times_with_pause:
23
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Play>http://foo.com/cowbell.mp3</Play><Pause/><Play>http://foo.com/cowbell.mp3</Play></Response>
24
+
25
+ gather:
26
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather></Gather></Response>
27
+
28
+ gather_with_action:
29
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather action="http://foobar.com"/></Response>
30
+
31
+ gather_with_get_method:
32
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather method="GET"/></Response>
33
+
34
+ gather_with_timeout:
35
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather timeout="10"/></Response>
36
+
37
+ gather_with_finish_key:
38
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather finishOnKey="*"/></Response>
39
+
40
+ gather_with_num_digits:
41
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather numDigits="5"/></Response>
42
+
43
+ gather_with_all_options_set:
44
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather finishOnKey="*" method="GET" action="http://foobar.com" numDigits="5" timeout="10"/></Response>
45
+
46
+ record:
47
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Record></Record></Response>
48
+
49
+ record_with_action:
50
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Record action="http://foobar.com"/></Response>
51
+
52
+ record_with_get_method:
53
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Record method="GET"/></Response>
54
+
55
+ record_with_timeout:
56
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Record timeout="10"/></Response>
57
+
58
+ record_with_finish_key:
59
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Record finishOnKey="*"/></Response>
60
+
61
+ record_with_max_length:
62
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Record maxLength="1800"/></Response>
63
+
64
+ record_with_transcribe:
65
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Record transcribe="true" transcribeCallback="/handle_transcribe"/></Response>
66
+
67
+ dial:
68
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial>415-123-4567</Dial></Response>
69
+
70
+ dial_with_action:
71
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial action="http://foobar.com">415-123-4567</Dial></Response>
72
+
73
+ dial_with_get_method:
74
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial method="GET">415-123-4567</Dial></Response>
75
+
76
+ dial_with_timeout:
77
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial timeout="10">415-123-4567</Dial></Response>
78
+
79
+ dial_with_hangup_on_star:
80
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial hangupOnStar="true">415-123-4567</Dial></Response>
81
+
82
+ dial_with_time_limit:
83
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial timeLimit="3600">415-123-4567</Dial></Response>
84
+
85
+ dial_with_caller_id:
86
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial callerId="858-987-6543">415-123-4567</Dial></Response>
87
+
88
+ dial_with_timeout_and_caller_id:
89
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial callerId="858-987-6543" timeout="10">415-123-4567</Dial></Response>
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'fakeweb'
4
+ require 'shoulda'
5
+ require 'matchy'
6
+ require 'yaml'
7
+
8
+ FakeWeb.allow_net_connect = false
9
+
10
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
11
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
12
+ require 'twilio'
13
+
14
+ class Test::Unit::TestCase #:nodoc: all
15
+ end
16
+
17
+ def fixture(filename) #:nodoc:
18
+ path = File.join(File.dirname(__FILE__), "fixtures/xml/#{filename}.xml")
19
+ File.read path
20
+ end
21
+
22
+ def twilio_url(url=nil) #:nodoc:
23
+ "https://mysid:mytoken@api.twilio.com:443/2008-08-01/Accounts/mysid#{'/' + url if url}"
24
+ end
25
+
26
+ def verb_response(verb) #:nodoc:
27
+ path = File.join(File.dirname(__FILE__), "fixtures/yml/verb_responses.yml")
28
+ YAML.load_file(path)[verb.to_s]['response']
29
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class AccountTest < Test::Unit::TestCase #:nodoc: all
4
+ context "An account" do
5
+ setup do
6
+ @connection = Twilio::Connection.new('mysid', 'mytoken')
7
+ @account = Twilio::Account.new(@connection)
8
+ end
9
+
10
+ should "be retrievable" do
11
+ fake_response = fixture(:account)
12
+ FakeWeb.register_uri(:get, twilio_url, :string => fake_response)
13
+ assert_equal @account.get, fake_response
14
+ end
15
+
16
+ should "be able to update name" do
17
+ fake_response = fixture(:account_renamed)
18
+ FakeWeb.register_uri(:put, twilio_url, :string => fake_response)
19
+ response = @account.update_name('Bubba')
20
+ assert_equal response, fake_response
21
+ end
22
+ end
23
+ end