nexmo-voice 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae184c99ebe299cbd4292676ecf3cbd3abd3d26b
4
- data.tar.gz: 21b45d35a87c5398f69bb85eef539bb2dd44079f
3
+ metadata.gz: 9d24b6a0dde0960412e1f82131ad423e88edd752
4
+ data.tar.gz: c8ec3595c30af2b7976be722b502283798d5a72b
5
5
  SHA512:
6
- metadata.gz: 78ced49e4f68710e11f573f5e904d6c797acfe8c2d55a1c69286b73c9dedd36fad67176ae9cea0ab149198e3e0c87aeb37ffe4b1fe5e28ec66d97cc34fa388ec
7
- data.tar.gz: 2487753de41f53f8813518e1a81b10af0da1324d6ab6ab4813ef623e004d0f3eb9a12d7271f3c86f4b2673ceacbaa137b6ba94d38a7ecedec8b097c29d652a2a
6
+ metadata.gz: c801a7f43351e700d7ca6369867b8f4fbfb052200ebc9e6a7c882b40e185a9482f073d09623f59a976cc1229c1a823eb27f3c3e60f6a3fa2fd1184dc1ae7dccf
7
+ data.tar.gz: 97f077752c30d2643287fa4df9f792e531d9f0ccd3b0d6a720eb3d0a7085bcaa2666bd9025a49ed390b26182a61966dcdddf2ce2a7c1f1db92340004b21c5921
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0
3
+ ## 0.1.2
4
+
5
+ * Support read_timeout and open_timeout
6
+ `Nexmo::Voice::Client.new 'your_key', 'your_secret', read_timeout: 2, open_timeout: 2`
7
+
8
+ ## 0.1.1
4
9
 
5
10
  * Support timeout `Nexmo::Voice::Client.new 'your_key', 'your_secret', timeout: 2`
@@ -6,18 +6,21 @@ require 'nexmo/voice/ttses'
6
6
 
7
7
  module Nexmo
8
8
  module Voice
9
- BASE_URL = 'https://api.nexmo.com'
9
+ BASE_URL = 'https://api.nexmo.com'.freeze
10
10
 
11
11
  class Client
12
12
  DEFAULT_TIMEOUT = 10
13
13
 
14
14
  attr_accessor :nexmo_adaptor, :api_config,
15
- :calls, :ttses
15
+ :calls, :ttses
16
16
 
17
17
  def initialize(api_key, api_secret, options = {})
18
- @nexmo_adaptor = RestClient::Resource.new(BASE_URL,
19
- timeout: options.fetch(:timeout) { DEFAULT_TIMEOUT },
20
- open_timeout: options.fetch(:open_timeout) { DEFAULT_TIMEOUT })
18
+ @nexmo_adaptor =
19
+ RestClient::Resource.new(
20
+ BASE_URL,
21
+ read_timeout: options.fetch(:read_timeout) { DEFAULT_TIMEOUT },
22
+ open_timeout: options.fetch(:open_timeout) { DEFAULT_TIMEOUT }
23
+ )
21
24
 
22
25
  @api_config = {
23
26
  api_key: api_key,
@@ -29,9 +32,9 @@ module Nexmo
29
32
  end
30
33
 
31
34
  def get(resource, entity = {})
32
- @nexmo_adaptor[resource.class::RELATIVE_URL].get(params: entity.merge(@api_config))
35
+ @nexmo_adaptor[resource.class::RELATIVE_URL]
36
+ .get(params: entity.merge(@api_config))
33
37
  end
34
38
  end
35
-
36
39
  end
37
40
  end
@@ -1,6 +1,6 @@
1
1
  module Nexmo::Voice
2
2
  class Calls
3
- RELATIVE_URL = '/call/json'
3
+ RELATIVE_URL = '/call/json'.freeze
4
4
 
5
5
  attr_accessor :client
6
6
 
@@ -12,6 +12,5 @@ module Nexmo::Voice
12
12
  def create(entity = {})
13
13
  @client.get(self, entity)
14
14
  end
15
-
16
15
  end
17
16
  end
@@ -1,6 +1,6 @@
1
1
  module Nexmo::Voice
2
2
  class Ttses
3
- RELATIVE_URL = '/tts/json'
3
+ RELATIVE_URL = '/tts/json'.freeze
4
4
 
5
5
  attr_accessor :client
6
6
 
@@ -12,7 +12,5 @@ module Nexmo::Voice
12
12
  def create(entity = {})
13
13
  @client.get(self, entity)
14
14
  end
15
-
16
15
  end
17
16
  end
18
-
@@ -1,5 +1,5 @@
1
1
  module Nexmo
2
2
  module Voice
3
- VERSION = "0.1.1"
3
+ VERSION = '0.1.2'.freeze
4
4
  end
5
5
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'rest-client', '~> 1.7.2'
21
+ spec.add_dependency 'rest-client', '~> 2.0', '>= 2.0.0'
22
22
 
23
23
  spec.add_development_dependency 'bundler', '~> 1.6'
24
24
  spec.add_development_dependency 'rake'
@@ -13,7 +13,8 @@ describe Nexmo::Voice::Calls do
13
13
  }
14
14
 
15
15
  it 'not raises errors' do
16
- stub_request(:get, %r(https://api.nexmo.com/call/json.*)).to_return(body: response_json)
16
+ stub_request(:get, %r{https://api.nexmo.com/call/json.*})
17
+ .to_return(body: response_json.to_json)
17
18
 
18
19
  expect {
19
20
  client.calls.create(entity)
@@ -21,10 +22,11 @@ describe Nexmo::Voice::Calls do
21
22
  end
22
23
 
23
24
  it 'timeouts' do
24
- stub_request(:get, %r(https://api.nexmo.com/call/json.*)).to_timeout
25
+ stub_request(:get, %r{https://api.nexmo.com/call/json.*})
26
+ .to_timeout
25
27
 
26
28
  expect {
27
29
  client.calls.create(entity)
28
- }.to raise_error
30
+ }.to raise_error(RestClient::Exceptions::ReadTimeout)
29
31
  end
30
32
  end
@@ -13,7 +13,8 @@ describe Nexmo::Voice::Ttses do
13
13
  }
14
14
 
15
15
  it 'not raises errors' do
16
- stub_request(:get, %r(https://api.nexmo.com/tts/json.*)).to_return(body: response_json)
16
+ stub_request(:get, %r{https://api.nexmo.com/tts/json.*})
17
+ .to_return(body: response_json.to_json)
17
18
 
18
19
  expect {
19
20
  client.ttses.create(entity)
@@ -21,11 +22,11 @@ describe Nexmo::Voice::Ttses do
21
22
  end
22
23
 
23
24
  it 'timeouts' do
24
- stub_request(:get, %r(https://api.nexmo.com/tts/json.*)).to_timeout
25
+ stub_request(:get, %r{https://api.nexmo.com/tts/json.*})
26
+ .to_timeout
25
27
 
26
28
  expect {
27
- client.calls.create(entity)
28
- }.to raise_error
29
+ client.ttses.create(entity)
30
+ }.to raise_error(RestClient::Exceptions::ReadTimeout)
29
31
  end
30
32
  end
31
-
@@ -16,13 +16,13 @@ RSpec.describe Nexmo::Voice::Client do
16
16
  end
17
17
 
18
18
  it 'sets the default timeout' do
19
- expect(client.nexmo_adaptor.timeout).to eq 10
20
- expect(client.nexmo_adaptor.open_timeout).to eq 10
19
+ expect(client.nexmo_adaptor.options[:read_timeout]).to eq 10
20
+ expect(client.nexmo_adaptor.options[:open_timeout]).to eq 10
21
21
  end
22
22
 
23
23
  it 'sets the timeout' do
24
- another_client = Nexmo::Voice::Client.new api_key, api_secret, timeout: 2, open_timeout: 1
25
- expect(another_client.nexmo_adaptor.timeout).to eq 2
26
- expect(another_client.nexmo_adaptor.open_timeout).to eq 1
24
+ another_client = Nexmo::Voice::Client.new api_key, api_secret, read_timeout: 2, open_timeout: 1
25
+ expect(another_client.nexmo_adaptor.options[:read_timeout]).to eq 2
26
+ expect(another_client.nexmo_adaptor.options[:open_timeout]).to eq 1
27
27
  end
28
28
  end
@@ -1,3 +1,2 @@
1
1
  require 'nexmo/voice'
2
2
  require 'webmock/rspec'
3
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexmo-voice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - fahchen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-31 00:00:00.000000000 Z
11
+ date: 2016-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.7.2
19
+ version: '2.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: 1.7.2
29
+ version: '2.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
129
  version: '0'
124
130
  requirements: []
125
131
  rubyforge_project:
126
- rubygems_version: 2.4.8
132
+ rubygems_version: 2.6.4
127
133
  signing_key:
128
134
  specification_version: 4
129
135
  summary: A Ruby wrapper for the Nexmo Voice API.