vonage 7.10.0 → 7.11.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: cc021f5f0b897743382fe24b1973b1fa1ffa57086b590577d9f794a3fbef5355
4
- data.tar.gz: 500df71d3f79eb6c8de37f5dc694d705526eab298f92cec34e90420290aa8e00
3
+ metadata.gz: 95210747eb477199b15e3e5349e2bddfe7650928e8caae6a0275dde92381b835
4
+ data.tar.gz: '00917603bc90d21275328916969cd1af6b5925e6d034aa557705027ae514f7f8'
5
5
  SHA512:
6
- metadata.gz: '049c59c41953de3695a71b722adf03e868bae4edb4f36f145a0e03b61859f512ed508ca3f1e8b1eee54200d058a55265858b9be4f8449c9ea68e60b274ed7282'
7
- data.tar.gz: 57fcf30de159323ef20feee16dec66f1eab1b7360e2b75e17a96f368f54c3015db4f83bd4d9b51c1b69739e5c762d25131e0d66bbd1cd09ec14325bfa5f8daae
6
+ metadata.gz: 523f1f2cb099dfe781a065eb538fd45fd5d06bdb1b71156f10e119c3d4890f1df1c86ce29bfa17a3fb28231d8906deec0a2a66d41b8780e1fe5a892be6bea5b8
7
+ data.tar.gz: ecbfe4149f794e02ab6835de0fee165bc708036cb8ff4e672d77437e94bda0a4a1fef836eddc4ba0583b6058a2f8cc7ee81a5c29b0f28dad84416ccd8b694e09
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
 
3
3
  module Vonage
4
- VERSION = "7.10.0"
4
+ VERSION = "7.11.0"
5
5
  end
@@ -2,9 +2,9 @@
2
2
  # frozen_string_literal: true
3
3
  require 'phonelib'
4
4
 
5
- module Vonage
5
+ module Vonage
6
6
  class Voice::Actions::Connect
7
- attr_accessor :endpoint, :from, :eventType, :timeout, :limit, :machineDetection, :eventUrl, :eventMethod, :ringbackTone
7
+ attr_accessor :endpoint, :from, :eventType, :timeout, :limit, :machineDetection, :advanced_machine_detection, :eventUrl, :eventMethod, :ringbackTone
8
8
 
9
9
  def initialize(attributes = {})
10
10
  @endpoint = attributes.fetch(:endpoint)
@@ -13,6 +13,7 @@ module Vonage
13
13
  @timeout = attributes.fetch(:timeout, nil)
14
14
  @limit = attributes.fetch(:limit, nil)
15
15
  @machineDetection = attributes.fetch(:machineDetection, nil)
16
+ @advanced_machine_detection = attributes.fetch(:advanced_machine_detection, nil)
16
17
  @eventUrl = attributes.fetch(:eventUrl, nil)
17
18
  @eventMethod = attributes.fetch(:eventMethod, nil)
18
19
  @ringbackTone = attributes.fetch(:ringbackTone, nil)
@@ -39,6 +40,10 @@ module Vonage
39
40
  verify_machine_detection
40
41
  end
41
42
 
43
+ if self.advanced_machine_detection
44
+ verify_advanced_machine_detection
45
+ end
46
+
42
47
  if self.eventUrl
43
48
  verify_event_url
44
49
  end
@@ -82,6 +87,25 @@ module Vonage
82
87
  raise ClientError.new("Invalid 'machineDetection' value, must be either: 'continue' or 'hangup' if defined") unless self.machineDetection == 'continue' || self.machineDetection == 'hangup'
83
88
  end
84
89
 
90
+ def verify_advanced_machine_detection
91
+ raise ClientError.new("Invalid 'advanced_machine_detection' value, must be a Hash") unless self.advanced_machine_detection.is_a?(Hash)
92
+ verify_advanced_machine_detection_behavior if self.advanced_machine_detection[:behavior]
93
+ verify_advanced_machine_detection_mode if self.advanced_machine_detection[:mode]
94
+ verify_advanced_machine_detection_beep_timeout if self.advanced_machine_detection[:beep_timeout]
95
+ end
96
+
97
+ def verify_advanced_machine_detection_behavior
98
+ raise ClientError.new("Invalid 'advanced_machine_detection[:behavior]' value, must be a `continue` or `hangup`") unless ['continue', 'hangup'].include?(self.advanced_machine_detection[:behavior])
99
+ end
100
+
101
+ def verify_advanced_machine_detection_mode
102
+ raise ClientError.new("Invalid 'advanced_machine_detection[:mode]' value, must be a `detect` or `detect_beep`") unless ['detect', 'detect_beep'].include?(self.advanced_machine_detection[:mode])
103
+ end
104
+
105
+ def verify_advanced_machine_detection_beep_timeout
106
+ raise ClientError.new("Invalid 'advanced_machine_detection[:beep_timeout]' value, must be between 45 and 120") unless self.advanced_machine_detection[:beep_timeout].between?(45, 120)
107
+ end
108
+
85
109
  def verify_event_url
86
110
  uri = URI.parse(self.eventUrl)
87
111
 
@@ -196,4 +220,4 @@ module Vonage
196
220
  }
197
221
  end
198
222
  end
199
- end
223
+ end
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
  module Vonage
4
4
  class Voice::Actions::Talk
5
- attr_accessor :text, :bargeIn, :loop, :level, :language, :style
5
+ attr_accessor :text, :bargeIn, :loop, :level, :language, :style, :premium
6
6
 
7
7
  def initialize(attributes= {})
8
8
  @text = attributes.fetch(:text)
@@ -11,6 +11,7 @@ module Vonage
11
11
  @level = attributes.fetch(:level, nil)
12
12
  @language = attributes.fetch(:language, nil)
13
13
  @style = attributes.fetch(:style, nil)
14
+ @premium = attributes.fetch(:premium, nil)
14
15
 
15
16
  after_initialize!
16
17
  end
@@ -31,6 +32,10 @@ module Vonage
31
32
  if self.style
32
33
  verify_style
33
34
  end
35
+
36
+ if self.premium
37
+ verify_premium
38
+ end
34
39
  end
35
40
 
36
41
  def verify_barge_in
@@ -49,6 +54,10 @@ module Vonage
49
54
  raise ClientError.new("Expected 'style' value to be an Integer") unless self.style.is_a?(Integer)
50
55
  end
51
56
 
57
+ def verify_premium
58
+ raise ClientError.new("Expected 'premium' value to be a Boolean") unless self.premium == true || self.premium == false
59
+ end
60
+
52
61
  def action
53
62
  create_talk!(self)
54
63
  end
@@ -70,4 +79,4 @@ module Vonage
70
79
  ncco
71
80
  end
72
81
  end
73
- end
82
+ end
@@ -12,8 +12,18 @@ module Vonage
12
12
  # @option params [required, String] :text
13
13
  # The text to read.
14
14
  #
15
+ # @option params [String] :language
16
+ # The language to use. See {https://developer.vonage.com/en/api/voice#startTalk-req-body} for a list of valid language codes.
17
+ #
18
+ # @option params [Integer] :style
19
+ # The vocal style, as identified by an assigned integer.
20
+ # See {https://developer.vonage.com/en/voice/voice-api/concepts/text-to-speech#supported-languages} for a list of available styles.
21
+ #
22
+ # @option params [Boolean] :premium
23
+ # Set to `true` to use the premium version of the specified style if available, otherwise the standard version will be used.
24
+ #
15
25
  # @option params [String] :voice_name
16
- # The voice & language to use.
26
+ # The voice & language to use. [DEPRECATED: use `language` and `style` instead].
17
27
  #
18
28
  # @option params [Integer] :loop
19
29
  # The number of times to repeat the text the file, 0 for infinite.
data/lib/vonage/voice.rb CHANGED
@@ -48,6 +48,17 @@ module Vonage
48
48
  # @option params [String] :machine_detection
49
49
  # Configure the behavior when Vonage detects that the call is answered by voicemail.
50
50
  #
51
+ # @option params [Hash] :advanced_machine_detection
52
+ # Configure the behavior of Vonage's advanced machine detection. Overrides machine_detection if both are set.
53
+ # Hash with three possible properties:
54
+ # - :behavior [String]: Must be one of `continue` or `hangup`. When hangup is used, the call will be terminated if a
55
+ # machine is detected. When continue is used, the call will continue even if a machine is detected.
56
+ # - :mode [String]: Must be one of `detect` or `detect_beep`. Detect if machine answered and sends a human or
57
+ # machine status in the webhook payload. When set to `detect_beep`, the system also attempts to detect
58
+ # voice mail beep and sends an additional parameter `sub_state` in the webhook with the value `beep_start`.
59
+ # - :beep_timeout [Integer]: Min: 45, Max: 120. Maximum time in seconds Vonage should wait for a machine beep
60
+ # to be detected. A machine event with `sub_state` set to `beep_timeout` will be sent if the timeout is exceeded.
61
+ #
51
62
  # @option params [Integer] :length_timer
52
63
  # Set the number of seconds that elapse before Vonage hangs up after the call state changes to in_progress.
53
64
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vonage
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.10.0
4
+ version: 7.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vonage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-31 00:00:00.000000000 Z
11
+ date: 2023-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vonage-jwt
@@ -168,7 +168,6 @@ files:
168
168
  - lib/vonage/voice/actions/conversation.rb
169
169
  - lib/vonage/voice/actions/input.rb
170
170
  - lib/vonage/voice/actions/notify.rb
171
- - lib/vonage/voice/actions/pay.rb
172
171
  - lib/vonage/voice/actions/record.rb
173
172
  - lib/vonage/voice/actions/stream.rb
174
173
  - lib/vonage/voice/actions/talk.rb
@@ -1,107 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
- module Vonage
4
- class Voice::Actions::Pay
5
- attr_accessor :amount, :currency, :eventUrl, :prompts, :voice
6
-
7
- def initialize(attributes= {})
8
- @amount = attributes.fetch(:amount)
9
- @currency = attributes.fetch(:currency, nil)
10
- @eventUrl = attributes.fetch(:eventUrl, nil)
11
- @prompts = attributes.fetch(:prompts, nil)
12
- @voice = attributes.fetch(:voice, nil)
13
-
14
- after_initialize!
15
- end
16
-
17
- def action
18
- create_pay!(self)
19
- end
20
-
21
- def create_pay!(builder)
22
- ncco = [
23
- {
24
- action: 'pay',
25
- amount: builder.amount
26
- }
27
- ]
28
-
29
- ncco[0].merge!(currency: builder.currency) if builder.currency
30
- ncco[0].merge!(eventUrl: builder.eventUrl) if builder.eventUrl
31
- ncco[0].merge!(prompts: builder.prompts) if builder.prompts
32
- ncco[0].merge!(voice: builder.voice) if builder.voice
33
-
34
- ncco
35
- end
36
-
37
- private
38
-
39
- def after_initialize!
40
- verify_amount
41
-
42
- if self.eventUrl
43
- verify_event_url
44
- end
45
-
46
- if self.prompts
47
- verify_prompts
48
- end
49
-
50
- if self.voice
51
- verify_voice
52
- end
53
- end
54
-
55
- def verify_amount
56
- verify_amount_class
57
- verify_amount_value
58
- end
59
-
60
- def verify_event_url
61
- raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item") unless self.eventUrl.is_a?(Array)
62
-
63
- uri = URI.parse(self.eventUrl[0])
64
-
65
- raise ClientError.new("Invalid 'eventUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
66
- end
67
-
68
- def verify_prompts
69
- verify_prompts_structure
70
- verify_prompts_values
71
- end
72
-
73
- def verify_voice
74
- verify_voice_structure
75
- verify_voice_style if self.voice[:style]
76
- end
77
-
78
- def verify_amount_class
79
- raise ClientError.new("Invalid 'amount' value, must be a float") unless self.amount.is_a?(Float)
80
- end
81
-
82
- def verify_amount_value
83
- raise ClientError.new("Invalid 'amount' value, must be greater than 0") unless self.amount > 0
84
- end
85
-
86
- def verify_prompts_structure
87
- raise ClientError.new("Invalid 'prompt', must be an array of at least one hash") unless self.prompts.is_a?(Array) && !self.prompts.empty? && self.prompts.all?(Hash)
88
- end
89
-
90
- def verify_prompts_values
91
- self.prompts.each do |prompt|
92
- prompt_keys = prompt.keys
93
- [:type, :text, :errors].each do |key|
94
- raise ClientError.new("Invalid 'prompt', '#{key}' is required") unless prompt_keys.include?(key)
95
- end
96
- end
97
- end
98
-
99
- def verify_voice_structure
100
- raise ClientError.new("Expected 'voice' value to be a Hash") unless self.voice.is_a?(Hash)
101
- end
102
-
103
- def verify_voice_style
104
- raise ClientError.new("Expected 'style' value to be an Integer") unless self.voice[:style].is_a?(Integer)
105
- end
106
- end
107
- end