nexmo 5.1.1 → 5.2.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
  SHA1:
3
- metadata.gz: b9bdcde474d49648996ce5b59a24d2d1981029fa
4
- data.tar.gz: fe2b945057edcd94f9c5a5f4e80810be7b0ea83f
3
+ metadata.gz: a75b2e071168d3e90be330542e75ef9ec3169f45
4
+ data.tar.gz: ee5a64fa8f7249c8d07664fd8edec0165e722c8b
5
5
  SHA512:
6
- metadata.gz: fa5f958c908fc21cde8241b940548651eb2ad23fd0cb25fcf6f066b04c6ea66872a71456ea710842cd1ea9257dceaf91c2e7d3ddcb8ad785049c6a5ff26938ae
7
- data.tar.gz: 735283fe44d2e12c5b0052284bca8a520f7c15dc0bfcc28b245927dc4d06817bcb84edcb3701ba8597ae8ec3ee706b564ee795c49b9096701d93015456b7bd9b
6
+ metadata.gz: ddf564d5563ef4f9f29603c2932ed50bc336efdc4526fdf169ba4c2dcf4b569d5a7a27df77ce0064b6e4b5d6c45266d6eac815e770aba8f200b3794cc21b4753
7
+ data.tar.gz: 72cbc7f778f491e88fd1991afb66932fb40efd4eddb1215ddcfcf3fe48c677a9dba5871bb89ce0681c52e6340308c822cca5cad3bb219dd22edf33017c90dc17
data/README.md CHANGED
@@ -14,6 +14,7 @@ need a Nexmo account. Sign up [for free at nexmo.com][signup].
14
14
  * [Number Insight API](#number-insight-api)
15
15
  * [Application API](#application-api)
16
16
  * [Numbers API](#numbers-api)
17
+ * [Redact API](#redact-api)
17
18
  * [Logging](#logging)
18
19
  * [JWT authentication](#jwt-authentication)
19
20
  * [Webhook signatures](#webhook-signatures)
@@ -357,6 +358,17 @@ client.numbers.update(country: 'GB', msisdn: '447700900000', voice_callback_type
357
358
  Docs: [https://developer.nexmo.com/api/developer/numbers#update-a-number](https://developer.nexmo.com/api/developer/numbers?utm_source=DEV_REL&utm_medium=github&utm_campaign=ruby-client-library#update-a-number)
358
359
 
359
360
 
361
+ ## Redact API
362
+
363
+ ### Redact a specific message
364
+
365
+ ```ruby
366
+ client.redact.transaction(id: '00A0B0C0', product: 'sms')
367
+ ```
368
+
369
+ Docs: [https://developer.nexmo.com/api/redact#transaction](https://developer.nexmo.com/api/redact?utm_source=DEV_REL&utm_medium=github&utm_campaign=ruby-client-library#transaction)
370
+
371
+
360
372
  ## Logging
361
373
 
362
374
  Use the logger option or attribute writer method to specify a logger. For example:
data/lib/nexmo.rb CHANGED
@@ -9,6 +9,10 @@ require 'nexmo/errors/error'
9
9
  require 'nexmo/errors/client_error'
10
10
  require 'nexmo/errors/server_error'
11
11
  require 'nexmo/errors/authentication_error'
12
+ require 'nexmo/authentication/abstract'
13
+ require 'nexmo/authentication/bearer_token'
14
+ require 'nexmo/authentication/key_secret_params'
15
+ require 'nexmo/authentication/key_secret_query'
12
16
  require 'nexmo/key_value_logger'
13
17
  require 'nexmo/namespace'
14
18
  require 'nexmo/client'
@@ -26,5 +30,6 @@ require 'nexmo/number_insight'
26
30
  require 'nexmo/numbers'
27
31
  require 'nexmo/pricing_types'
28
32
  require 'nexmo/pricing'
33
+ require 'nexmo/redact'
29
34
  require 'nexmo/sms'
30
35
  require 'nexmo/verify'
@@ -0,0 +1,7 @@
1
+ module Nexmo
2
+ class AbstractAuthentication
3
+ def initialize(client)
4
+ @client = client
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nexmo
4
+ class BearerToken < AbstractAuthentication
5
+ def update(object)
6
+ return unless object.is_a?(Net::HTTPRequest)
7
+
8
+ object['Authorization'] = @client.authorization
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ module Nexmo
2
+ class KeySecretParams < AbstractAuthentication
3
+ def update(object)
4
+ return unless object.is_a?(Hash)
5
+
6
+ object[:api_key] = @client.api_key
7
+ object[:api_secret] = @client.api_secret
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ module Nexmo
2
+ class KeySecretQuery < AbstractAuthentication
3
+ def update(object)
4
+ return unless object.is_a?(URI)
5
+
6
+ object.query = Params.join(object.query, params)
7
+ end
8
+
9
+ private
10
+
11
+ def params
12
+ {
13
+ api_key: @client.api_key,
14
+ api_secret: @client.api_secret
15
+ }
16
+ end
17
+ end
18
+ end
@@ -8,8 +8,8 @@ module Nexmo
8
8
 
9
9
  private
10
10
 
11
- def authorization_header?
12
- true
11
+ def authentication
12
+ @authentication ||= BearerToken.new(@client)
13
13
  end
14
14
 
15
15
  def json_body?
@@ -12,8 +12,8 @@ module Nexmo
12
12
 
13
13
  private
14
14
 
15
- def authorization_header?
16
- true
15
+ def authentication
16
+ @authentication ||= BearerToken.new(@client)
17
17
  end
18
18
 
19
19
  def json_body?
@@ -12,8 +12,8 @@ module Nexmo
12
12
 
13
13
  private
14
14
 
15
- def authorization_header?
16
- true
15
+ def authentication
16
+ @authentication ||= BearerToken.new(@client)
17
17
  end
18
18
 
19
19
  def json_body?
data/lib/nexmo/calls.rb CHANGED
@@ -61,8 +61,8 @@ module Nexmo
61
61
 
62
62
  private
63
63
 
64
- def authorization_header?
65
- true
64
+ def authentication
65
+ @authentication ||= BearerToken.new(@client)
66
66
  end
67
67
 
68
68
  def json_body?
data/lib/nexmo/client.rb CHANGED
@@ -139,6 +139,10 @@ module Nexmo
139
139
  @pricing ||= PricingTypes.new(self)
140
140
  end
141
141
 
142
+ def redact
143
+ @redact ||= Redact.new(self)
144
+ end
145
+
142
146
  def sms
143
147
  @sms ||= SMS.new(self)
144
148
  end
data/lib/nexmo/files.rb CHANGED
@@ -18,8 +18,8 @@ module Nexmo
18
18
 
19
19
  private
20
20
 
21
- def authorization_header?
22
- true
21
+ def authentication
22
+ @authentication ||= BearerToken.new(@client)
23
23
  end
24
24
  end
25
25
  end
@@ -21,8 +21,8 @@ module Nexmo
21
21
  'api.nexmo.com'
22
22
  end
23
23
 
24
- def authorization_header?
25
- false
24
+ def authentication
25
+ @authentication ||= KeySecretParams.new(@client)
26
26
  end
27
27
 
28
28
  def json_body?
@@ -36,20 +36,22 @@ module Nexmo
36
36
  def request(path, params: nil, type: Get, &block)
37
37
  uri = URI('https://' + host + path)
38
38
 
39
- unless authorization_header?
40
- params ||= {}
41
- params[:api_key] = @client.api_key
42
- params[:api_secret] = @client.api_secret
43
- end
39
+ params ||= {}
40
+
41
+ authentication.update(params)
44
42
 
45
- unless type::REQUEST_HAS_BODY || params.nil? || params.empty?
43
+ unless type::REQUEST_HAS_BODY || params.empty?
46
44
  uri.query = Params.encode(params)
47
45
  end
48
46
 
47
+ authentication.update(uri)
48
+
49
49
  message = type.new(uri.request_uri)
50
- message['Authorization'] = @client.authorization if authorization_header?
50
+
51
51
  message['User-Agent'] = @client.user_agent
52
52
 
53
+ authentication.update(message)
54
+
53
55
  encode_body(params, message) if type::REQUEST_HAS_BODY
54
56
 
55
57
  logger.info('Nexmo API request', method: message.method, path: uri.path)
data/lib/nexmo/params.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cgi'
2
3
 
3
4
  module Nexmo
@@ -6,6 +7,14 @@ module Nexmo
6
7
  params.flat_map { |k, vs| Array(vs).map { |v| "#{escape(k)}=#{escape(v)}" } }.join('&')
7
8
  end
8
9
 
10
+ def self.join(string, params)
11
+ encoded = encode(params)
12
+
13
+ return encoded if string.nil?
14
+
15
+ string + '&' + encoded
16
+ end
17
+
9
18
  private
10
19
 
11
20
  def self.escape(component)
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nexmo
4
+ class Redact < Namespace
5
+ def transaction(params)
6
+ request('/v1/redact/transaction', params: params, type: Post)
7
+ end
8
+
9
+ private
10
+
11
+ def authentication
12
+ @authentication ||= KeySecretQuery.new(@client)
13
+ end
14
+
15
+ def json_body?
16
+ true
17
+ end
18
+ end
19
+ end
data/lib/nexmo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nexmo
2
- VERSION = '5.1.1'
2
+ VERSION = '5.2.0'
3
3
  end
data/nexmo.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.files = Dir.glob('{lib,spec}/**/*') + %w(LICENSE.txt README.md nexmo.gemspec)
14
14
  s.required_ruby_version = '>= 2.0.0'
15
15
  s.add_dependency('jwt')
16
- s.add_development_dependency('rake')
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
19
  s.require_path = 'lib'
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.1.1
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Craft
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-17 00:00:00.000000000 Z
11
+ date: 2018-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '12.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '12.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -79,6 +79,10 @@ files:
79
79
  - lib/nexmo/account.rb
80
80
  - lib/nexmo/alerts.rb
81
81
  - lib/nexmo/applications.rb
82
+ - lib/nexmo/authentication/abstract.rb
83
+ - lib/nexmo/authentication/bearer_token.rb
84
+ - lib/nexmo/authentication/key_secret_params.rb
85
+ - lib/nexmo/authentication/key_secret_query.rb
82
86
  - lib/nexmo/call_dtmf.rb
83
87
  - lib/nexmo/call_stream.rb
84
88
  - lib/nexmo/call_talk.rb
@@ -101,6 +105,7 @@ files:
101
105
  - lib/nexmo/params.rb
102
106
  - lib/nexmo/pricing.rb
103
107
  - lib/nexmo/pricing_types.rb
108
+ - lib/nexmo/redact.rb
104
109
  - lib/nexmo/signature.rb
105
110
  - lib/nexmo/sms.rb
106
111
  - lib/nexmo/user_agent.rb