nexmo 5.4.0 → 5.5.0
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/LICENSE.txt +1 -1
- data/README.md +4 -4
- data/lib/nexmo.rb +2 -0
- data/lib/nexmo/authentication/abstract.rb +1 -1
- data/lib/nexmo/authentication/basic.rb +1 -1
- data/lib/nexmo/authentication/bearer_token.rb +1 -1
- data/lib/nexmo/authentication/key_secret_params.rb +1 -1
- data/lib/nexmo/authentication/key_secret_query.rb +1 -1
- data/lib/nexmo/client.rb +8 -0
- data/lib/nexmo/errors/error.rb +27 -0
- data/lib/nexmo/form_data.rb +1 -1
- data/lib/nexmo/http.rb +32 -0
- data/lib/nexmo/json.rb +1 -1
- data/lib/nexmo/keys.rb +1 -1
- data/lib/nexmo/logger.rb +1 -1
- data/lib/nexmo/namespace.rb +5 -9
- data/lib/nexmo/params.rb +1 -1
- data/lib/nexmo/problem.rb +20 -0
- data/lib/nexmo/user_agent.rb +1 -1
- data/lib/nexmo/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7339e40c57dc348e205411f04ffdb1d5f96bd0bb41fd481a4781c6a91b9c06c0
|
4
|
+
data.tar.gz: cb033f687f94529c18faf2b9bee41f7e9383fdc7954e9cf38f3cf15642d1bbeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbddc5433b0356fc806c999dbfc1185b5e5d90989cb1e1742812713e0624d3b7ed07fb21e333c55d0c774e44aec42e00c7bcc3e15f1b5079b4e3b1f626441c57
|
7
|
+
data.tar.gz: c56b00b6a05d095268289cb2238ee4d38f05b8da67f2d4c0d839f4ae89f09462fd44138b9e880187e75b01dbd356ed74dfad5038aefcf7588f93776a1ff408b5
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -53,7 +53,7 @@ Then construct a client object with your key and secret:
|
|
53
53
|
client = Nexmo::Client.new(api_key: 'YOUR-API-KEY', api_secret: 'YOUR-API-SECRET')
|
54
54
|
```
|
55
55
|
|
56
|
-
You can now use the client object to [send
|
56
|
+
You can now use the client object to [send an SMS](#send-an-sms),
|
57
57
|
[start a verification](#start-a-verification), or [create an application](#create-an-application).
|
58
58
|
|
59
59
|
For production you can specify the `NEXMO_API_KEY` and `NEXMO_API_SECRET`
|
@@ -153,7 +153,7 @@ Docs: [https://developer.nexmo.com/api/voice#startStream](https://developer.nexm
|
|
153
153
|
### Stop playing an audio file into a call
|
154
154
|
|
155
155
|
```ruby
|
156
|
-
response = client.stream.stop(uuid)
|
156
|
+
response = client.calls.stream.stop(uuid)
|
157
157
|
```
|
158
158
|
|
159
159
|
Docs: [https://developer.nexmo.com/api/voice#stopStream](https://developer.nexmo.com/api/voice?utm_source=DEV_REL&utm_medium=github&utm_campaign=ruby-client-library#stopStream)
|
@@ -161,7 +161,7 @@ Docs: [https://developer.nexmo.com/api/voice#stopStream](https://developer.nexmo
|
|
161
161
|
### Play text to speech into a call
|
162
162
|
|
163
163
|
```ruby
|
164
|
-
response = client.talk.start(uuid, text: 'Hello')
|
164
|
+
response = client.calls.talk.start(uuid, text: 'Hello')
|
165
165
|
```
|
166
166
|
|
167
167
|
Docs: [https://developer.nexmo.com/api/voice#startTalk](https://developer.nexmo.com/api/voice?utm_source=DEV_REL&utm_medium=github&utm_campaign=ruby-client-library#startTalk)
|
@@ -169,7 +169,7 @@ Docs: [https://developer.nexmo.com/api/voice#startTalk](https://developer.nexmo.
|
|
169
169
|
### Stop text to speech in a call
|
170
170
|
|
171
171
|
```ruby
|
172
|
-
response = client.talk.stop(uuid)
|
172
|
+
response = client.calls.talk.stop(uuid)
|
173
173
|
```
|
174
174
|
|
175
175
|
Docs: [https://developer.nexmo.com/api/voice#stopTalk](https://developer.nexmo.com/api/voice?utm_source=DEV_REL&utm_medium=github&utm_campaign=ruby-client-library#stopTalk)
|
data/lib/nexmo.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'nexmo/version'
|
2
2
|
require 'nexmo/params'
|
3
3
|
require 'nexmo/form_data'
|
4
|
+
require 'nexmo/http'
|
4
5
|
require 'nexmo/json'
|
5
6
|
require 'nexmo/jwt'
|
6
7
|
require 'nexmo/signature'
|
7
8
|
require 'nexmo/user_agent'
|
8
9
|
require 'nexmo/entity'
|
9
10
|
require 'nexmo/keys'
|
11
|
+
require 'nexmo/problem'
|
10
12
|
require 'nexmo/errors/error'
|
11
13
|
require 'nexmo/errors/client_error'
|
12
14
|
require 'nexmo/errors/server_error'
|
data/lib/nexmo/client.rb
CHANGED
@@ -25,9 +25,17 @@ module Nexmo
|
|
25
25
|
|
26
26
|
@user_agent = UserAgent.string(options[:app_name], options[:app_version])
|
27
27
|
|
28
|
+
self.http_options = options[:http]
|
29
|
+
|
28
30
|
self.logger = options[:logger] || (defined?(Rails.logger) && Rails.logger)
|
29
31
|
end
|
30
32
|
|
33
|
+
attr_reader :http_options
|
34
|
+
|
35
|
+
def http_options=(hash)
|
36
|
+
@http_options = HTTP::Options.new(hash)
|
37
|
+
end
|
38
|
+
|
31
39
|
def logger
|
32
40
|
@logger
|
33
41
|
end
|
data/lib/nexmo/errors/error.rb
CHANGED
@@ -1,4 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'json'
|
3
|
+
|
1
4
|
module Nexmo
|
2
5
|
class Error < StandardError
|
6
|
+
def self.parse(response) # :nodoc:
|
7
|
+
exception_class = case response
|
8
|
+
when Net::HTTPUnauthorized
|
9
|
+
AuthenticationError
|
10
|
+
when Net::HTTPClientError
|
11
|
+
ClientError
|
12
|
+
when Net::HTTPServerError
|
13
|
+
ServerError
|
14
|
+
else
|
15
|
+
Error
|
16
|
+
end
|
17
|
+
|
18
|
+
message = if content_type = response['Content-Type']
|
19
|
+
case content_type.split(';').first
|
20
|
+
when 'application/problem+json'
|
21
|
+
Problem.parse(response.body)
|
22
|
+
when 'application/json'
|
23
|
+
hash = ::JSON.parse(response.body)
|
24
|
+
hash['error_title']
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
exception_class.new(message)
|
29
|
+
end
|
3
30
|
end
|
4
31
|
end
|
data/lib/nexmo/form_data.rb
CHANGED
data/lib/nexmo/http.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
module Nexmo
|
5
|
+
module HTTP # :nodoc:
|
6
|
+
class Options
|
7
|
+
def initialize(hash)
|
8
|
+
@hash = hash || {}
|
9
|
+
|
10
|
+
@hash.each_key do |name|
|
11
|
+
next if defined_options.key?(name)
|
12
|
+
|
13
|
+
raise ArgumentError, "#{name.inspect} is not a valid option"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def set(http)
|
18
|
+
@hash.each do |name, value|
|
19
|
+
http.public_send(defined_options.fetch(name), value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def defined_options
|
26
|
+
@defined_options ||= Net::HTTP.instance_methods.grep(/\w=\z/).each_with_object({}) do |name, hash|
|
27
|
+
hash[name.to_s.chomp('=').to_sym] = name
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/nexmo/json.rb
CHANGED
data/lib/nexmo/keys.rb
CHANGED
data/lib/nexmo/logger.rb
CHANGED
data/lib/nexmo/namespace.rb
CHANGED
@@ -3,7 +3,7 @@ require 'net/http'
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
module Nexmo
|
6
|
-
class Namespace
|
6
|
+
class Namespace # :nodoc:
|
7
7
|
def initialize(client)
|
8
8
|
@client = client
|
9
9
|
|
@@ -11,8 +11,10 @@ module Nexmo
|
|
11
11
|
|
12
12
|
@host = self.class.host
|
13
13
|
|
14
|
-
@http = Net::HTTP.new(@host, Net::HTTP.https_default_port)
|
14
|
+
@http = Net::HTTP.new(@host, Net::HTTP.https_default_port, p_addr = nil)
|
15
15
|
@http.use_ssl = true
|
16
|
+
|
17
|
+
@client.http_options.set(@http)
|
16
18
|
end
|
17
19
|
|
18
20
|
def self.host
|
@@ -91,14 +93,8 @@ module Nexmo
|
|
91
93
|
else
|
92
94
|
response
|
93
95
|
end
|
94
|
-
when Net::HTTPUnauthorized
|
95
|
-
raise AuthenticationError
|
96
|
-
when Net::HTTPClientError
|
97
|
-
raise ClientError
|
98
|
-
when Net::HTTPServerError
|
99
|
-
raise ServerError
|
100
96
|
else
|
101
|
-
|
97
|
+
Error.parse(response)
|
102
98
|
end
|
103
99
|
end
|
104
100
|
end
|
data/lib/nexmo/params.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Nexmo
|
5
|
+
module Problem # :nodoc:
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def parse(body)
|
9
|
+
problem = ::JSON.parse(body)
|
10
|
+
|
11
|
+
title = problem['title']
|
12
|
+
|
13
|
+
detail = problem['detail']
|
14
|
+
|
15
|
+
url = problem['type']
|
16
|
+
|
17
|
+
"#{title}. #{detail} See #{url} for more info, or email support@nexmo.com if you have any questions."
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/nexmo/user_agent.rb
CHANGED
data/lib/nexmo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexmo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nexmo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/nexmo/errors/server_error.rb
|
98
98
|
- lib/nexmo/files.rb
|
99
99
|
- lib/nexmo/form_data.rb
|
100
|
+
- lib/nexmo/http.rb
|
100
101
|
- lib/nexmo/json.rb
|
101
102
|
- lib/nexmo/jwt.rb
|
102
103
|
- lib/nexmo/keys.rb
|
@@ -108,6 +109,7 @@ files:
|
|
108
109
|
- lib/nexmo/params.rb
|
109
110
|
- lib/nexmo/pricing.rb
|
110
111
|
- lib/nexmo/pricing_types.rb
|
112
|
+
- lib/nexmo/problem.rb
|
111
113
|
- lib/nexmo/redact.rb
|
112
114
|
- lib/nexmo/secrets.rb
|
113
115
|
- lib/nexmo/signature.rb
|