nexmo-voice 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/nexmo/voice.rb +10 -7
- data/lib/nexmo/voice/calls.rb +1 -2
- data/lib/nexmo/voice/ttses.rb +1 -3
- data/lib/nexmo/voice/version.rb +1 -1
- data/nexmo-voice.gemspec +1 -1
- data/spec/nexmo/voice/calls_spec.rb +5 -3
- data/spec/nexmo/voice/ttses_spec.rb +6 -5
- data/spec/nexmo/voice_spec.rb +5 -5
- data/spec/spec_helper.rb +0 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d24b6a0dde0960412e1f82131ad423e88edd752
|
4
|
+
data.tar.gz: c8ec3595c30af2b7976be722b502283798d5a72b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c801a7f43351e700d7ca6369867b8f4fbfb052200ebc9e6a7c882b40e185a9482f073d09623f59a976cc1229c1a823eb27f3c3e60f6a3fa2fd1184dc1ae7dccf
|
7
|
+
data.tar.gz: 97f077752c30d2643287fa4df9f792e531d9f0ccd3b0d6a720eb3d0a7085bcaa2666bd9025a49ed390b26182a61966dcdddf2ce2a7c1f1db92340004b21c5921
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 0.1.
|
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`
|
data/lib/nexmo/voice.rb
CHANGED
@@ -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
|
-
|
15
|
+
:calls, :ttses
|
16
16
|
|
17
17
|
def initialize(api_key, api_secret, options = {})
|
18
|
-
@nexmo_adaptor =
|
19
|
-
|
20
|
-
|
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]
|
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
|
data/lib/nexmo/voice/calls.rb
CHANGED
data/lib/nexmo/voice/ttses.rb
CHANGED
data/lib/nexmo/voice/version.rb
CHANGED
data/nexmo-voice.gemspec
CHANGED
@@ -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', '~>
|
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
|
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
|
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
|
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
|
25
|
+
stub_request(:get, %r{https://api.nexmo.com/tts/json.*})
|
26
|
+
.to_timeout
|
25
27
|
|
26
28
|
expect {
|
27
|
-
client.
|
28
|
-
}.to raise_error
|
29
|
+
client.ttses.create(entity)
|
30
|
+
}.to raise_error(RestClient::Exceptions::ReadTimeout)
|
29
31
|
end
|
30
32
|
end
|
31
|
-
|
data/spec/nexmo/voice_spec.rb
CHANGED
@@ -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.
|
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,
|
25
|
-
expect(another_client.nexmo_adaptor.
|
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
|
data/spec/spec_helper.rb
CHANGED
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.
|
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-
|
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:
|
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:
|
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
|
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.
|