twilio-ruby 3.4.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -42,13 +42,13 @@ capability.allow_client_incoming 'andrew'
42
42
  @token = capability.generate
43
43
  ```
44
44
 
45
- There is a slightly more detailed document in the
46
- [Capability](twilio-ruby/wiki/Capability) section of the wiki.
45
+ There is a slightly more detailed document in the [Capability][capability]
46
+ section of the wiki.
47
47
 
48
48
  ## Getting Started With TwiML
49
49
 
50
- TwiML support is based on the [builder][1] library. You can construct a TwiML
51
- response like this:
50
+ TwiML support is based on the [builder][builder] library. You can construct a
51
+ TwiML response like this:
52
52
 
53
53
  ``` ruby
54
54
  require 'rubygems' # not necessary with ruby 1.9 but included for completeness
@@ -144,8 +144,15 @@ auth_token = '62ea81de3a5b414154eb263595357c69'
144
144
 
145
145
  ## More Information
146
146
 
147
- There are more detailed examples in the included [examples.rb](twilio-ruby/blob/master/examples.rb).
147
+ There are more detailed examples in the included [examples.rb][examples].
148
148
 
149
- Full [API documentation](twilio-ruby/wiki/Documentation), as well as an [upgrade guide](twilio-ruby/wiki/UpgradeGuide) for users of the old twiliolib gem, is available in the [twilio-ruby github wiki](twilio-ruby/wiki).
149
+ Full [API documentation][documentation], as well as an [upgrade guide][upgrade]
150
+ for users of the old twiliolib gem, is available in the
151
+ [twilio-ruby github wiki][wiki].
150
152
 
151
- [1]:http://builder.rubyforge.org/
153
+ [capability]:https://github.com/twilio/twilio-ruby/wiki/Capability
154
+ [builder]:http://builder.rubyforge.org/
155
+ [examples]:https://github.com/twilio/twilio-ruby/blob/master/examples.rb
156
+ [documentation]:https://github.com/twilio/twilio-ruby/wiki/Documentation
157
+ [upgrade]:https://github.com/twilio/twilio-ruby/wiki/UpgradeGuide
158
+ [wiki]:https://github.com/twilio/twilio-ruby/wiki
@@ -82,6 +82,11 @@ module Twilio
82
82
  # to avoid insecure connection warnings in environments without the proper
83
83
  # cert validation chain.
84
84
  #
85
+ # === <tt>:ssl_ca_file => '/path/to/ca/file'</tt>
86
+ #
87
+ # Specify the path to the certificate authority bundle you'd like to use
88
+ # when verifying Twilio's SSL certificate.
89
+ #
85
90
  # === <tt>:timeout => 30</tt>
86
91
  #
87
92
  # Set the time in seconds to wait before timing out the HTTP request.
@@ -125,7 +130,7 @@ module Twilio
125
130
  method_class = Net::HTTP.const_get method.to_s.capitalize
126
131
  define_method method do |uri, *args|
127
132
  params = twilify args[0]; params = {} if params.empty?
128
- uri += '.json' # create a local copy of the uri to manipulate
133
+ uri = "#{uri}.json" # create a local copy of the uri to manipulate
129
134
  uri << "?#{url_encode(params)}" if method == :get && !params.empty?
130
135
  request = method_class.new uri, HTTP_HEADERS
131
136
  request.basic_auth @account_sid, @auth_token
@@ -181,6 +186,7 @@ module Twilio
181
186
  config[:proxy_port], config[:proxy_user], config[:proxy_pass]
182
187
  @connection = connection_class.new config[:host], config[:port]
183
188
  @connection.use_ssl = config[:use_ssl]
189
+ @connection.ca_file = config[:ssl_ca_file]
184
190
  unless config[:ssl_verify_peer]
185
191
  @connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
186
192
  end
@@ -38,8 +38,7 @@ module Twilio
38
38
  # instance resource, including the newly updated properties.
39
39
  def update(params = {})
40
40
  raise "Can't update a resource without a REST Client" unless @client
41
- response = @client.post @uri, params
42
- set_up_properties_from response
41
+ set_up_properties_from(@client.post(@uri, params))
43
42
  self
44
43
  end
45
44
 
@@ -49,8 +48,7 @@ module Twilio
49
48
  def refresh
50
49
  raise "Can't refresh a resource without a REST Client" unless @client
51
50
  @updated = false
52
- response = @client.get @uri
53
- set_up_properties_from response
51
+ set_up_properties_from(@client.get(@uri))
54
52
  self
55
53
  end
56
54
 
@@ -68,8 +66,7 @@ module Twilio
68
66
  # until an attempt is made to access an unknown attribute.
69
67
  def method_missing(method, *args)
70
68
  super if @updated
71
- response = @client.get @uri
72
- set_up_properties_from response
69
+ set_up_properties_from(@client.get(@uri))
73
70
  self.send method, *args
74
71
  end
75
72
 
@@ -33,10 +33,10 @@ module Twilio
33
33
  resource
34
34
  end
35
35
  # set the +total+ property on the array
36
- resource_list.instance_eval {
36
+ resource_list.instance_eval do
37
37
  eigenclass = class << self; self; end
38
38
  eigenclass.send :define_method, :total, &lambda {response['total']}
39
- }
39
+ end
40
40
  resource_list
41
41
  end
42
42
 
@@ -49,8 +49,7 @@ module Twilio
49
49
  # +total+ attribute as well.
50
50
  def total
51
51
  raise "Can't get a resource total without a REST Client" unless @client
52
- response = @client.get @uri, :page_size => 1
53
- @total = response['total']
52
+ @client.get(@uri, :page_size => 1)['total']
54
53
  end
55
54
 
56
55
  ##
@@ -1,3 +1,3 @@
1
1
  module Twilio
2
- VERSION = '3.4.0'
2
+ VERSION = '3.4.1'
3
3
  end
data/test/twilio_spec.rb CHANGED
@@ -21,6 +21,12 @@ describe Twilio::REST::Client do
21
21
  twilio.instance_variable_get('@connection').use_ssl?.should == true
22
22
  end
23
23
 
24
+ it 'should set up the requested ssl verification ca_file if provided' do
25
+ twilio = Twilio::REST::Client.new('someSid', 'someToken', :ssl_ca_file => '/path/to/ca/file')
26
+ connection = twilio.instance_variable_get('@connection')
27
+ connection.ca_file.should == '/path/to/ca/file'
28
+ end
29
+
24
30
  it 'should set up the proper http ssl connection when a different domain is given' do
25
31
  twilio = Twilio::REST::Client.new('someSid', 'someToken', :host => 'api.faketwilio.com')
26
32
  twilio.instance_variable_get('@connection').address.should == 'api.faketwilio.com'
@@ -182,39 +188,65 @@ describe Twilio::REST::Recording do
182
188
  end
183
189
 
184
190
  describe Twilio::Util::RequestValidator do
185
- it 'should properly validate a Twilio request based on its signature' do
186
- token = '1c892n40nd03kdnc0112slzkl3091j20'
191
+ it 'should properly validate a Twilio Voice request' do
192
+ token = '2bd9e9638872de601313dc77410d3b23'
187
193
  validator = Twilio::Util::RequestValidator.new token
188
- url = 'http://www.postbin.org/1ed898x'
194
+ url = 'http://twiliotests.heroku.com/validate/voice'
189
195
  params = {
190
- 'AccountSid' => 'AC9a9f9392lad99kla0sklakjs90j092j3',
191
- 'ApiVersion' => '2010-04-01',
192
- 'CallSid' => 'CAd800bb12c0426a7ea4230e492fef2a4f',
193
- 'CallStatus' => 'ringing',
194
- 'Called' => '+15306384866',
195
- 'CalledCity' => 'OAKLAND',
196
- 'CalledCountry' => 'US',
197
- 'CalledState' => 'CA',
198
- 'CalledZip' => '94612',
199
- 'Caller' => '+15306666666',
200
- 'CallerCity' => 'SOUTH LAKE TAHOE',
201
- 'CallerCountry' => 'US',
202
- 'CallerName' => 'CA Wireless Call',
203
- 'CallerState' => 'CA',
204
- 'CallerZip' => '89449',
196
+ 'ToState' => 'California',
197
+ 'CalledState' => 'California',
205
198
  'Direction' => 'inbound',
206
- 'From' => '+15306666666',
207
- 'FromCity' => 'SOUTH LAKE TAHOE',
208
- 'FromCountry' => 'US',
209
199
  'FromState' => 'CA',
210
- 'FromZip' => '89449',
211
- 'To' => '+15306384866',
212
- 'ToCity' => 'OAKLAND',
200
+ 'AccountSid' => 'ACba8bc05eacf94afdae398e642c9cc32d',
201
+ 'Caller' => '+14153595711',
202
+ 'CallerZip' => '94108',
203
+ 'CallerCountry' => 'US',
204
+ 'From' => '+14153595711',
205
+ 'FromCity' => 'SAN FRANCISCO',
206
+ 'CallerCity' => 'SAN FRANCISCO',
207
+ 'To' => '+14157669926',
208
+ 'FromZip' => '94108',
209
+ 'FromCountry' => 'US',
210
+ 'ToCity' => '',
211
+ 'CallStatus' => 'ringing',
212
+ 'CalledCity' => '',
213
+ 'CallerState' => 'CA',
214
+ 'CalledZip' => '',
215
+ 'ToZip' => '',
213
216
  'ToCountry' => 'US',
217
+ 'CallSid' => 'CA136d09cd59a3c0ec8dbff44da5c03f31',
218
+ 'CalledCountry' => 'US',
219
+ 'Called' => '+14157669926',
220
+ 'ApiVersion' => '2010-04-01',
221
+ 'ApplicationSid' => 'AP44efecad51364e80b133bb7c07eb8204'
222
+ }
223
+ signature = 'oVb2kXoVy8GEfwBDjR8bk/ZZ6eA='
224
+ validator.validate(url, params, signature).should == true
225
+ end
226
+
227
+ it 'should properly validate a Twilio SMS request' do
228
+ token = '2bd9e9638872de601313dc77410d3b23'
229
+ validator = Twilio::Util::RequestValidator.new token
230
+ url = 'http://twiliotests.heroku.com/validate/sms'
231
+ params = {
214
232
  'ToState' => 'CA',
215
- 'ToZip' => '94612'
233
+ 'FromState' => 'CA',
234
+ 'AccountSid' => 'ACba8bc05eacf94afdae398e642c9cc32d',
235
+ 'SmsMessageSid' => 'SM2003cbd5e6a3701999aa3e5f20ff2787',
236
+ 'Body' => 'Orly',
237
+ 'From' => '+14159354345',
238
+ 'FromCity' => 'SAN FRANCISCO',
239
+ 'SmsStatus' => 'received',
240
+ 'FromZip' => '94107',
241
+ 'FromCountry' => 'US',
242
+ 'To' => '+14158141819',
243
+ 'ToCity' => 'SAN FRANCISCO',
244
+ 'ToZip' => '94105',
245
+ 'ToCountry' => 'US',
246
+ 'ApiVersion' => '2010-04-01',
247
+ 'SmsSid' => 'SM2003cbd5e6a3701999aa3e5f20ff2787'
216
248
  }
217
- signature = 'fF+xx6dTinOaCdZ0aIeNkHr/ZAA='
249
+ signature = 'mxeiv65lEe0b8L6LdVw2jgJi8yw='
218
250
  validator.validate(url, params, signature).should == true
219
251
  end
220
252
  end
data/twilio-ruby.gemspec CHANGED
@@ -24,6 +24,6 @@ Gem::Specification.new do |s|
24
24
  s.add_development_dependency 'fakeweb', '~> 1.3.0'
25
25
  s.add_development_dependency 'rack', '~> 1.3.0'
26
26
 
27
- s.extra_rdoc_files = ['README.md', 'README.rdoc', 'examples.rb', 'LICENSE']
27
+ s.extra_rdoc_files = ['README.md', 'examples.rb', 'LICENSE']
28
28
  s.rdoc_options = ['--line-numbers', '--inline-source', '--title', 'twilio-ruby', '--main', 'README.md']
29
29
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio-ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 4
9
- - 0
10
- version: 3.4.0
9
+ - 1
10
+ version: 3.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Benton
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-21 00:00:00 -07:00
18
+ date: 2011-10-09 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -138,7 +138,6 @@ extensions: []
138
138
 
139
139
  extra_rdoc_files:
140
140
  - README.md
141
- - README.rdoc
142
141
  - examples.rb
143
142
  - LICENSE
144
143
  files:
@@ -146,7 +145,6 @@ files:
146
145
  - Gemfile
147
146
  - LICENSE
148
147
  - README.md
149
- - README.rdoc
150
148
  - Rakefile
151
149
  - examples.rb
152
150
  - lib/twilio-ruby.rb
data/README.rdoc DELETED
File without changes