twilio-ruby 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ TWILIO_RUBY_ROOT = File.expand_path(File.dirname(__FILE__))
3
3
  require 'net/http'
4
4
  require 'net/https'
5
5
  require 'builder'
6
- require 'crack'
6
+ require 'json'
7
7
  require 'cgi'
8
8
  require 'openssl'
9
9
  require 'base64'
@@ -6,15 +6,14 @@ module Twilio
6
6
  include Twilio::REST::Utils
7
7
 
8
8
  attr_reader :account_sid, :account, :accounts
9
-
9
+
10
10
  def initialize(account_sid, auth_token, domain = 'api.twilio.com',
11
11
  proxy_host = nil, proxy_port = nil)
12
- @account_sid = account_sid
13
- @auth_token = auth_token
12
+ @account_sid, @auth_token = account_sid, auth_token
14
13
  set_up_connection_to domain, proxy_host, proxy_port
15
14
  set_up_subresources
16
15
  end
17
-
16
+
18
17
  # Define some helper methods for sending HTTP requests
19
18
  [:get, :put, :post, :delete].each do |method|
20
19
  method_class = Net::HTTP.const_get method.to_s.capitalize
@@ -24,13 +23,13 @@ module Twilio
24
23
  uri += "?#{url_encode(params)}" if !params.empty? && method == :get
25
24
  headers = {
26
25
  'Accept' => 'application/json',
27
- 'User-Agent' => 'twilio-ruby/3.0.0'
26
+ 'User-Agent' => 'twilio-ruby/3.1.0'
28
27
  }
29
28
  request = method_class.new uri, headers
30
29
  request.basic_auth @account_sid, @auth_token
31
30
  request.form_data = params if [:post, :put].include? method
32
31
  http_response = @connection.request request
33
- object = Crack::JSON.parse http_response.body if http_response.body
32
+ object = JSON.parse http_response.body if http_response.body
34
33
  if http_response.kind_of? Net::HTTPClientError
35
34
  raise Twilio::REST::RequestError, object['message']
36
35
  elsif http_response.kind_of? Net::HTTPServerError
@@ -65,9 +64,9 @@ module Twilio
65
64
  req.basic_auth @account_sid, @auth_token
66
65
  @connection.request req
67
66
  end
68
-
67
+
69
68
  private
70
-
69
+
71
70
  def set_up_connection_to(domain, proxy_host = nil, proxy_port = nil)
72
71
  connection_class = Net::HTTP::Proxy proxy_host, proxy_port
73
72
  @connection = connection_class.new domain, 443
@@ -77,7 +76,7 @@ module Twilio
77
76
  # But cert validation is usually a nightmare, so we skip it for now.
78
77
  @connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
79
78
  end
80
-
79
+
81
80
  def set_up_subresources
82
81
  accounts_uri = '/2010-04-01/Accounts'
83
82
  account_uri = "#{accounts_uri}/#{@account_sid}"
@@ -86,7 +85,7 @@ module Twilio
86
85
  # Set up the accounts subresource.
87
86
  @accounts = Twilio::REST::Accounts.new accounts_uri, self
88
87
  end
89
-
88
+
90
89
  end
91
90
  end
92
91
  end
@@ -1,5 +1,11 @@
1
1
  module Twilio
2
2
  module REST
3
- class Messages < ListResource; end
3
+ class Messages < ListResource
4
+ def initialize(uri, client)
5
+ super
6
+ # hard-code the json key since 'messages' doesn't exist in the response
7
+ @resource_name = 'sms_messages'
8
+ end
9
+ end
4
10
  end
5
11
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "twilio-ruby"
3
- s.version = "3.0.0"
3
+ s.version = "3.1.0"
4
4
  s.author = "Andrew Benton"
5
5
  s.email = "andrew@twilio.com"
6
6
  s.description = "A simple library for communicating with the Twilio REST API"
@@ -9,6 +9,6 @@ Gem::Specification.new do |s|
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.files = Dir['lib/**/*.rb'] + Dir['test/**/*.rb'] + ['examples.rb', 'Rakefile', 'LICENSE', 'README.md', 'twilio-ruby.gemspec']
11
11
  s.test_files = Dir['test/**/*.rb']
12
+ s.add_dependency("json", ">= 1.2.0")
12
13
  s.add_dependency("builder", ">= 2.1.2")
13
- s.add_dependency("crack", ">= 0.1.8")
14
14
  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: 7
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 3.0.0
10
+ version: 3.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Benton
@@ -15,39 +15,39 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-15 00:00:00 -07:00
18
+ date: 2011-07-17 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: builder
22
+ name: json
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 15
29
+ hash: 31
30
30
  segments:
31
- - 2
32
31
  - 1
33
32
  - 2
34
- version: 2.1.2
33
+ - 0
34
+ version: 1.2.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: crack
38
+ name: builder
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- hash: 11
45
+ hash: 15
46
46
  segments:
47
- - 0
47
+ - 2
48
48
  - 1
49
- - 8
50
- version: 0.1.8
49
+ - 2
50
+ version: 2.1.2
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  description: A simple library for communicating with the Twilio REST API