nexmo 5.5.0 → 5.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +18 -0
- data/lib/nexmo.rb +2 -1
- data/lib/nexmo/client.rb +4 -0
- data/lib/nexmo/entity.rb +3 -21
- data/lib/nexmo/keys.rb +14 -0
- data/lib/nexmo/params.rb +2 -2
- data/lib/nexmo/signature.rb +2 -2
- data/lib/nexmo/tfa.rb +13 -0
- data/lib/nexmo/version.rb +1 -1
- data/nexmo.gemspec +1 -0
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcef65e09c820aa2be62979694389d22332b6950ac9032e83aeacc1b9a3b09ec
|
4
|
+
data.tar.gz: 736e0c49c1c24d7fa76876b92a9cd1eef5ea0fa2dbe8137b8f5b8f6e5424df8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8e63854abd113d5670356a17d82ac7264c5f7b3e41d1db43252091200c05d574a2e4c48e29e487d4a5a8eb8f85e27968d1f65e037f83bc6dbf4f42944f5a667
|
7
|
+
data.tar.gz: 504269980fdcfa37612957e6d6d514a8adf8c7471ba3b6f3407b54ff54d4cd05ec4226875fecae5e341df5d7372836e9484b50c898ec5a73412eac02d02b9133
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -9,6 +9,7 @@ need a Nexmo account. Sign up [for free at nexmo.com][signup].
|
|
9
9
|
* [Installation](#installation)
|
10
10
|
* [Usage](#usage)
|
11
11
|
* [SMS API](#sms-api)
|
12
|
+
* [2FA API](#2fa-api)
|
12
13
|
* [Voice API](#voice-api)
|
13
14
|
* [Verify API](#verify-api)
|
14
15
|
* [Number Insight API](#number-insight-api)
|
@@ -102,6 +103,23 @@ end
|
|
102
103
|
Docs: [https://developer.nexmo.com/api/sms#send-an-sms](https://developer.nexmo.com/api/sms?utm_source=DEV_REL&utm_medium=github&utm_campaign=ruby-client-library#send-an-sms)
|
103
104
|
|
104
105
|
|
106
|
+
## 2FA API
|
107
|
+
|
108
|
+
### Send a 2FA Token
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
response = client.tfa.send(to: 'YOUR NUMBER', pin: '12345')
|
112
|
+
|
113
|
+
if response.messages.first.status == '0'
|
114
|
+
puts "Sent message id=#{response.messages.first.message_id}"
|
115
|
+
else
|
116
|
+
puts "Error: #{response.messages.first.error_text}"
|
117
|
+
end
|
118
|
+
```
|
119
|
+
|
120
|
+
Docs: [https://developer.nexmo.com/api/sms/us-short-codes/2fa](https://developer.nexmo.com/api/sms/us-short-codes/2fa?utm_source=DEV_REL&utm_medium=github&utm_campaign=ruby-client-library)
|
121
|
+
|
122
|
+
|
105
123
|
## Voice API
|
106
124
|
|
107
125
|
### Create an outbound call
|
data/lib/nexmo.rb
CHANGED
@@ -6,8 +6,8 @@ require 'nexmo/json'
|
|
6
6
|
require 'nexmo/jwt'
|
7
7
|
require 'nexmo/signature'
|
8
8
|
require 'nexmo/user_agent'
|
9
|
-
require 'nexmo/entity'
|
10
9
|
require 'nexmo/keys'
|
10
|
+
require 'nexmo/entity'
|
11
11
|
require 'nexmo/problem'
|
12
12
|
require 'nexmo/errors/error'
|
13
13
|
require 'nexmo/errors/client_error'
|
@@ -38,4 +38,5 @@ require 'nexmo/pricing'
|
|
38
38
|
require 'nexmo/redact'
|
39
39
|
require 'nexmo/secrets'
|
40
40
|
require 'nexmo/sms'
|
41
|
+
require 'nexmo/tfa'
|
41
42
|
require 'nexmo/verify'
|
data/lib/nexmo/client.rb
CHANGED
data/lib/nexmo/entity.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Nexmo
|
2
2
|
class Entity
|
3
|
+
include Keys
|
4
|
+
|
3
5
|
def initialize(**kwargs)
|
4
6
|
@attributes = kwargs
|
5
7
|
end
|
6
8
|
|
7
9
|
def []=(key, value)
|
8
|
-
|
9
|
-
|
10
|
-
@attributes[name] = value
|
10
|
+
@attributes[attribute_key(key)] = value
|
11
11
|
end
|
12
12
|
|
13
13
|
def respond_to_missing?(name, include_private = false)
|
@@ -31,23 +31,5 @@ module Nexmo
|
|
31
31
|
attr_reader :attributes
|
32
32
|
|
33
33
|
protected :attributes
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def self.attribute_names
|
38
|
-
@attribute_names ||= Hash.new do |hash, key|
|
39
|
-
hash[key] = attribute_name(key)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.attribute_name(key)
|
44
|
-
return key if key.is_a?(Symbol)
|
45
|
-
|
46
|
-
key.split(PATTERN).join(UNDERSCORE).downcase.to_sym
|
47
|
-
end
|
48
|
-
|
49
|
-
PATTERN = /[\-_]|(?<=\w)(?=[A-Z])/
|
50
|
-
|
51
|
-
UNDERSCORE = '_'
|
52
34
|
end
|
53
35
|
end
|
data/lib/nexmo/keys.rb
CHANGED
@@ -27,5 +27,19 @@ module Nexmo
|
|
27
27
|
def camelcase_key(k)
|
28
28
|
k.to_s.gsub(/_(\w)/) { $1.upcase }
|
29
29
|
end
|
30
|
+
|
31
|
+
ATTRIBUTE_KEYS = Hash.new { |h, k| h[k] = k.split(PATTERN).join('_').downcase.to_sym }
|
32
|
+
|
33
|
+
PATTERN = /[\-_]|(?<=\w)(?=[A-Z])/
|
34
|
+
|
35
|
+
private_constant :ATTRIBUTE_KEYS
|
36
|
+
|
37
|
+
private_constant :PATTERN
|
38
|
+
|
39
|
+
def attribute_key(k)
|
40
|
+
return k if k.is_a?(Symbol)
|
41
|
+
|
42
|
+
ATTRIBUTE_KEYS[k]
|
43
|
+
end
|
30
44
|
end
|
31
45
|
end
|
data/lib/nexmo/params.rb
CHANGED
data/lib/nexmo/signature.rb
CHANGED
@@ -19,8 +19,6 @@ module Nexmo
|
|
19
19
|
self.class.check(params, @client.signature_secret)
|
20
20
|
end
|
21
21
|
|
22
|
-
private
|
23
|
-
|
24
22
|
def self.digest(params, secret)
|
25
23
|
md5 = Digest::MD5.new
|
26
24
|
|
@@ -32,5 +30,7 @@ module Nexmo
|
|
32
30
|
|
33
31
|
md5.hexdigest
|
34
32
|
end
|
33
|
+
|
34
|
+
private_class_method :digest
|
35
35
|
end
|
36
36
|
end
|
data/lib/nexmo/tfa.rb
ADDED
data/lib/nexmo/version.rb
CHANGED
data/nexmo.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.add_development_dependency('rake', '~> 12.0')
|
17
17
|
s.add_development_dependency('minitest', '~> 5.0')
|
18
18
|
s.add_development_dependency('webmock', '~> 3.0')
|
19
|
+
s.add_development_dependency('simplecov', '~> 0.16')
|
19
20
|
s.require_path = 'lib'
|
20
21
|
s.metadata = {
|
21
22
|
'homepage' => 'https://github.com/Nexmo/nexmo-ruby',
|
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.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nexmo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.16'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.16'
|
69
83
|
description: Nexmo Client Library for Ruby
|
70
84
|
email:
|
71
85
|
- devrel@nexmo.com
|
@@ -114,6 +128,7 @@ files:
|
|
114
128
|
- lib/nexmo/secrets.rb
|
115
129
|
- lib/nexmo/signature.rb
|
116
130
|
- lib/nexmo/sms.rb
|
131
|
+
- lib/nexmo/tfa.rb
|
117
132
|
- lib/nexmo/user_agent.rb
|
118
133
|
- lib/nexmo/verify.rb
|
119
134
|
- lib/nexmo/version.rb
|
@@ -141,8 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
156
|
- !ruby/object:Gem::Version
|
142
157
|
version: '0'
|
143
158
|
requirements: []
|
144
|
-
|
145
|
-
rubygems_version: 2.7.6
|
159
|
+
rubygems_version: 3.0.1
|
146
160
|
signing_key:
|
147
161
|
specification_version: 4
|
148
162
|
summary: This is the Ruby client library for Nexmo's API. To use it you'll need a
|