vonage 7.29.1 → 8.0.0.beta

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.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +89 -476
  3. data/lib/vonage/applications.rb +4 -12
  4. data/lib/vonage/basic.rb +1 -1
  5. data/lib/vonage/bearer_token.rb +1 -1
  6. data/lib/vonage/client.rb +0 -65
  7. data/lib/vonage/client_error.rb +1 -1
  8. data/lib/vonage/config.rb +1 -9
  9. data/lib/vonage/conversations/events.rb +0 -12
  10. data/lib/vonage/conversations/legs.rb +0 -6
  11. data/lib/vonage/conversations/members.rb +0 -15
  12. data/lib/vonage/conversations/users.rb +0 -15
  13. data/lib/vonage/conversations.rb +0 -30
  14. data/lib/vonage/errors.rb +20 -37
  15. data/lib/vonage/gsm7.rb +1 -1
  16. data/lib/vonage/http.rb +3 -3
  17. data/lib/vonage/jwt.rb +0 -17
  18. data/lib/vonage/key_secret_params.rb +2 -3
  19. data/lib/vonage/keys.rb +1 -14
  20. data/lib/vonage/logger.rb +3 -5
  21. data/lib/vonage/messaging/channels/viber.rb +2 -9
  22. data/lib/vonage/messaging/channels/whats_app.rb +1 -3
  23. data/lib/vonage/messaging/message.rb +0 -1
  24. data/lib/vonage/messaging.rb +4 -34
  25. data/lib/vonage/namespace.rb +68 -137
  26. data/lib/vonage/numbers.rb +17 -40
  27. data/lib/vonage/server_error.rb +1 -1
  28. data/lib/vonage/signature.rb +5 -5
  29. data/lib/vonage/sms.rb +20 -20
  30. data/lib/vonage/version.rb +1 -1
  31. data/lib/vonage/video/archives.rb +58 -25
  32. data/lib/vonage/video/list_response.rb +11 -0
  33. data/lib/vonage/video/moderation.rb +22 -7
  34. data/lib/vonage/video/signals.rb +9 -4
  35. data/lib/vonage/video/streams.rb +12 -6
  36. data/lib/vonage/video.rb +13 -50
  37. data/lib/vonage/voice/actions/connect.rb +5 -34
  38. data/lib/vonage/voice/actions/conversation.rb +4 -10
  39. data/lib/vonage/voice/actions/input.rb +3 -19
  40. data/lib/vonage/voice/actions/notify.rb +3 -8
  41. data/lib/vonage/voice/actions/pay.rb +107 -0
  42. data/lib/vonage/voice/actions/record.rb +4 -52
  43. data/lib/vonage/voice/actions/stream.rb +4 -48
  44. data/lib/vonage/voice/actions/talk.rb +4 -54
  45. data/lib/vonage/voice/talk.rb +1 -11
  46. data/lib/vonage/voice.rb +0 -24
  47. data/lib/vonage.rb +0 -4
  48. data/vonage.gemspec +1 -3
  49. metadata +12 -108
  50. data/lib/vonage/api_error.rb +0 -33
  51. data/lib/vonage/conversation/event/list_response.rb +0 -11
  52. data/lib/vonage/conversation/event.rb +0 -108
  53. data/lib/vonage/conversation/list_response.rb +0 -11
  54. data/lib/vonage/conversation/member/list_response.rb +0 -11
  55. data/lib/vonage/conversation/member.rb +0 -134
  56. data/lib/vonage/conversation/user/conversations_list_response.rb +0 -11
  57. data/lib/vonage/conversation/user/sessions_list_response.rb +0 -11
  58. data/lib/vonage/conversation/user.rb +0 -67
  59. data/lib/vonage/conversation.rb +0 -164
  60. data/lib/vonage/meetings/applications.rb +0 -28
  61. data/lib/vonage/meetings/dial_in_numbers/list_response.rb +0 -11
  62. data/lib/vonage/meetings/dial_in_numbers.rb +0 -26
  63. data/lib/vonage/meetings/recordings.rb +0 -42
  64. data/lib/vonage/meetings/rooms/list_response.rb +0 -11
  65. data/lib/vonage/meetings/rooms.rb +0 -167
  66. data/lib/vonage/meetings/sessions/list_response.rb +0 -11
  67. data/lib/vonage/meetings/sessions.rb +0 -31
  68. data/lib/vonage/meetings/themes/list_response.rb +0 -11
  69. data/lib/vonage/meetings/themes.rb +0 -239
  70. data/lib/vonage/meetings.rb +0 -50
  71. data/lib/vonage/messaging/channels/rcs.rb +0 -42
  72. data/lib/vonage/network_authentication/client_authentication.rb +0 -39
  73. data/lib/vonage/network_authentication/server_authentication.rb +0 -47
  74. data/lib/vonage/network_authentication.rb +0 -22
  75. data/lib/vonage/network_number_verification.rb +0 -92
  76. data/lib/vonage/network_sim_swap.rb +0 -84
  77. data/lib/vonage/number_insight_2.rb +0 -36
  78. data/lib/vonage/proactive_connect/events/list_response.rb +0 -11
  79. data/lib/vonage/proactive_connect/events.rb +0 -71
  80. data/lib/vonage/proactive_connect/item.rb +0 -116
  81. data/lib/vonage/proactive_connect/items/file_response.rb +0 -32
  82. data/lib/vonage/proactive_connect/items/list_response.rb +0 -11
  83. data/lib/vonage/proactive_connect/items.rb +0 -116
  84. data/lib/vonage/proactive_connect/list.rb +0 -186
  85. data/lib/vonage/proactive_connect/lists/list_response.rb +0 -11
  86. data/lib/vonage/proactive_connect/lists.rb +0 -38
  87. data/lib/vonage/proactive_connect.rb +0 -43
  88. data/lib/vonage/subaccounts/balance_transfers/list_response.rb +0 -11
  89. data/lib/vonage/subaccounts/credit_transfers/list_response.rb +0 -11
  90. data/lib/vonage/subaccounts/list_response.rb +0 -15
  91. data/lib/vonage/subaccounts.rb +0 -203
  92. data/lib/vonage/users/list_response.rb +0 -11
  93. data/lib/vonage/users.rb +0 -156
  94. data/lib/vonage/verify2/channels/email.rb +0 -36
  95. data/lib/vonage/verify2/channels/silent_auth.rb +0 -45
  96. data/lib/vonage/verify2/channels/sms.rb +0 -63
  97. data/lib/vonage/verify2/channels/voice.rb +0 -32
  98. data/lib/vonage/verify2/channels/whats_app.rb +0 -39
  99. data/lib/vonage/verify2/channels/whats_app_interactive.rb +0 -32
  100. data/lib/vonage/verify2/start_verification_options.rb +0 -63
  101. data/lib/vonage/verify2/template_fragments/list_response.rb +0 -11
  102. data/lib/vonage/verify2/template_fragments.rb +0 -125
  103. data/lib/vonage/verify2/templates/list_response.rb +0 -11
  104. data/lib/vonage/verify2/templates.rb +0 -86
  105. data/lib/vonage/verify2/workflow.rb +0 -39
  106. data/lib/vonage/verify2/workflow_builder.rb +0 -25
  107. data/lib/vonage/verify2.rb +0 -112
  108. data/lib/vonage/video/archives/list_response.rb +0 -11
  109. data/lib/vonage/video/broadcasts/list_response.rb +0 -11
  110. data/lib/vonage/video/broadcasts.rb +0 -75
  111. data/lib/vonage/video/captions.rb +0 -67
  112. data/lib/vonage/video/renders/list_response.rb +0 -11
  113. data/lib/vonage/video/renders.rb +0 -107
  114. data/lib/vonage/video/sip.rb +0 -48
  115. data/lib/vonage/video/streams/list_response.rb +0 -11
  116. data/lib/vonage/video/web_socket.rb +0 -61
data/lib/vonage/video.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  module Vonage
5
5
  class Video < Namespace
6
6
  include Keys
7
-
7
+
8
8
  self.authentication = BearerToken
9
9
 
10
10
  self.host = :video_host
@@ -30,7 +30,7 @@ module Vonage
30
30
  #
31
31
  def create_session(**params)
32
32
  request_params = params.clone
33
- request_params[:archive_mode] ||= 'manual'
33
+ request_params[:archive_mode] ||= 'manual'
34
34
  media_mode = request_params.delete(:media_mode) || 'routed'
35
35
 
36
36
  if media_mode == 'relayed' && request_params[:archive_mode] == 'manual'
@@ -42,7 +42,7 @@ module Vonage
42
42
  response = request('/session/create', params: camelcase(request_params), type: Post)
43
43
 
44
44
  public_response_data = {
45
- session_id: response.entity.first.session_id,
45
+ session_id: response.entity[:session_id],
46
46
  archive_mode: request_params[:archive_mode],
47
47
  media_mode: media_mode,
48
48
  location: request_params[:location]
@@ -54,22 +54,7 @@ module Vonage
54
54
  end
55
55
 
56
56
  def generate_client_token(session_id:, scope: 'session.connect', role: 'publisher', **params)
57
- valid_roles = %w[publisher subscriber moderator publisheronly]
58
- raise ArgumentError, "Invalid role: #{role}" unless valid_roles.include?(role)
59
-
60
- claims = {
61
- application_id: @config.application_id,
62
- scope: scope,
63
- session_id: session_id,
64
- role: role,
65
- initial_layout_class_list: '',
66
- sub: 'video',
67
- acl: {
68
- paths: {'/session/**' => {}}
69
- }
70
- }
71
-
72
-
57
+ claims = {session_id: session_id, application_id: @config.application_id, scope: scope, role: role}
73
58
  claims[:data] = params[:data] if params[:data]
74
59
  claims[:initial_layout_class_list] = params[:initial_layout_class_list].join(' ') if params[:initial_layout_class_list]
75
60
  claims[:exp] = params[:expire_time].to_i if params[:expire_time]
@@ -77,52 +62,30 @@ module Vonage
77
62
  JWT.generate(claims, @config.private_key)
78
63
  end
79
64
 
80
- # @return [Archives]
65
+ # @return [Streams]
81
66
  #
82
- def archives
83
- @archives ||= Archives.new(@config)
67
+ def streams
68
+ @streams ||= Streams.new(@config)
84
69
  end
85
70
 
86
- # @return [Broadcasts]
71
+ # @return [Archives]
87
72
  #
88
- def broadcasts
89
- @broadcasts ||= Broadcasts.new(@config)
73
+ def archives
74
+ @archives ||= Archives.new(@config)
90
75
  end
91
76
 
92
- # @return [Moderation]
77
+ # @return [Archives]
93
78
  #
94
79
  def moderation
95
80
  @moderation ||= Moderation.new(@config)
96
81
  end
97
82
 
98
- # @return [Signals]
83
+ # @return [Archives]
99
84
  #
100
85
  def signals
101
86
  @signals ||= Signals.new(@config)
102
87
  end
103
88
 
104
- # @return [Streams]
105
- #
106
- def streams
107
- @streams ||= Streams.new(@config)
108
- end
109
-
110
- # @return [Captions]
111
- #
112
- def captions
113
- @captions ||= Captions.new(@config)
114
- end
115
-
116
- # @return [Renders]
117
- #
118
- def renders
119
- @renders ||= Renders.new(@config)
120
- end
121
-
122
- # @return [WebSocket]
123
- #
124
- def web_socket
125
- @web_socket ||= WebSocket.new(@config)
126
- end
89
+ # TODO: add token generator
127
90
  end
128
91
  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, :advanced_machine_detection, :eventUrl, :eventMethod, :ringbackTone
7
+ attr_accessor :endpoint, :from, :eventType, :timeout, :limit, :machineDetection, :eventUrl, :eventMethod, :ringbackTone
8
8
 
9
9
  def initialize(attributes = {})
10
10
  @endpoint = attributes.fetch(:endpoint)
@@ -13,7 +13,6 @@ 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)
17
16
  @eventUrl = attributes.fetch(:eventUrl, nil)
18
17
  @eventMethod = attributes.fetch(:eventMethod, nil)
19
18
  @ringbackTone = attributes.fetch(:ringbackTone, nil)
@@ -40,10 +39,6 @@ module Vonage
40
39
  verify_machine_detection
41
40
  end
42
41
 
43
- if self.advanced_machine_detection
44
- verify_advanced_machine_detection
45
- end
46
-
47
42
  if self.eventUrl
48
43
  verify_event_url
49
44
  end
@@ -87,33 +82,10 @@ module Vonage
87
82
  raise ClientError.new("Invalid 'machineDetection' value, must be either: 'continue' or 'hangup' if defined") unless self.machineDetection == 'continue' || self.machineDetection == 'hangup'
88
83
  end
89
84
 
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
-
109
85
  def verify_event_url
110
- unless self.eventUrl.is_a?(Array) && self.eventUrl.length == 1 && self.eventUrl[0].is_a?(String)
111
- raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
112
- end
113
-
114
- uri = URI.parse(self.eventUrl[0])
86
+ uri = URI.parse(self.eventUrl)
115
87
 
116
- raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
88
+ raise ClientError.new("Invalid 'eventUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
117
89
 
118
90
  self.eventUrl
119
91
  end
@@ -213,7 +185,6 @@ module Vonage
213
185
  }
214
186
 
215
187
  hash.merge!(headers: endpoint_attrs[:headers]) if endpoint_attrs[:headers]
216
- hash.merge!(standardHeaders: endpoint_attrs[:standardHeaders]) if endpoint_attrs[:standardHeaders]
217
188
 
218
189
  hash
219
190
  end
@@ -225,4 +196,4 @@ module Vonage
225
196
  }
226
197
  end
227
198
  end
228
- end
199
+ end
@@ -1,7 +1,7 @@
1
1
  # typed: true
2
2
  # frozen_string_literal: true
3
-
4
- module Vonage
3
+
4
+ module Vonage
5
5
  class Voice::Actions::Conversation
6
6
  attr_accessor :name, :musicOnHoldUrl, :startOnEnter, :endOnExit, :record, :canSpeak, :canHear, :mute
7
7
 
@@ -49,15 +49,9 @@ module Vonage
49
49
  end
50
50
 
51
51
  def verify_music_on_hold_url
52
- music_on_hold_url = self.musicOnHoldUrl
53
-
54
- unless music_on_hold_url.is_a?(Array) && music_on_hold_url.length == 1 && music_on_hold_url[0].is_a?(String)
55
- raise ClientError.new("Expected 'musicOnHoldUrl' parameter to be an Array containing a single string item")
56
- end
57
-
58
- uri = URI.parse(music_on_hold_url[0])
52
+ uri = URI.parse(self.musicOnHoldUrl)
59
53
 
60
- raise ClientError.new("Invalid 'musicOnHoldUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
54
+ raise ClientError.new("Invalid 'musicOnHoldUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
61
55
 
62
56
  self.musicOnHoldUrl
63
57
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Vonage
5
5
  class Voice::Actions::Input
6
- attr_accessor :type, :dtmf, :speech, :eventUrl, :eventMethod, :mode
6
+ attr_accessor :type, :dtmf, :speech, :eventUrl, :eventMethod
7
7
 
8
8
  def initialize(attributes = {})
9
9
  @type = attributes.fetch(:type)
@@ -11,7 +11,6 @@ module Vonage
11
11
  @speech = attributes.fetch(:speech, nil)
12
12
  @eventUrl = attributes.fetch(:eventUrl, nil)
13
13
  @eventMethod = attributes.fetch(:eventMethod, nil)
14
- @mode = attributes.fetch(:mode, nil)
15
14
 
16
15
  after_initialize!
17
16
  end
@@ -34,10 +33,6 @@ module Vonage
34
33
  if self.eventMethod
35
34
  validate_event_method
36
35
  end
37
-
38
- if self.mode
39
- validate_mode
40
- end
41
36
  end
42
37
 
43
38
  def validate_type
@@ -88,13 +83,9 @@ module Vonage
88
83
  end
89
84
 
90
85
  def validate_event_url
91
- unless self.eventUrl.is_a?(Array) && self.eventUrl.length == 1 && self.eventUrl[0].is_a?(String)
92
- raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
93
- end
94
-
95
- uri = URI.parse(self.eventUrl[0])
86
+ uri = URI.parse(self.eventUrl)
96
87
 
97
- raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
88
+ raise ClientError.new("Invalid 'eventUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
98
89
 
99
90
  self.eventUrl
100
91
  end
@@ -105,12 +96,6 @@ module Vonage
105
96
  raise ClientError.new("Invalid 'eventMethod' value. must be either: 'GET' or 'POST'") unless valid_methods.include?(self.eventMethod.upcase)
106
97
  end
107
98
 
108
- def validate_mode
109
- valid_modes = ['asyncronous']
110
-
111
- raise ClientError.new("Invalid 'mode' value, must be asyncronous'") unless valid_modes.include?(self.mode)
112
- end
113
-
114
99
  def action
115
100
  create_input!(self)
116
101
  end
@@ -127,7 +112,6 @@ module Vonage
127
112
  ncco[0].merge!(speech: builder.speech) if builder.speech
128
113
  ncco[0].merge!(eventUrl: builder.eventUrl) if builder.eventUrl
129
114
  ncco[0].merge!(eventMethod: builder.eventMethod) if builder.eventMethod
130
- ncco[0].merge!(mode: builder.mode) if builder.mode
131
115
 
132
116
  ncco
133
117
  end
@@ -22,15 +22,10 @@ module Vonage
22
22
  end
23
23
 
24
24
  def validate_event_url
25
- event_url = self.eventUrl
25
+ uri = URI.parse(self.eventUrl[0])
26
26
 
27
- unless event_url.is_a?(Array) && event_url.length == 1 && event_url[0].is_a?(String)
28
- raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
29
- end
30
-
31
- uri = URI.parse(event_url[0])
32
-
33
- raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
27
+ raise ClientError.new("Expected 'eventUrl' value to be an Array with a single string") unless self.eventUrl.is_a?(Array)
28
+ raise ClientError.new("Invalid 'eventUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
34
29
 
35
30
  self.eventUrl
36
31
  end
@@ -0,0 +1,107 @@
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
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Vonage
5
5
  class Voice::Actions::Record
6
- attr_accessor :format, :split, :channels, :endOnSilence, :endOnKey, :timeOut, :beepStart, :eventUrl, :eventMethod, :transcription
6
+ attr_accessor :format, :split, :channels, :endOnSilence, :endOnKey, :timeOut, :beepStart, :eventUrl, :eventMethod
7
7
 
8
8
  def initialize(attributes = {})
9
9
  @format = attributes.fetch(:format, nil)
@@ -15,7 +15,6 @@ module Vonage
15
15
  @beepStart = attributes.fetch(:beepStart, nil)
16
16
  @eventUrl = attributes.fetch(:eventUrl, nil)
17
17
  @eventMethod = attributes.fetch(:eventMethod, nil)
18
- @transcription = attributes.fetch(:transcription, nil)
19
18
 
20
19
  after_initialize!
21
20
  end
@@ -56,10 +55,6 @@ module Vonage
56
55
  if self.eventMethod
57
56
  validate_event_method
58
57
  end
59
-
60
- if self.transcription
61
- validate_transcription
62
- end
63
58
  end
64
59
 
65
60
  def validate_format
@@ -95,13 +90,9 @@ module Vonage
95
90
  end
96
91
 
97
92
  def validate_event_url
98
- unless self.eventUrl.is_a?(Array) && self.eventUrl.length == 1 && self.eventUrl[0].is_a?(String)
99
- raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
100
- end
93
+ uri = URI.parse(self.eventUrl)
101
94
 
102
- uri = URI.parse(self.eventUrl[0])
103
-
104
- raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
95
+ raise ClientError.new("Invalid 'eventUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
105
96
 
106
97
  self.eventUrl
107
98
  end
@@ -109,45 +100,7 @@ module Vonage
109
100
  def validate_event_method
110
101
  valid_methods = ['GET', 'POST']
111
102
 
112
- raise ClientError.new("Invalid 'eventMethod' value. Must be either: 'GET' or 'POST'") unless valid_methods.include?(self.eventMethod.upcase)
113
- end
114
-
115
- def validate_transcription
116
- raise ClientError.new("Expected 'transcription' parameter to be a Hash") unless self.transcription.is_a?(Hash)
117
-
118
- if self.transcription[:language]
119
- raise ClientError.new("Invalid 'language' value, must be a String") unless self.transcription[:language].is_a?(String)
120
- end
121
-
122
- if self.transcription[:eventUrl]
123
- event_url = self.transcription[:eventUrl]
124
-
125
- unless event_url.is_a?(Array) && event_url.length == 1 && event_url[0].is_a?(String)
126
- raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
127
- end
128
-
129
- uri = URI.parse(event_url[0])
130
-
131
- raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
132
- end
133
-
134
- if self.transcription[:eventMethod]
135
- event_method = self.transcription[:eventMethod]
136
- raise ClientError.new("Invalid 'eventMethod' value, must be either: 'GET' or 'POST'") unless ['GET', 'POST'].include?(event_method.upcase)
137
- end
138
-
139
- if self.transcription[:sentimentAnalysis]
140
- sentiment_analysis = self.transcription[:sentimentAnalysis]
141
- raise ClientError.new("Invalid 'sentimentAnalysis' value, must be a Boolean") unless sentiment_analysis == true || sentiment_analysis == false
142
- end
143
-
144
- # if self.dtmf[:maxDigits]
145
- # raise ClientError.new("Expected 'maxDigits' to not be more than 22") if self.dtmf[:maxDigits] > 22
146
- # end
147
-
148
- # if self.dtmf[:submitOnHash]
149
- # raise ClientError.new("Invalid 'submitOnHash' value, must be a Boolean") unless self.dtmf[:submitOnHash] == true || self.dtmf[:submitOnHash] == false
150
- # end
103
+ raise ClientError.new("Invalid 'eventMethod' value. must be either: 'GET' or 'POST'") unless valid_methods.include?(self.eventMethod.upcase)
151
104
  end
152
105
 
153
106
  def action
@@ -170,7 +123,6 @@ module Vonage
170
123
  ncco[0].merge!(beepStart: builder.beepStart) if builder.beepStart
171
124
  ncco[0].merge!(eventUrl: builder.eventUrl) if builder.eventUrl
172
125
  ncco[0].merge!(eventMethod: builder.eventMethod) if builder.eventMethod
173
- ncco[0].merge!(transcription: builder.transcription) if builder.transcription
174
126
 
175
127
  ncco
176
128
  end
@@ -3,16 +3,13 @@
3
3
 
4
4
  module Vonage
5
5
  class Voice::Actions::Stream
6
- attr_accessor :streamUrl, :level, :bargeIn, :loop, :eventOnCompletion, :eventUrl, :eventMethod
6
+ attr_accessor :streamUrl, :level, :bargeIn, :loop
7
7
 
8
8
  def initialize(attributes = {})
9
9
  @streamUrl = attributes.fetch(:streamUrl)
10
10
  @level = attributes.fetch(:level, nil)
11
11
  @bargeIn = attributes.fetch(:bargeIn, nil)
12
12
  @loop = attributes.fetch(:loop, nil)
13
- @eventOnCompletion = attributes.fetch(:eventOnCompletion, nil)
14
- @eventUrl = attributes.fetch(:eventUrl, nil)
15
- @eventMethod = attributes.fetch(:eventMethod, nil)
16
13
 
17
14
  after_initialize!
18
15
  end
@@ -31,28 +28,12 @@ module Vonage
31
28
  if self.loop
32
29
  verify_loop
33
30
  end
34
-
35
- if self.eventOnCompletion || self.eventOnCompletion == false
36
- verify_event_on_completion
37
- end
38
-
39
- if self.eventUrl
40
- verify_event_url
41
- end
42
-
43
- if self.eventMethod
44
- verify_event_method
45
- end
46
31
  end
47
32
 
48
33
  def verify_stream_url
49
- stream_url = self.streamUrl
50
-
51
- unless stream_url.is_a?(Array) && stream_url.length == 1 && stream_url[0].is_a?(String)
52
- raise ClientError.new("Expected 'streamUrl' parameter to be an Array containing a single string item")
53
- end
34
+ raise ClientError.new("Expected 'streamUrl' parameter to be an Array containing a single string item") unless self.streamUrl.is_a?(Array)
54
35
 
55
- uri = URI.parse(stream_url[0])
36
+ uri = URI.parse(self.streamUrl[0])
56
37
 
57
38
  raise ClientError.new("Invalid 'streamUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
58
39
  end
@@ -66,29 +47,7 @@ module Vonage
66
47
  end
67
48
 
68
49
  def verify_loop
69
- raise ClientError.new("Expected 'loop' value to be either 0 or a positive integer") unless self.loop >= 0
70
- end
71
-
72
- def verify_event_on_completion
73
- raise ClientError.new("Expected 'eventOnCompletion' value to be a Boolean") unless self.eventOnCompletion == true || self.eventOnCompletion == false
74
- end
75
-
76
- def verify_event_url
77
- unless self.eventUrl.is_a?(Array) && self.eventUrl.length == 1 && self.eventUrl[0].is_a?(String)
78
- raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
79
- end
80
-
81
- uri = URI.parse(self.eventUrl[0])
82
-
83
- raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
84
-
85
- self.eventUrl
86
- end
87
-
88
- def verify_event_method
89
- valid_methods = ['GET', 'POST']
90
-
91
- raise ClientError.new("Invalid 'eventMethod' value. must be either: 'GET' or 'POST'") unless valid_methods.include?(self.eventMethod.upcase)
50
+ raise ClientError.new("Expected 'loop' value to be either 1 or 0") unless self.loop == 1 || self.loop == 0
92
51
  end
93
52
 
94
53
  def action
@@ -106,9 +65,6 @@ module Vonage
106
65
  ncco[0].merge!(level: builder.level) if builder.level
107
66
  ncco[0].merge!(bargeIn: builder.bargeIn) if (builder.bargeIn || builder.bargeIn == false)
108
67
  ncco[0].merge!(loop: builder.loop) if builder.loop
109
- ncco[0].merge!(eventOnCompletion: builder.eventOnCompletion) if (builder.eventOnCompletion || builder.eventOnCompletion == false)
110
- ncco[0].merge!(eventUrl: builder.eventUrl) if builder.eventUrl
111
- ncco[0].merge!(eventMethod: builder.eventMethod) if builder.eventMethod
112
68
 
113
69
  ncco
114
70
  end