vonage 7.2.1 → 7.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +46 -1
- data/lib/vonage/abstract_authentication.rb +1 -1
- data/lib/vonage/applications/list_response.rb +1 -1
- data/lib/vonage/applications.rb +11 -3
- data/lib/vonage/basic.rb +1 -1
- data/lib/vonage/bearer_token.rb +1 -1
- data/lib/vonage/config.rb +1 -1
- data/lib/vonage/conversations/events.rb +6 -2
- data/lib/vonage/conversations/legs.rb +6 -2
- data/lib/vonage/conversations/members.rb +6 -2
- data/lib/vonage/conversations/users.rb +6 -2
- data/lib/vonage/conversations.rb +10 -3
- data/lib/vonage/entity.rb +0 -2
- data/lib/vonage/form_data.rb +1 -1
- data/lib/vonage/gsm7.rb +4 -1
- data/lib/vonage/json.rb +1 -1
- data/lib/vonage/jwt.rb +1 -1
- data/lib/vonage/namespace.rb +121 -16
- data/lib/vonage/numbers/list_response.rb +1 -1
- data/lib/vonage/numbers/response.rb +2 -2
- data/lib/vonage/numbers.rb +9 -1
- data/lib/vonage/params.rb +1 -1
- data/lib/vonage/response.rb +1 -0
- data/lib/vonage/secrets/list_response.rb +1 -1
- data/lib/vonage/secrets.rb +6 -2
- data/lib/vonage/user_agent.rb +4 -1
- data/lib/vonage/verify.rb +1 -1
- data/lib/vonage/version.rb +1 -1
- data/lib/vonage/voice/actions/connect.rb +199 -0
- data/lib/vonage/voice/actions/conversation.rb +107 -0
- data/lib/vonage/voice/actions/input.rb +119 -0
- data/lib/vonage/voice/actions/notify.rb +57 -0
- data/lib/vonage/voice/actions/record.rb +130 -0
- data/lib/vonage/voice/actions/stream.rb +72 -0
- data/lib/vonage/voice/actions/talk.rb +73 -0
- data/lib/vonage/voice/list_response.rb +1 -1
- data/lib/vonage/voice/ncco.rb +42 -0
- data/lib/vonage/voice.rb +9 -1
- data/vonage.gemspec +2 -0
- metadata +39 -3
@@ -0,0 +1,73 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
module Vonage
|
4
|
+
class Voice::Actions::Talk
|
5
|
+
attr_accessor :text, :bargeIn, :loop, :level, :language, :style
|
6
|
+
|
7
|
+
def initialize(attributes= {})
|
8
|
+
@text = attributes.fetch(:text)
|
9
|
+
@bargeIn = attributes.fetch(:bargeIn, nil)
|
10
|
+
@loop = attributes.fetch(:loop, nil)
|
11
|
+
@level = attributes.fetch(:level, nil)
|
12
|
+
@language = attributes.fetch(:language, nil)
|
13
|
+
@style = attributes.fetch(:style, nil)
|
14
|
+
|
15
|
+
after_initialize!
|
16
|
+
end
|
17
|
+
|
18
|
+
def after_initialize!
|
19
|
+
if self.bargeIn
|
20
|
+
verify_barge_in
|
21
|
+
end
|
22
|
+
|
23
|
+
if self.loop
|
24
|
+
verify_loop
|
25
|
+
end
|
26
|
+
|
27
|
+
if self.level
|
28
|
+
verify_level
|
29
|
+
end
|
30
|
+
|
31
|
+
if self.style
|
32
|
+
verify_style
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def verify_barge_in
|
37
|
+
raise ClientError.new("Expected 'bargeIn' value to be a Boolean") unless self.bargeIn == true || self.bargeIn == false
|
38
|
+
end
|
39
|
+
|
40
|
+
def verify_loop
|
41
|
+
raise ClientError.new("Expected 'loop' value to be either 1 or 0") unless self.loop == 1 || self.loop == 0
|
42
|
+
end
|
43
|
+
|
44
|
+
def verify_level
|
45
|
+
raise ClientError.new("Expected 'level' value to be a number between -1 and 1") unless self.level.between?(-1, 1)
|
46
|
+
end
|
47
|
+
|
48
|
+
def verify_style
|
49
|
+
raise ClientError.new("Expected 'style' value to be an Integer") unless self.style.is_a?(Integer)
|
50
|
+
end
|
51
|
+
|
52
|
+
def action
|
53
|
+
create_talk!(self)
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_talk!(builder)
|
57
|
+
ncco = [
|
58
|
+
{
|
59
|
+
action: 'talk',
|
60
|
+
text: builder.text
|
61
|
+
}
|
62
|
+
]
|
63
|
+
|
64
|
+
ncco[0].merge!(bargeIn: builder.bargeIn) if (builder.bargeIn || builder.bargeIn == false)
|
65
|
+
ncco[0].merge!(loop: builder.loop) if builder.loop
|
66
|
+
ncco[0].merge!(level: builder.level) if builder.level
|
67
|
+
ncco[0].merge!(language: builder.language) if builder.language
|
68
|
+
ncco[0].merge!(style: builder.style) if builder.style
|
69
|
+
|
70
|
+
ncco
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Vonage
|
5
|
+
class Voice::Ncco
|
6
|
+
ACTIONS = {
|
7
|
+
connect: Vonage::Voice::Actions::Connect,
|
8
|
+
conversation: Vonage::Voice::Actions::Conversation,
|
9
|
+
input: Vonage::Voice::Actions::Input,
|
10
|
+
notify: Vonage::Voice::Actions::Notify,
|
11
|
+
record: Vonage::Voice::Actions::Record,
|
12
|
+
stream: Vonage::Voice::Actions::Stream,
|
13
|
+
talk: Vonage::Voice::Actions::Talk
|
14
|
+
}
|
15
|
+
|
16
|
+
ACTIONS.keys.each do |method|
|
17
|
+
self.class.send :define_method, method do |attributes|
|
18
|
+
ACTIONS[method].new(**attributes).action
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.method_missing(method)
|
23
|
+
raise ClientError.new("NCCO action must be one of the valid options. Please refer to https://developer.nexmo.com/voice/voice-api/ncco-reference#ncco-actions for a complete list.")
|
24
|
+
end
|
25
|
+
|
26
|
+
# Create an NCCO
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# talk = Vonage::Voice::Ncco.talk(text: 'This is sample text')
|
30
|
+
# input = Vonage::Voice::Ncco.input(type: ['dtmf'])
|
31
|
+
# ncco = Vonage::Voice::Ncco.create(talk, input)
|
32
|
+
#
|
33
|
+
# @option actions [Vonage::Voice::Ncco]
|
34
|
+
#
|
35
|
+
# @return [Array]
|
36
|
+
#
|
37
|
+
# @see https://developer.nexmo.com/voice/voice-api/ncco-reference
|
38
|
+
def self.create(*actions)
|
39
|
+
actions.flatten!
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/vonage/voice.rb
CHANGED
@@ -87,13 +87,21 @@ module Vonage
|
|
87
87
|
# @option params [String] :conversation_uuid
|
88
88
|
# Return all the records associated with a specific conversation.
|
89
89
|
#
|
90
|
+
# @option params [Boolean] :auto_advance
|
91
|
+
# Set this to `false` to not auto-advance through all the pages in the record
|
92
|
+
# and collect all the data. The default is `true`.
|
93
|
+
#
|
90
94
|
# @param [Hash] params
|
91
95
|
#
|
92
96
|
# @return [ListResponse]
|
93
97
|
#
|
94
98
|
# @see https://developer.nexmo.com/api/voice#getCalls
|
95
99
|
#
|
96
|
-
def list(params = nil)
|
100
|
+
def list(params = nil, auto_advance = true)
|
101
|
+
if params && !params.key?(:auto_advance)
|
102
|
+
params.merge!(auto_advance: true)
|
103
|
+
end
|
104
|
+
|
97
105
|
request('/v1/calls', params: params, response_class: ListResponse)
|
98
106
|
end
|
99
107
|
|
data/vonage.gemspec
CHANGED
@@ -15,6 +15,8 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.add_dependency('nexmo-jwt', '~> 0.1.2')
|
16
16
|
s.add_dependency('zeitwerk', '~> 2', '>= 2.2')
|
17
17
|
s.add_dependency('sorbet-runtime', '~> 0.5')
|
18
|
+
s.add_runtime_dependency('rexml')
|
19
|
+
s.add_runtime_dependency('phonelib')
|
18
20
|
s.require_path = 'lib'
|
19
21
|
s.metadata = {
|
20
22
|
'homepage' => 'https://github.com/Vonage/vonage-ruby-sdk',
|
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.
|
4
|
+
version: 7.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vonage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nexmo-jwt
|
@@ -58,6 +58,34 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0.5'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rexml
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: phonelib
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
61
89
|
description: Vonage Server SDK for Ruby
|
62
90
|
email:
|
63
91
|
- devrel@vonage.com
|
@@ -118,8 +146,16 @@ files:
|
|
118
146
|
- lib/vonage/verify.rb
|
119
147
|
- lib/vonage/version.rb
|
120
148
|
- lib/vonage/voice.rb
|
149
|
+
- lib/vonage/voice/actions/connect.rb
|
150
|
+
- lib/vonage/voice/actions/conversation.rb
|
151
|
+
- lib/vonage/voice/actions/input.rb
|
152
|
+
- lib/vonage/voice/actions/notify.rb
|
153
|
+
- lib/vonage/voice/actions/record.rb
|
154
|
+
- lib/vonage/voice/actions/stream.rb
|
155
|
+
- lib/vonage/voice/actions/talk.rb
|
121
156
|
- lib/vonage/voice/dtmf.rb
|
122
157
|
- lib/vonage/voice/list_response.rb
|
158
|
+
- lib/vonage/voice/ncco.rb
|
123
159
|
- lib/vonage/voice/stream.rb
|
124
160
|
- lib/vonage/voice/talk.rb
|
125
161
|
- vonage.gemspec
|
@@ -147,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
183
|
- !ruby/object:Gem::Version
|
148
184
|
version: '0'
|
149
185
|
requirements: []
|
150
|
-
rubygems_version: 3.
|
186
|
+
rubygems_version: 3.3.6
|
151
187
|
signing_key:
|
152
188
|
specification_version: 4
|
153
189
|
summary: This is the Ruby Server SDK for Vonage APIs. To use it you'll need a Vonage
|