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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7339e40c57dc348e205411f04ffdb1d5f96bd0bb41fd481a4781c6a91b9c06c0
4
- data.tar.gz: cb033f687f94529c18faf2b9bee41f7e9383fdc7954e9cf38f3cf15642d1bbeb
3
+ metadata.gz: dcef65e09c820aa2be62979694389d22332b6950ac9032e83aeacc1b9a3b09ec
4
+ data.tar.gz: 736e0c49c1c24d7fa76876b92a9cd1eef5ea0fa2dbe8137b8f5b8f6e5424df8a
5
5
  SHA512:
6
- metadata.gz: bbddc5433b0356fc806c999dbfc1185b5e5d90989cb1e1742812713e0624d3b7ed07fb21e333c55d0c774e44aec42e00c7bcc3e15f1b5079b4e3b1f626441c57
7
- data.tar.gz: c56b00b6a05d095268289cb2238ee4d38f05b8da67f2d4c0d839f4ae89f09462fd44138b9e880187e75b01dbd356ed74dfad5038aefcf7588f93776a1ff408b5
6
+ metadata.gz: b8e63854abd113d5670356a17d82ac7264c5f7b3e41d1db43252091200c05d574a2e4c48e29e487d4a5a8eb8f85e27968d1f65e037f83bc6dbf4f42944f5a667
7
+ data.tar.gz: 504269980fdcfa37612957e6d6d514a8adf8c7471ba3b6f3407b54ff54d4cd05ec4226875fecae5e341df5d7372836e9484b50c898ec5a73412eac02d02b9133
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016-2018 Nexmo Inc
3
+ Copyright (c) 2016-2019 Nexmo Inc
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person
6
6
  obtaining a copy of this software and associated documentation
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
@@ -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'
@@ -165,6 +165,10 @@ module Nexmo
165
165
  @sms ||= SMS.new(self)
166
166
  end
167
167
 
168
+ def tfa
169
+ @tfa ||= TFA.new(self)
170
+ end
171
+
168
172
  def verify
169
173
  @verify ||= Verify.new(self)
170
174
  end
@@ -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
- name = self.class.attribute_names[key]
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
@@ -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
@@ -15,10 +15,10 @@ module Nexmo
15
15
  string + '&' + encoded
16
16
  end
17
17
 
18
- private
19
-
20
18
  def self.escape(component)
21
19
  CGI.escape(component.to_s)
22
20
  end
21
+
22
+ private_class_method :escape
23
23
  end
24
24
  end
@@ -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
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nexmo
4
+ class TFA < Namespace
5
+ include Keys
6
+
7
+ self.host = 'rest.nexmo.com'
8
+
9
+ def send(params)
10
+ request('/sc/us/2fa/json', params: hyphenate(params), type: Post)
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Nexmo
2
- VERSION = '5.5.0'
2
+ VERSION = '5.6.0'
3
3
  end
@@ -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.5.0
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: 2018-12-03 00:00:00.000000000 Z
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
- rubyforge_project:
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