twilio-ruby 4.2.0 → 4.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZDNmMGMwNWY2OTAyNTlmNmJmMzYxOTI4ZWVjYzdjYWRiNGI1Yzc3NQ==
5
- data.tar.gz: !binary |-
6
- YTQ5YjQzNDBlYjIyYTNlMzgzNGVkODg1MThiY2FiN2NiNTBkZGU0NQ==
2
+ SHA1:
3
+ metadata.gz: af489771a6143eed6bab64834224d33424173807
4
+ data.tar.gz: 9ace9554caa5f9726e8391aaa554dbd9ccfcd2a3
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NjNlOTQ1NmFjMzdmNDI0MDhkMzA4MTkwOTI1NzEyNDkzY2FiMGQ3ZDBkMzll
10
- OWZmMzc2ZjQ2YWM3MzI2Y2JkMTNkNGIwMzUwZTBmOTQ1NzVhNzQ3MDJhODQ3
11
- MDQ0NThjNmU4NjdiYjhkMGEzMjBkMDM0MjJlMjcxZTU5NzU5NDM=
12
- data.tar.gz: !binary |-
13
- M2QzOWIxMjliYzRjNTQ0YTYyMjU4NTU1MDFiYjc2NTI1NTllMGNmODNmOTZm
14
- YTMxYzQ3YWQ4OTg5YTBhNDAxMjU3MjJmOWRhZDZlNjU3ODllMzQyMDRmYTRm
15
- NGZjYTM1MGQ3Yzg5MDRlZThlNzY5MmQ4N2M3NDZlZDcwMGJiMDg=
6
+ metadata.gz: 73a48780f30ca69167c4de6f48acea63366718ddb6d54908e11147075edb864497f7972b2de58393e50c28cf77076c8754fc28b34ebcd7a45264aaea3b962d25
7
+ data.tar.gz: 885802c111f183d73945f7fd8ddc99f75834017890e4a304e26296a791e9b508396771bf77bbabcf2588a8e5aa1e07b3f46d9094c77e7e9e265acfa008e9a12e
data/CHANGES.md CHANGED
@@ -1,6 +1,15 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ Version 4.2.1
5
+ -------------
6
+
7
+ Release June 19, 2015
8
+
9
+ - Allow passing URL parameters through when getting statistics for TaskRouter objects
10
+ - URI encode phone number lookups
11
+ - Adds documentation for lookups
12
+
4
13
  Version 4.2.0
5
14
  -------------
6
15
 
data/README.md CHANGED
@@ -11,7 +11,7 @@ A module for using the Twilio REST API and generating valid [TwiML](http://www.t
11
11
  To install using [Bundler][bundler] grab the latest stable version:
12
12
 
13
13
  ```ruby
14
- gem 'twilio-ruby', '~> 4.1.0'
14
+ gem 'twilio-ruby', '~> 4.2.1'
15
15
  ```
16
16
 
17
17
  To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install:
@@ -147,6 +147,30 @@ capability.allow_client_incoming 'andrew'
147
147
  There is a slightly more detailed document in the [Capability][capability]
148
148
  section of the wiki.
149
149
 
150
+ ## Lookup Phone Number information
151
+
152
+ You can look up details on phone numbers with the Lookups API.
153
+
154
+ ```ruby
155
+ require 'twilio-ruby'
156
+
157
+ # put your own credentials here
158
+ account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
159
+ auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
160
+
161
+ # set up a client to talk to the Twilio REST API
162
+ @lookups_client = Twilio::REST::LookupsClient.new account_sid, auth_token
163
+
164
+ # lookup a number
165
+ number = @lookups_client.phone_numbers.get('+14159341234')
166
+
167
+ # investigate the number
168
+ number.national_format
169
+ # => "(415) 934-1234"
170
+ number.country_code
171
+ # => "US"
172
+ ```
173
+
150
174
  ## Getting Started With TwiML
151
175
 
152
176
  TwiML support is based on the [Builder][builder] library. You can construct a
@@ -201,7 +225,7 @@ If you've instead found a bug in the library or would like new features added, g
201
225
  ## More Information
202
226
 
203
227
  There are more detailed examples in the included [examples][examples]
204
- directory. Also for thoose upgrading, the [upgrade guide][upgrade] is available in the [twilio-ruby github wiki][wiki].
228
+ directory. Also for those upgrading, the [upgrade guide][upgrade] is available in the [twilio-ruby github wiki][wiki].
205
229
 
206
230
  [capability]: https://github.com/twilio/twilio-ruby/wiki/Capability
207
231
  [builder]: http://builder.rubyforge.org/
@@ -71,6 +71,16 @@ state.
71
71
  usage/taskrouter-tokens
72
72
 
73
73
 
74
+ Lookups
75
+ -------
76
+
77
+ Query the Lookups API to get information about phone numbers and their carriers.
78
+
79
+ .. toctree::
80
+ :maxdepth: 1
81
+
82
+ usage/lookups
83
+
74
84
  TwiML
75
85
  ---------
76
86
 
@@ -0,0 +1,62 @@
1
+ ===========
2
+ Lookups API
3
+ ===========
4
+
5
+ Lookups allows you to systematically ascertain information about phone numbers. With Lookups, you can identify local-friendly number formats, reduce the likelihood of undelivered messages and protect yourself from fraud.
6
+
7
+ For more information see the `Lookups API <https://www.twilio.com/docs/api/rest/lookups>`_ documentation.
8
+
9
+ Looking up details on a phone number
10
+ ------------------------------------
11
+
12
+ You can look up a phone number with a :class:`Twilio::REST::LookupsClient`. You instantiate the client as you would with any other :class:`Twilio::REST` client
13
+
14
+ .. code-block:: ruby
15
+
16
+ require "twilio-ruby"
17
+
18
+ # Find these values at twilio.com/user/account
19
+ account_sid = "AC123123"
20
+ auth_token = "secret"
21
+
22
+ @lookups_client = Twilio::REST::LookupsClient.new account_sid, auth_token
23
+
24
+ You can then use the client to lookup a phone number.
25
+
26
+ .. code-block:: ruby
27
+
28
+ response = @lookups_client.phone_numbers.get("+12316851234")
29
+ response.country_code
30
+ # => "US"
31
+ response.phone_number
32
+ # => "+12316851234"
33
+ response.national_format
34
+ # => "(231) 685-1234"
35
+ response.url
36
+ # => "https://lookups.twilio.com/v1/PhoneNumbers/+12316851234"
37
+
38
+ Invalid Phone Numbers
39
+ ---------------------
40
+
41
+ The Lookups API is a REST API that returns data on phone number resources. If you try to lookup a phone number that doesn't exist the API will raise a 404 :class:`Twilio::REST::RequestError`. You should handle this within your code.
42
+
43
+ .. code-block:: ruby
44
+
45
+ response = @lookups_client.phone_numbers.get("+15558675309")
46
+ begin
47
+ puts response.phone_number
48
+ rescue Twilio::REST::RequestError => e
49
+ raise e unless e.code == 20404 # ensure this is a 404 error
50
+ puts "Invalid number"
51
+ end
52
+
53
+ Carrier Information
54
+ -------------------
55
+
56
+ The Lookups API can be used to find out more information about the carrier for the phone number. Just pass the type "carrier" to the request.
57
+
58
+ .. code-block:: ruby
59
+
60
+ response = @lookups_client.phone_numbers.get("+12316851234", type: "carrier")
61
+ response.carrier
62
+ # => {"mobile_country_code"=>nil, "mobile_network_code"=>nil, "name"=>"Charter Fiberlink, LLC", "type"=>"landline", "error_code"=>nil}
@@ -6,7 +6,7 @@ module Twilio
6
6
  include Twilio::REST::Utils
7
7
 
8
8
  def get(number, query={})
9
- full_path = "#{@path}/#{number}"
9
+ full_path = "#{@path}/#{URI.encode(number)}"
10
10
  full_path << "?#{url_encode(twilify(query))}" if !query.empty?
11
11
  @instance_class.new full_path, @client
12
12
  end
@@ -4,7 +4,7 @@ module Twilio
4
4
  module Statistics
5
5
  def statistics(args={})
6
6
  path = "#{@path}/Statistics"
7
- response = @client.get(path, args, true)
7
+ response = @client.get(path, args)
8
8
  statistics_class.new(path, @client, response)
9
9
  end
10
10
 
@@ -1,3 +1,3 @@
1
1
  module Twilio
2
- VERSION = '4.2.0'
2
+ VERSION = '4.2.1'
3
3
  end
@@ -5,4 +5,24 @@ describe Twilio::REST::Lookups::PhoneNumbers do
5
5
  client = Twilio::REST::LookupsClient.new 'otherSid', 'otherToken'
6
6
  expect(client).to respond_to(:phone_numbers)
7
7
  end
8
+
9
+ it 'gets phone numbers without special encoding' do
10
+ number = '+13123131434'
11
+ client = Twilio::REST::LookupsClient.new 'otherSid', 'otherToken'
12
+ expect(client).to receive(:get).once
13
+ .with('/v1/PhoneNumbers/+13123131434')
14
+ .and_return({ phone_number: number })
15
+ phone_number = client.phone_numbers.get('+13123131434').phone_number
16
+ expect(phone_number).to be(number)
17
+ end
18
+
19
+ it 'URI encodes phone number path parameters' do
20
+ number = '+13123131434'
21
+ client = Twilio::REST::LookupsClient.new 'otherSid', 'otherToken'
22
+ expect(client).to receive(:get).once
23
+ .with('/v1/PhoneNumbers/+1%20312%20313%201434')
24
+ .and_return({ phone_number: number })
25
+ phone_number = client.phone_numbers.get('+1 312 313 1434').phone_number
26
+ expect(phone_number).to be(number)
27
+ end
8
28
  end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ class Twilio::REST::TaskRouter::StatisticsTestHarnessStatistics
4
+ def initialize(*args)
5
+ end
6
+ end
7
+
8
+ class StatisticsTestHarness
9
+ include Twilio::REST::TaskRouter::Statistics
10
+
11
+ def initialize(path, client)
12
+ @path = path
13
+ @client = client
14
+ end
15
+ end
16
+
17
+ describe Twilio::REST::TaskRouter::Statistics do
18
+ it "creates a new statistics object based on the class" do
19
+ client = double("Client")
20
+ allow(client).to receive(:get)
21
+ harness = StatisticsTestHarness.new("/test/harness", client)
22
+ expect(harness.statistics).to(
23
+ be_an_instance_of(Twilio::REST::TaskRouter::StatisticsTestHarnessStatistics)
24
+ )
25
+ end
26
+
27
+ it "passes parameters to the HTTP request for statistics" do
28
+ client = Twilio::REST::TaskRouterClient.new 'someSid', 'someAuthToken', 'someWorkspaceSid'
29
+ allow(Net::HTTP::Get).to receive(:new)
30
+ .with("/test/harness/Statistics?Minutes=15", Twilio::REST::BaseClient::HTTP_HEADERS)
31
+ .and_call_original
32
+ harness = StatisticsTestHarness.new("/test/harness", client)
33
+ expect(harness.statistics(minutes: 15)).to(
34
+ be_an_instance_of(Twilio::REST::TaskRouter::StatisticsTestHarnessStatistics)
35
+ )
36
+ end
37
+ end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Benton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-19 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.1.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.1.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jwt
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.5'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.5'
69
69
  description: A simple library for communicating with the Twilio REST API, building
@@ -76,8 +76,8 @@ extra_rdoc_files:
76
76
  - README.md
77
77
  - LICENSE.md
78
78
  files:
79
- - .gitignore
80
- - .travis.yml
79
+ - ".gitignore"
80
+ - ".travis.yml"
81
81
  - AUTHORS.md
82
82
  - CHANGES.md
83
83
  - Gemfile
@@ -112,6 +112,7 @@ files:
112
112
  - docs/usage/caller-ids.rst
113
113
  - docs/usage/conferences.rst
114
114
  - docs/usage/errors.rst
115
+ - docs/usage/lookups.rst
115
116
  - docs/usage/messages.rst
116
117
  - docs/usage/notifications.rst
117
118
  - docs/usage/phone-calls.rst
@@ -234,6 +235,7 @@ files:
234
235
  - spec/rest/sms/message_spec.rb
235
236
  - spec/rest/sms/messages_spec.rb
236
237
  - spec/rest/task_router/reservation_spec.rb
238
+ - spec/rest/task_router/statistics_spec.rb
237
239
  - spec/rest/task_router/task_queue_spec.rb
238
240
  - spec/rest/token_spec.rb
239
241
  - spec/rest/utils_spec.rb
@@ -253,27 +255,27 @@ licenses:
253
255
  metadata: {}
254
256
  post_install_message:
255
257
  rdoc_options:
256
- - --line-numbers
257
- - --inline-source
258
- - --title
258
+ - "--line-numbers"
259
+ - "--inline-source"
260
+ - "--title"
259
261
  - twilio-ruby
260
- - --main
262
+ - "--main"
261
263
  - README.md
262
264
  require_paths:
263
265
  - lib
264
266
  required_ruby_version: !ruby/object:Gem::Requirement
265
267
  requirements:
266
- - - ! '>='
268
+ - - ">="
267
269
  - !ruby/object:Gem::Version
268
270
  version: 1.9.3
269
271
  required_rubygems_version: !ruby/object:Gem::Requirement
270
272
  requirements:
271
- - - ! '>='
273
+ - - ">="
272
274
  - !ruby/object:Gem::Version
273
275
  version: '0'
274
276
  requirements: []
275
277
  rubyforge_project:
276
- rubygems_version: 2.4.1
278
+ rubygems_version: 2.4.5
277
279
  signing_key:
278
280
  specification_version: 4
279
281
  summary: A simple library for communicating with the Twilio REST API, building TwiML,
@@ -298,6 +300,7 @@ test_files:
298
300
  - spec/rest/sms/message_spec.rb
299
301
  - spec/rest/sms/messages_spec.rb
300
302
  - spec/rest/task_router/reservation_spec.rb
303
+ - spec/rest/task_router/statistics_spec.rb
301
304
  - spec/rest/task_router/task_queue_spec.rb
302
305
  - spec/rest/token_spec.rb
303
306
  - spec/rest/utils_spec.rb