vonage 7.31.0 → 7.33.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eef9ba6a82f261b39300753a6a894de863fa511caeedbe4da526f19386310a5d
4
- data.tar.gz: ecdb4a66e5ce1d811c9acaf65c87c6a7acf7c25ec547ae2be6f1089600088f45
3
+ metadata.gz: a5b786bdfd6a5142be34fe1400d4e1914b6d6d9ef4b7e15d10a56e88f9bb5250
4
+ data.tar.gz: 5768855f0b0d03e66222694234f257600fa65a4eaf07dc4c0b9ce36471b87807
5
5
  SHA512:
6
- metadata.gz: 88e3b48ab6f91e84397bcf2ec1ec4d05303bdb54fb6a911a835b494bae537984779875975903a5ebd5ebfad10ac148da95c427785cd27fc6d701397df7ef9558
7
- data.tar.gz: 2fafc180379722a799ba71eaf5d3bcd08e992298e9ccc4f7503d5a07033498cad34e9fa3bbf23e955a7618f36b31b8f9a18ca16dad94aa0bc684beb1db0a2e20
6
+ metadata.gz: 3596b7759e7dc20c08ea1a127d97519aff481011134db294ac81b01452700757055813b2905d32144ae1977d8daa1d7d391ef1378763360ca3443b117caf7e05
7
+ data.tar.gz: e4a089e502ded233cbfbc0c07a60ae5dffceae4e5c550556f377202b7a4cef3b1e42806c3901b81c1c9763a7dd884ae82e9e80e0ecb016e56d0e9bbaeadf7e3d
@@ -6,6 +6,8 @@ module Vonage
6
6
  extend T::Sig
7
7
  include Keys
8
8
 
9
+ self.authentication = Basic
10
+
9
11
  self.host = :rest_host
10
12
 
11
13
  # Retrieve your account balance.
@@ -0,0 +1,22 @@
1
+ # typed: true
2
+
3
+ module Vonage
4
+ class BasicAndSignature < AbstractAuthentication
5
+ def update(object, data)
6
+ if @config.authentication_preference == :signature
7
+ return unless object.is_a?(Hash)
8
+
9
+ object['api_key'] = T.must(@config).api_key
10
+ object['timestamp'] =Time.now.to_i.to_s
11
+ signature = Signature.new(@config).generate(object)
12
+ object[:sig] = signature
13
+ else
14
+ return unless object.is_a?(Net::HTTPRequest)
15
+
16
+ object.basic_auth(@config.api_key, @config.api_secret)
17
+ end
18
+ end
19
+ end
20
+
21
+ private_constant :Basic
22
+ end
data/lib/vonage/config.rb CHANGED
@@ -109,6 +109,9 @@ module Vonage
109
109
  sig { returns(T.nilable(String)) }
110
110
  attr_accessor :app_version
111
111
 
112
+ sig { returns(T.nilable(Symbol)) }
113
+ attr_accessor :authentication_preference
114
+
112
115
  # Returns the value of attribute http.
113
116
  #
114
117
  # @return [Vonage::HTTP::Options]
@@ -6,6 +6,8 @@ module Vonage
6
6
  extend T::Sig
7
7
  include Keys
8
8
 
9
+ self.authentication = BasicAndSignature
10
+
9
11
  sig { params(params: T::Hash[Symbol, T.untyped]).returns(Vonage::Response) }
10
12
  def track_sms(params)
11
13
  request('/conversions/sms', params: hyphenate(params), type: Post)
data/lib/vonage/keys.rb CHANGED
@@ -41,7 +41,9 @@ module Vonage
41
41
  'hashed_phone_number',
42
42
  'max_age',
43
43
  'max_bitrate',
44
- 'quantization_parameter'
44
+ 'quantization_parameter',
45
+ 'has_transcription',
46
+ 'transcription_properties'
45
47
  ]
46
48
  hash.transform_keys do |k|
47
49
  if exceptions.include?(k.to_s)
@@ -10,6 +10,29 @@ module Vonage
10
10
  @config = config
11
11
  end
12
12
 
13
+ # Generate a request signature.
14
+ #
15
+ # @example
16
+ # client = Vonage::Client.new
17
+ # client.config.signature_secret = 'secret'
18
+ # client.config.signature_method = 'sha512'
19
+ # params = {
20
+ # 'api_key' => 'abc123',
21
+ # 'to' => '447900000000',
22
+ # 'from' => '447900000001',
23
+ # 'text' => 'Hello World',
24
+ # 'timestamp' => '1385047698'
25
+ # }
26
+ #
27
+ # sig = client.signature.generate(params)
28
+ #
29
+ # @param [Hash] params
30
+ #
31
+ # @see https://developer.nexmo.com/concepts/guides/signing-messages
32
+ def generate(params, signature_secret: @config.signature_secret, signature_method: @config.signature_method)
33
+ digest(params, signature_secret, signature_method)
34
+ end
35
+
13
36
  # Check webhook request signature.
14
37
  #
15
38
  # @example
@@ -38,7 +61,7 @@ module Vonage
38
61
  private
39
62
 
40
63
  def digest(params, signature_secret, signature_method)
41
- digest_string = params.sort.map { |k, v| "&#{k}=#{v.tr('&=', '_')}" }.join
64
+ digest_string = params.sort.map { |k, v| "&#{k}=#{v.to_s.tr('&=', '_')}" }.join
42
65
 
43
66
  case signature_method
44
67
  when 'md5', 'sha1', 'sha256', 'sha512'
data/lib/vonage/sms.rb CHANGED
@@ -6,6 +6,8 @@ module Vonage
6
6
  extend T::Sig
7
7
  include Keys
8
8
 
9
+ self.authentication = BasicAndSignature
10
+
9
11
  self.host = :rest_host
10
12
 
11
13
  # Send an outbound SMS from your Vonage account.
data/lib/vonage/verify.rb CHANGED
@@ -8,6 +8,8 @@ module Vonage
8
8
 
9
9
  private :http_request
10
10
 
11
+ self.authentication = Basic
12
+
11
13
  # Generate and send a PIN to your user.
12
14
  #
13
15
  # @note You can make a maximum of one Verify request per second.
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
 
3
3
  module Vonage
4
- VERSION = '7.31.0'
4
+ VERSION = '7.33.0'
5
5
  end
@@ -71,6 +71,14 @@ module Vonage
71
71
  #
72
72
  # @option layout [optional, String] :screenshareType
73
73
  #
74
+ # @param [optional, Boolean] :has_transcription
75
+ #
76
+ # @param [optional, Hash] :transcription_properties
77
+ #
78
+ # @option transcription_properties [optional, String] :primaryLanguageCode
79
+ #
80
+ # @option transcription_properties [optional, Boolean] :hasSummary
81
+ #
74
82
  # @return [Response]
75
83
  #
76
84
  # @see TODO: add docs link
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::Video::Connections::ListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity.items.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,29 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Video::Connections < Namespace
6
+
7
+ self.authentication = BearerToken
8
+
9
+ self.request_body = JSON
10
+
11
+ self.host = :video_host
12
+
13
+ # Get a list of connections for a specified session.
14
+ #
15
+ # @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
16
+ #
17
+ # @param [required, String] :session_id
18
+ #
19
+ # TODO: add auto_advance option
20
+ #
21
+ # @return [ListResponse]
22
+ #
23
+ # @see TODO: add docs link
24
+ #
25
+ def list(session_id:)
26
+ request('/v2/project/' + @config.application_id + '/session/' + session_id + '/connection', response_class: ListResponse)
27
+ end
28
+ end
29
+ end
data/lib/vonage/video.rb CHANGED
@@ -107,6 +107,12 @@ module Vonage
107
107
  @streams ||= Streams.new(@config)
108
108
  end
109
109
 
110
+ # @return [Connections]
111
+ #
112
+ def connections
113
+ @connections ||= Connections.new(@config)
114
+ end
115
+
110
116
  # @return [Captions]
111
117
  #
112
118
  def captions
@@ -65,7 +65,7 @@ module Vonage
65
65
  raise ClientError.new("'user' must be defined") unless endpoint[:user]
66
66
  when 'websocket'
67
67
  raise ClientError.new("Expected 'uri' value to be a valid URI") unless URI.parse(endpoint[:uri]).kind_of?(URI::Generic)
68
- raise ClientError.new("Expected 'content-type' parameter to be either 'audio/116;rate=16000' or 'audio/116;rate=8000") unless endpoint[:'content-type'] == 'audio/116;rate=16000' || endpoint[:'content-type'] == 'audio/116;rate=8000'
68
+ raise ClientError.new("Expected 'content-type' parameter to be either 'audio/l16;rate=16000', 'audio/l16;rate=8000', or 'audio/l16;rate=24000'") unless ['audio/l16;rate=16000', 'audio/l16;rate=8000', 'audio/l16;rate=24000'].include?(endpoint[:'content-type'])
69
69
  when 'sip'
70
70
  raise ClientError.new("Expected 'uri' value to be a valid URI") unless URI.parse(endpoint[:uri]).kind_of?(URI::Generic) if endpoint[:uri]
71
71
  raise ClientError.new("`uri` must not be combined with `user` and `domain`") if endpoint[:uri] && (endpoint[:user] || endpoint[:domain])
@@ -0,0 +1,83 @@
1
+ # typed: true
2
+ # typed: true
3
+ # frozen_string_literal: true
4
+
5
+ module Vonage
6
+ class Voice::Actions::Transfer
7
+ attr_accessor :conversation_id, :can_hear, :can_speak, :mute
8
+
9
+ def initialize(attributes = {})
10
+ @conversation_id = attributes.fetch(:conversation_id)
11
+ @can_hear = attributes.fetch(:can_hear, nil)
12
+ @can_speak = attributes.fetch(:can_speak, nil)
13
+ @mute = attributes.fetch(:mute, nil)
14
+
15
+ after_initialize!
16
+ end
17
+
18
+ def after_initialize!
19
+ validate_conversation_id
20
+ validate_can_hear if self.can_hear
21
+ validate_can_speak if self.can_speak
22
+ validate_mute if self.mute != nil
23
+ end
24
+
25
+ def validate_conversation_id
26
+ conversation_id = self.conversation_id
27
+
28
+ raise ClientError.new("Expected 'conversation_id' parameter to be a string") unless conversation_id.is_a?(String)
29
+
30
+ self.conversation_id
31
+ end
32
+
33
+ def validate_can_hear
34
+ can_hear = self.can_hear
35
+ unless can_hear.is_a?(Array) && can_hear.all? { |item| item.is_a?(String) }
36
+ raise ClientError.new("Expected 'can_hear' parameter to be an array of strings")
37
+ end
38
+
39
+ self.can_hear
40
+ end
41
+
42
+ def validate_can_speak
43
+ can_speak = self.can_speak
44
+ unless can_speak.is_a?(Array) && can_speak.all? { |item| item.is_a?(String) }
45
+ raise ClientError.new("Expected 'can_speak' parameter to be an array of strings")
46
+ end
47
+
48
+ self.can_speak
49
+ end
50
+
51
+ def validate_mute
52
+ mute = self.mute
53
+ unless [true, false].include?(mute)
54
+ raise ClientError.new("Expected 'mute' parameter to be a boolean")
55
+ end
56
+
57
+ if self.mute && self.can_speak
58
+ raise ClientError.new("The 'mute' parameter is not supported if 'can_speak' is also set")
59
+ end
60
+
61
+ self.mute
62
+ end
63
+
64
+ def action
65
+ create_transfer!(self)
66
+ end
67
+
68
+ def create_transfer!(builder)
69
+ ncco = [
70
+ {
71
+ action: 'transfer',
72
+ conversation_id: builder.conversation_id,
73
+ }
74
+ ]
75
+
76
+ ncco[0].merge!(canHear: builder.can_hear) if builder.can_hear
77
+ ncco[0].merge!(canSpeak: builder.can_speak) if builder.can_speak
78
+ ncco[0].merge!(mute: builder.mute) if builder.mute != nil
79
+
80
+ ncco
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,43 @@
1
+ # typed: true
2
+ # typed: true
3
+ # frozen_string_literal: true
4
+
5
+ module Vonage
6
+ class Voice::Actions::Wait
7
+ attr_accessor :timeout
8
+
9
+ def initialize(attributes = {})
10
+ @timeout = attributes.fetch(:timeout, nil)
11
+
12
+ after_initialize!
13
+ end
14
+
15
+ def after_initialize!
16
+ validate_timeout if self.timeout
17
+ end
18
+
19
+ def validate_timeout
20
+ timeout = self.timeout
21
+
22
+ raise ClientError.new("Expected 'timeout' parameter to be a number") unless timeout.is_a?(Numeric)
23
+
24
+ self.timeout
25
+ end
26
+
27
+ def action
28
+ create_wait!(self)
29
+ end
30
+
31
+ def create_wait!(builder)
32
+ ncco = [
33
+ {
34
+ action: 'wait'
35
+ }
36
+ ]
37
+
38
+ ncco[0].merge!(timeout: builder.timeout) if builder.timeout
39
+
40
+ ncco
41
+ end
42
+ end
43
+ end
@@ -10,7 +10,9 @@ module Vonage
10
10
  notify: Vonage::Voice::Actions::Notify,
11
11
  record: Vonage::Voice::Actions::Record,
12
12
  stream: Vonage::Voice::Actions::Stream,
13
- talk: Vonage::Voice::Actions::Talk
13
+ talk: Vonage::Voice::Actions::Talk,
14
+ wait: Vonage::Voice::Actions::Wait,
15
+ transfer: Vonage::Voice::Actions::Transfer
14
16
  }
15
17
 
16
18
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vonage
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.31.0
4
+ version: 7.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vonage
@@ -137,6 +137,7 @@ files:
137
137
  - lib/vonage/applications/list_response.rb
138
138
  - lib/vonage/authentication_error.rb
139
139
  - lib/vonage/basic.rb
140
+ - lib/vonage/basic_and_signature.rb
140
141
  - lib/vonage/bearer_token.rb
141
142
  - lib/vonage/client.rb
142
143
  - lib/vonage/client_error.rb
@@ -250,6 +251,8 @@ files:
250
251
  - lib/vonage/video/broadcasts.rb
251
252
  - lib/vonage/video/broadcasts/list_response.rb
252
253
  - lib/vonage/video/captions.rb
254
+ - lib/vonage/video/connections.rb
255
+ - lib/vonage/video/connections/list_response.rb
253
256
  - lib/vonage/video/moderation.rb
254
257
  - lib/vonage/video/renders.rb
255
258
  - lib/vonage/video/renders/list_response.rb
@@ -266,6 +269,8 @@ files:
266
269
  - lib/vonage/voice/actions/record.rb
267
270
  - lib/vonage/voice/actions/stream.rb
268
271
  - lib/vonage/voice/actions/talk.rb
272
+ - lib/vonage/voice/actions/transfer.rb
273
+ - lib/vonage/voice/actions/wait.rb
269
274
  - lib/vonage/voice/dtmf.rb
270
275
  - lib/vonage/voice/list_response.rb
271
276
  - lib/vonage/voice/ncco.rb