twilio 2.9.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -1
- data/CHANGELOG.rdoc +27 -0
- data/Gemfile +4 -0
- data/README.rdoc +16 -6
- data/Rakefile +6 -46
- data/lib/twilio.rb +21 -6
- data/lib/twilio/account.rb +1 -1
- data/lib/twilio/available_phone_numbers.rb +56 -0
- data/lib/twilio/call.rb +4 -4
- data/lib/twilio/conference.rb +6 -6
- data/lib/twilio/incoming_phone_number.rb +16 -2
- data/lib/twilio/notification.rb +2 -2
- data/lib/twilio/outgoing_caller_id.rb +5 -4
- data/lib/twilio/recording.rb +2 -2
- data/lib/twilio/sms.rb +2 -2
- data/lib/twilio/twilio_object.rb +8 -5
- data/lib/twilio/version.rb +3 -0
- data/spec/fixtures/xml/account.xml +23 -0
- data/{test → spec}/fixtures/xml/account_renamed.xml +0 -0
- data/spec/fixtures/xml/available_phone_numbers_local.xml +26 -0
- data/spec/fixtures/xml/available_phone_numbers_local_search.xml +15 -0
- data/spec/fixtures/xml/available_phone_numbers_toll_free.xml +14 -0
- data/spec/fixtures/xml/available_phone_numbers_toll_free_search.xml +10 -0
- data/{test → spec}/fixtures/xml/call.xml +0 -0
- data/{test → spec}/fixtures/xml/call_new.xml +0 -0
- data/{test → spec}/fixtures/xml/call_redirected.xml +0 -0
- data/{test → spec}/fixtures/xml/calls.xml +0 -0
- data/{test → spec}/fixtures/xml/conference.xml +1 -1
- data/{test → spec}/fixtures/xml/conference_participant.xml +0 -0
- data/{test → spec}/fixtures/xml/conference_participant_muted.xml +0 -0
- data/{test → spec}/fixtures/xml/conference_participants.xml +0 -0
- data/{test → spec}/fixtures/xml/conferences.xml +0 -0
- data/{test → spec}/fixtures/xml/incoming_phone_number.xml +0 -0
- data/{test → spec}/fixtures/xml/incoming_phone_numbers.xml +0 -0
- data/{test → spec}/fixtures/xml/notification.xml +0 -0
- data/{test → spec}/fixtures/xml/notifications.xml +0 -0
- data/{test → spec}/fixtures/xml/outgoing_caller_id.xml +0 -0
- data/{test → spec}/fixtures/xml/outgoing_caller_id_new.xml +0 -0
- data/{test → spec}/fixtures/xml/outgoing_caller_ids.xml +0 -0
- data/{test → spec}/fixtures/xml/recording.xml +0 -0
- data/{test → spec}/fixtures/xml/recordings.xml +0 -0
- data/{test → spec}/fixtures/xml/sms.xml +0 -0
- data/{test → spec}/fixtures/xml/sms_messages.xml +0 -0
- data/{test → spec}/fixtures/xml/sms_new.xml +0 -0
- data/{test → spec}/fixtures/xml/sms_new_with_callback.xml +0 -0
- data/{test → spec}/fixtures/xml/transcription.xml +0 -0
- data/{test → spec}/fixtures/xml/transcriptions.xml +0 -0
- data/{test → spec}/fixtures/yml/verb_responses.yml +0 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/twilio_helpers.rb +52 -0
- data/spec/twilio/account_spec.rb +21 -0
- data/spec/twilio/available_phone_numbers_spec.rb +53 -0
- data/spec/twilio/call_spec.rb +64 -0
- data/spec/twilio/conference_spec.rb +58 -0
- data/spec/twilio/incoming_phone_number_spec.rb +42 -0
- data/spec/twilio/live_connection_spec.rb +21 -0
- data/spec/twilio/notification_spec.rb +29 -0
- data/spec/twilio/outgoing_caller_id_spec.rb +43 -0
- data/spec/twilio/recording_spec.rb +44 -0
- data/spec/twilio/sms_spec.rb +36 -0
- data/spec/twilio/verb_spec.rb +235 -0
- data/twilio.gemspec +23 -111
- metadata +164 -82
- data/VERSION.yml +0 -5
- data/lib/twilio/connection.rb +0 -24
- data/lib/twilio/local_phone_number.rb +0 -26
- data/lib/twilio/toll_free_phone_number.rb +0 -26
- data/test/fixtures/xml/account.xml +0 -11
- data/test/test_helper.rb +0 -33
- data/test/twilio/account_test.rb +0 -28
- data/test/twilio/call_test.rb +0 -66
- data/test/twilio/conference_test.rb +0 -46
- data/test/twilio/connection_test.rb +0 -25
- data/test/twilio/incoming_phone_number_test.rb +0 -31
- data/test/twilio/local_phone_number_test.rb +0 -37
- data/test/twilio/notification_test.rb +0 -35
- data/test/twilio/outgoing_caller_id_test.rb +0 -45
- data/test/twilio/recording_test.rb +0 -47
- data/test/twilio/sms_test.rb +0 -27
- data/test/twilio/toll_free_phone_number_test.rb +0 -38
- data/test/twilio/verb_test.rb +0 -244
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twilio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 7
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
-
|
7
|
+
- 3
|
8
|
+
- 0
|
9
9
|
- 0
|
10
|
-
version:
|
10
|
+
version: 3.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Phil Misiowiec
|
@@ -20,7 +20,7 @@ autorequire:
|
|
20
20
|
bindir: bin
|
21
21
|
cert_chain: []
|
22
22
|
|
23
|
-
date:
|
23
|
+
date: 2011-03-26 00:00:00 -07:00
|
24
24
|
default_executable:
|
25
25
|
dependencies:
|
26
26
|
- !ruby/object:Gem::Dependency
|
@@ -29,14 +29,13 @@ dependencies:
|
|
29
29
|
requirement: &id001 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
hash:
|
34
|
+
hash: 7
|
35
35
|
segments:
|
36
|
-
-
|
37
|
-
-
|
38
|
-
|
39
|
-
version: 2.1.2
|
36
|
+
- 3
|
37
|
+
- 0
|
38
|
+
version: "3.0"
|
40
39
|
type: :runtime
|
41
40
|
version_requirements: *id001
|
42
41
|
- !ruby/object:Gem::Dependency
|
@@ -45,93 +44,145 @@ dependencies:
|
|
45
44
|
requirement: &id002 !ruby/object:Gem::Requirement
|
46
45
|
none: false
|
47
46
|
requirements:
|
48
|
-
- -
|
47
|
+
- - ~>
|
49
48
|
- !ruby/object:Gem::Version
|
50
|
-
hash:
|
49
|
+
hash: 11
|
51
50
|
segments:
|
52
51
|
- 0
|
52
|
+
- 7
|
53
53
|
- 4
|
54
|
-
|
55
|
-
version: 0.4.3
|
54
|
+
version: 0.7.4
|
56
55
|
type: :runtime
|
57
56
|
version_requirements: *id002
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rake
|
59
|
+
prerelease: false
|
60
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 49
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
- 8
|
69
|
+
- 7
|
70
|
+
version: 0.8.7
|
71
|
+
type: :development
|
72
|
+
version_requirements: *id003
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: rspec
|
75
|
+
prerelease: false
|
76
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 27
|
82
|
+
segments:
|
83
|
+
- 2
|
84
|
+
- 5
|
85
|
+
- 0
|
86
|
+
version: 2.5.0
|
87
|
+
type: :development
|
88
|
+
version_requirements: *id004
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: webmock
|
91
|
+
prerelease: false
|
92
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ~>
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
hash: 11
|
98
|
+
segments:
|
99
|
+
- 1
|
100
|
+
- 6
|
101
|
+
- 2
|
102
|
+
version: 1.6.2
|
103
|
+
type: :development
|
104
|
+
version_requirements: *id005
|
58
105
|
description: Twilio API wrapper
|
59
|
-
email:
|
106
|
+
email:
|
107
|
+
- github@webficient.com
|
60
108
|
executables: []
|
61
109
|
|
62
110
|
extensions: []
|
63
111
|
|
64
|
-
extra_rdoc_files:
|
65
|
-
|
66
|
-
- README.rdoc
|
112
|
+
extra_rdoc_files: []
|
113
|
+
|
67
114
|
files:
|
68
115
|
- .gitignore
|
116
|
+
- CHANGELOG.rdoc
|
117
|
+
- Gemfile
|
69
118
|
- LICENSE
|
70
119
|
- README.rdoc
|
71
120
|
- Rakefile
|
72
|
-
- VERSION.yml
|
73
121
|
- lib/twilio.rb
|
74
122
|
- lib/twilio/account.rb
|
123
|
+
- lib/twilio/available_phone_numbers.rb
|
75
124
|
- lib/twilio/call.rb
|
76
125
|
- lib/twilio/conference.rb
|
77
|
-
- lib/twilio/connection.rb
|
78
126
|
- lib/twilio/incoming_phone_number.rb
|
79
|
-
- lib/twilio/local_phone_number.rb
|
80
127
|
- lib/twilio/notification.rb
|
81
128
|
- lib/twilio/outgoing_caller_id.rb
|
82
129
|
- lib/twilio/recording.rb
|
83
130
|
- lib/twilio/sms.rb
|
84
|
-
- lib/twilio/toll_free_phone_number.rb
|
85
131
|
- lib/twilio/twilio_object.rb
|
86
132
|
- lib/twilio/verb.rb
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
95
|
-
-
|
96
|
-
-
|
97
|
-
-
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
-
|
102
|
-
-
|
103
|
-
-
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
108
|
-
-
|
109
|
-
-
|
110
|
-
-
|
111
|
-
-
|
112
|
-
-
|
113
|
-
-
|
114
|
-
-
|
115
|
-
-
|
116
|
-
-
|
117
|
-
-
|
118
|
-
-
|
119
|
-
-
|
120
|
-
-
|
121
|
-
-
|
122
|
-
-
|
123
|
-
-
|
124
|
-
-
|
125
|
-
-
|
126
|
-
-
|
133
|
+
- lib/twilio/version.rb
|
134
|
+
- spec/fixtures/xml/account.xml
|
135
|
+
- spec/fixtures/xml/account_renamed.xml
|
136
|
+
- spec/fixtures/xml/available_phone_numbers_local.xml
|
137
|
+
- spec/fixtures/xml/available_phone_numbers_local_search.xml
|
138
|
+
- spec/fixtures/xml/available_phone_numbers_toll_free.xml
|
139
|
+
- spec/fixtures/xml/available_phone_numbers_toll_free_search.xml
|
140
|
+
- spec/fixtures/xml/call.xml
|
141
|
+
- spec/fixtures/xml/call_new.xml
|
142
|
+
- spec/fixtures/xml/call_redirected.xml
|
143
|
+
- spec/fixtures/xml/calls.xml
|
144
|
+
- spec/fixtures/xml/conference.xml
|
145
|
+
- spec/fixtures/xml/conference_participant.xml
|
146
|
+
- spec/fixtures/xml/conference_participant_muted.xml
|
147
|
+
- spec/fixtures/xml/conference_participants.xml
|
148
|
+
- spec/fixtures/xml/conferences.xml
|
149
|
+
- spec/fixtures/xml/incoming_phone_number.xml
|
150
|
+
- spec/fixtures/xml/incoming_phone_numbers.xml
|
151
|
+
- spec/fixtures/xml/notification.xml
|
152
|
+
- spec/fixtures/xml/notifications.xml
|
153
|
+
- spec/fixtures/xml/outgoing_caller_id.xml
|
154
|
+
- spec/fixtures/xml/outgoing_caller_id_new.xml
|
155
|
+
- spec/fixtures/xml/outgoing_caller_ids.xml
|
156
|
+
- spec/fixtures/xml/recording.xml
|
157
|
+
- spec/fixtures/xml/recordings.xml
|
158
|
+
- spec/fixtures/xml/sms.xml
|
159
|
+
- spec/fixtures/xml/sms_messages.xml
|
160
|
+
- spec/fixtures/xml/sms_new.xml
|
161
|
+
- spec/fixtures/xml/sms_new_with_callback.xml
|
162
|
+
- spec/fixtures/xml/transcription.xml
|
163
|
+
- spec/fixtures/xml/transcriptions.xml
|
164
|
+
- spec/fixtures/yml/verb_responses.yml
|
165
|
+
- spec/spec_helper.rb
|
166
|
+
- spec/support/twilio_helpers.rb
|
167
|
+
- spec/twilio/account_spec.rb
|
168
|
+
- spec/twilio/available_phone_numbers_spec.rb
|
169
|
+
- spec/twilio/call_spec.rb
|
170
|
+
- spec/twilio/conference_spec.rb
|
171
|
+
- spec/twilio/incoming_phone_number_spec.rb
|
172
|
+
- spec/twilio/live_connection_spec.rb
|
173
|
+
- spec/twilio/notification_spec.rb
|
174
|
+
- spec/twilio/outgoing_caller_id_spec.rb
|
175
|
+
- spec/twilio/recording_spec.rb
|
176
|
+
- spec/twilio/sms_spec.rb
|
177
|
+
- spec/twilio/verb_spec.rb
|
127
178
|
- twilio.gemspec
|
128
179
|
has_rdoc: true
|
129
|
-
homepage:
|
180
|
+
homepage: ""
|
130
181
|
licenses: []
|
131
182
|
|
132
183
|
post_install_message:
|
133
|
-
rdoc_options:
|
134
|
-
|
184
|
+
rdoc_options: []
|
185
|
+
|
135
186
|
require_paths:
|
136
187
|
- lib
|
137
188
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -154,22 +205,53 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
205
|
version: "0"
|
155
206
|
requirements: []
|
156
207
|
|
157
|
-
rubyforge_project:
|
158
|
-
rubygems_version: 1.
|
208
|
+
rubyforge_project: twilio
|
209
|
+
rubygems_version: 1.6.2
|
159
210
|
signing_key:
|
160
211
|
specification_version: 3
|
161
212
|
summary: Twilio API Client
|
162
213
|
test_files:
|
163
|
-
-
|
164
|
-
-
|
165
|
-
-
|
166
|
-
-
|
167
|
-
-
|
168
|
-
-
|
169
|
-
-
|
170
|
-
-
|
171
|
-
-
|
172
|
-
-
|
173
|
-
-
|
174
|
-
-
|
175
|
-
-
|
214
|
+
- spec/fixtures/xml/account.xml
|
215
|
+
- spec/fixtures/xml/account_renamed.xml
|
216
|
+
- spec/fixtures/xml/available_phone_numbers_local.xml
|
217
|
+
- spec/fixtures/xml/available_phone_numbers_local_search.xml
|
218
|
+
- spec/fixtures/xml/available_phone_numbers_toll_free.xml
|
219
|
+
- spec/fixtures/xml/available_phone_numbers_toll_free_search.xml
|
220
|
+
- spec/fixtures/xml/call.xml
|
221
|
+
- spec/fixtures/xml/call_new.xml
|
222
|
+
- spec/fixtures/xml/call_redirected.xml
|
223
|
+
- spec/fixtures/xml/calls.xml
|
224
|
+
- spec/fixtures/xml/conference.xml
|
225
|
+
- spec/fixtures/xml/conference_participant.xml
|
226
|
+
- spec/fixtures/xml/conference_participant_muted.xml
|
227
|
+
- spec/fixtures/xml/conference_participants.xml
|
228
|
+
- spec/fixtures/xml/conferences.xml
|
229
|
+
- spec/fixtures/xml/incoming_phone_number.xml
|
230
|
+
- spec/fixtures/xml/incoming_phone_numbers.xml
|
231
|
+
- spec/fixtures/xml/notification.xml
|
232
|
+
- spec/fixtures/xml/notifications.xml
|
233
|
+
- spec/fixtures/xml/outgoing_caller_id.xml
|
234
|
+
- spec/fixtures/xml/outgoing_caller_id_new.xml
|
235
|
+
- spec/fixtures/xml/outgoing_caller_ids.xml
|
236
|
+
- spec/fixtures/xml/recording.xml
|
237
|
+
- spec/fixtures/xml/recordings.xml
|
238
|
+
- spec/fixtures/xml/sms.xml
|
239
|
+
- spec/fixtures/xml/sms_messages.xml
|
240
|
+
- spec/fixtures/xml/sms_new.xml
|
241
|
+
- spec/fixtures/xml/sms_new_with_callback.xml
|
242
|
+
- spec/fixtures/xml/transcription.xml
|
243
|
+
- spec/fixtures/xml/transcriptions.xml
|
244
|
+
- spec/fixtures/yml/verb_responses.yml
|
245
|
+
- spec/spec_helper.rb
|
246
|
+
- spec/support/twilio_helpers.rb
|
247
|
+
- spec/twilio/account_spec.rb
|
248
|
+
- spec/twilio/available_phone_numbers_spec.rb
|
249
|
+
- spec/twilio/call_spec.rb
|
250
|
+
- spec/twilio/conference_spec.rb
|
251
|
+
- spec/twilio/incoming_phone_number_spec.rb
|
252
|
+
- spec/twilio/live_connection_spec.rb
|
253
|
+
- spec/twilio/notification_spec.rb
|
254
|
+
- spec/twilio/outgoing_caller_id_spec.rb
|
255
|
+
- spec/twilio/recording_spec.rb
|
256
|
+
- spec/twilio/sms_spec.rb
|
257
|
+
- spec/twilio/verb_spec.rb
|
data/VERSION.yml
DELETED
data/lib/twilio/connection.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Twilio
|
2
|
-
include HTTParty
|
3
|
-
TWILIO_URL = "https://api.twilio.com/2010-04-01/Accounts"
|
4
|
-
|
5
|
-
# The connect method caches your Twilio account id and authentication token
|
6
|
-
# Example:
|
7
|
-
# Twilio.connect('AC309475e5fede1b49e100272a8640f438', '3a2630a909aadbf60266234756fb15a0')
|
8
|
-
def self.connect(account_sid, auth_token)
|
9
|
-
self.base_uri "#{TWILIO_URL}/#{account_sid}"
|
10
|
-
self.basic_auth account_sid, auth_token
|
11
|
-
end
|
12
|
-
|
13
|
-
# DEPRECATED - use Twilio.connect
|
14
|
-
class Connection
|
15
|
-
include HTTParty
|
16
|
-
TWILIO_URL = "https://api.twilio.com/2008-08-01/Accounts"
|
17
|
-
|
18
|
-
def initialize(account_sid, auth_token)
|
19
|
-
self.class.base_uri "#{TWILIO_URL}/#{account_sid}"
|
20
|
-
self.class.basic_auth account_sid, auth_token
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Twilio
|
2
|
-
# This sub-resource represents only Local phone numbers, or in other words, not toll-free numbers.
|
3
|
-
# Also allows you to request a new local phone number be added to your account.
|
4
|
-
# Example:
|
5
|
-
# Twilio.connect('my_twilio_sid', 'my_auth_token')
|
6
|
-
# Twilio::LocalPhoneNumber.list
|
7
|
-
class LocalPhoneNumber < TwilioObject
|
8
|
-
def create(url, area_code = nil, method = 'POST', friendly_name = nil, options = {})
|
9
|
-
Twilio.post("/IncomingPhoneNumbers/Local", :body => {
|
10
|
-
:VoiceUrl => url,
|
11
|
-
:AreaCode => area_code,
|
12
|
-
:VoiceMethod => method,
|
13
|
-
:FriendlyName => friendly_name
|
14
|
-
}.merge(options))
|
15
|
-
end
|
16
|
-
|
17
|
-
def list
|
18
|
-
Twilio.get("/IncomingPhoneNumbers/Local")
|
19
|
-
end
|
20
|
-
|
21
|
-
def delete(phone_number_sid)
|
22
|
-
Twilio.delete("/IncomingPhoneNumbers/#{phone_number_sid}")
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Twilio
|
2
|
-
# This sub-resource represents only Toll Free phone numbers, or in other words, not local numbers.
|
3
|
-
# Also allows you to request a new toll free phone number be added to your account.
|
4
|
-
# Example:
|
5
|
-
# Twilio.connect('my_twilio_sid', 'my_auth_token')
|
6
|
-
# Twilio::TollFreePhoneNumber.list
|
7
|
-
class TollFreePhoneNumber < TwilioObject
|
8
|
-
def create(url, area_code = nil, method = 'POST', friendly_name = nil)
|
9
|
-
Twilio.post("/IncomingPhoneNumbers/TollFree", :body => {
|
10
|
-
:VoiceUrl => url,
|
11
|
-
:AreaCode => area_code,
|
12
|
-
:VoiceMethod => method,
|
13
|
-
:FriendlyName => friendly_name
|
14
|
-
})
|
15
|
-
end
|
16
|
-
|
17
|
-
def list
|
18
|
-
Twilio.get("/IncomingPhoneNumbers/TollFree")
|
19
|
-
end
|
20
|
-
|
21
|
-
def delete(phone_number_sid)
|
22
|
-
Twilio.delete("/IncomingPhoneNumbers/#{phone_number_sid}")
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
@@ -1,11 +0,0 @@
|
|
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>
|
data/test/test_helper.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'fakeweb'
|
3
|
-
require 'shoulda'
|
4
|
-
require 'yaml'
|
5
|
-
require 'twilio'
|
6
|
-
|
7
|
-
FakeWeb.allow_net_connect = false
|
8
|
-
|
9
|
-
class Test::Unit::TestCase #:nodoc: all
|
10
|
-
end
|
11
|
-
|
12
|
-
def fixture(filename) #:nodoc:
|
13
|
-
path = File.join(File.dirname(__FILE__), "fixtures/xml/#{filename}.xml")
|
14
|
-
File.read path
|
15
|
-
end
|
16
|
-
|
17
|
-
def stub_response(verb, fixture_name, options = {}) #:nodoc:
|
18
|
-
fake_response = fixture(fixture_name)
|
19
|
-
resource = options.delete(:resource)
|
20
|
-
options = { :body => fake_response }.merge(options)
|
21
|
-
FakeWeb.register_uri(verb, twilio_url(resource), options)
|
22
|
-
|
23
|
-
fake_response
|
24
|
-
end
|
25
|
-
|
26
|
-
def twilio_url(url=nil) #:nodoc:
|
27
|
-
"https://mysid:mytoken@api.twilio.com:443/2010-04-01/Accounts/mysid#{'/' + url if url}"
|
28
|
-
end
|
29
|
-
|
30
|
-
def verb_response(verb) #:nodoc:
|
31
|
-
path = File.join(File.dirname(__FILE__), "fixtures/yml/verb_responses.yml")
|
32
|
-
YAML.load_file(path)[verb.to_s]['response']
|
33
|
-
end
|