vonage 7.2.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 +7 -0
- data/LICENSE.txt +190 -0
- data/README.md +191 -0
- data/lib/vonage.rb +29 -0
- data/lib/vonage/abstract_authentication.rb +9 -0
- data/lib/vonage/account.rb +61 -0
- data/lib/vonage/alerts.rb +72 -0
- data/lib/vonage/applications.rb +148 -0
- data/lib/vonage/applications/list_response.rb +11 -0
- data/lib/vonage/authentication_error.rb +6 -0
- data/lib/vonage/basic.rb +13 -0
- data/lib/vonage/bearer_token.rb +14 -0
- data/lib/vonage/client.rb +134 -0
- data/lib/vonage/client_error.rb +6 -0
- data/lib/vonage/config.rb +208 -0
- data/lib/vonage/conversations.rb +210 -0
- data/lib/vonage/conversations/events.rb +73 -0
- data/lib/vonage/conversations/legs.rb +30 -0
- data/lib/vonage/conversations/members.rb +104 -0
- data/lib/vonage/conversations/users.rb +93 -0
- data/lib/vonage/conversions.rb +19 -0
- data/lib/vonage/entity.rb +51 -0
- data/lib/vonage/error.rb +6 -0
- data/lib/vonage/errors.rb +51 -0
- data/lib/vonage/files.rb +26 -0
- data/lib/vonage/form_data.rb +11 -0
- data/lib/vonage/gsm7.rb +13 -0
- data/lib/vonage/http.rb +43 -0
- data/lib/vonage/json.rb +17 -0
- data/lib/vonage/jwt.rb +43 -0
- data/lib/vonage/key_secret_params.rb +20 -0
- data/lib/vonage/keys.rb +51 -0
- data/lib/vonage/logger.rb +60 -0
- data/lib/vonage/messages.rb +25 -0
- data/lib/vonage/namespace.rb +118 -0
- data/lib/vonage/number_insight.rb +140 -0
- data/lib/vonage/numbers.rb +196 -0
- data/lib/vonage/numbers/list_response.rb +11 -0
- data/lib/vonage/numbers/response.rb +8 -0
- data/lib/vonage/params.rb +27 -0
- data/lib/vonage/pricing.rb +30 -0
- data/lib/vonage/pricing_types.rb +18 -0
- data/lib/vonage/redact.rb +37 -0
- data/lib/vonage/response.rb +25 -0
- data/lib/vonage/secrets.rb +85 -0
- data/lib/vonage/secrets/list_response.rb +11 -0
- data/lib/vonage/server_error.rb +6 -0
- data/lib/vonage/signature.rb +53 -0
- data/lib/vonage/sms.rb +121 -0
- data/lib/vonage/tfa.rb +14 -0
- data/lib/vonage/user_agent.rb +16 -0
- data/lib/vonage/verify.rb +253 -0
- data/lib/vonage/version.rb +5 -0
- data/lib/vonage/voice.rb +250 -0
- data/lib/vonage/voice/dtmf.rb +26 -0
- data/lib/vonage/voice/list_response.rb +11 -0
- data/lib/vonage/voice/stream.rb +44 -0
- data/lib/vonage/voice/talk.rb +48 -0
- data/vonage.gemspec +26 -0
- metadata +155 -0
@@ -0,0 +1,210 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Vonage
|
5
|
+
class Conversations < Namespace
|
6
|
+
extend T::Sig
|
7
|
+
|
8
|
+
self.authentication = BearerToken
|
9
|
+
|
10
|
+
self.request_body = JSON
|
11
|
+
|
12
|
+
# Create a conversation.
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# response = client.conversations.create(name: 'Example Conversation', display_name: 'Example Display Name')
|
16
|
+
#
|
17
|
+
# @option params [String] :name
|
18
|
+
# Unique name for a conversation.
|
19
|
+
#
|
20
|
+
# @option params [String] :display_name
|
21
|
+
# The display name for the conversation.
|
22
|
+
# It does not have to be unique.
|
23
|
+
#
|
24
|
+
# @option params [String] :image_url
|
25
|
+
# A link to an image for conversations' and users' avatars.
|
26
|
+
#
|
27
|
+
# @option params [Hash] :numbers
|
28
|
+
# - **:sms** (String) phone number used for sms channel
|
29
|
+
# - **:pstn** (String) phone number used for pstn channel
|
30
|
+
#
|
31
|
+
# @option params [Hash] :properties
|
32
|
+
# - **:ttl** (Integer) After how many seconds an empty conversation is deleted
|
33
|
+
#
|
34
|
+
# @return [Response]
|
35
|
+
#
|
36
|
+
# @see https://developer.nexmo.com/api/conversation#createConversation
|
37
|
+
#
|
38
|
+
sig { params(params: T::Hash[Symbol, T.untyped]).returns(Vonage::Response) }
|
39
|
+
def create(params)
|
40
|
+
request('/beta/conversations', params: params, type: Post)
|
41
|
+
end
|
42
|
+
|
43
|
+
# List all conversations associated with your application.
|
44
|
+
#
|
45
|
+
# @example
|
46
|
+
# response = client.conversations.list
|
47
|
+
#
|
48
|
+
# @option params [String] :date_start
|
49
|
+
# Return the records that occurred after this point in time.
|
50
|
+
#
|
51
|
+
# @option params [String] :date_end
|
52
|
+
# Return the records that occurred before this point in time.
|
53
|
+
#
|
54
|
+
# @option params [Integer] :page_size
|
55
|
+
# Return this amount of records in the response.
|
56
|
+
#
|
57
|
+
# @option params [Integer] :record_index
|
58
|
+
# Return calls from this index in the response.
|
59
|
+
#
|
60
|
+
# @option params ['asc', 'desc'] :order
|
61
|
+
# Return the records in ascending or descending order.
|
62
|
+
#
|
63
|
+
# @param [Hash, nil] params
|
64
|
+
#
|
65
|
+
# @return [Response]
|
66
|
+
#
|
67
|
+
# @see https://developer.nexmo.com/api/conversation#replaceConversation
|
68
|
+
#
|
69
|
+
sig { params(params: T.nilable(T::Hash[Symbol, T.untyped])).returns(Vonage::Response) }
|
70
|
+
def list(params = nil)
|
71
|
+
request('/beta/conversations', params: params)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Retrieve a conversation.
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# response = client.conversations.get(id)
|
78
|
+
#
|
79
|
+
# @param [String] id
|
80
|
+
#
|
81
|
+
# @return [Response]
|
82
|
+
#
|
83
|
+
# @see https://developer.nexmo.com/api/conversation#retrieveConversation
|
84
|
+
#
|
85
|
+
sig { params(id: String).returns(Vonage::Response) }
|
86
|
+
def get(id)
|
87
|
+
request('/beta/conversations/' + id)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Update a conversation.
|
91
|
+
#
|
92
|
+
# @example
|
93
|
+
# response = client.conversations.update(id, display_name: 'Updated conversation')
|
94
|
+
#
|
95
|
+
# @option params [String] :name
|
96
|
+
# Unique name for a conversation
|
97
|
+
#
|
98
|
+
# @option params [String] :display_name
|
99
|
+
# The display name for the conversation.
|
100
|
+
#
|
101
|
+
# @option params [String] :image_url
|
102
|
+
# A link to an image for conversations' and users' avatars.
|
103
|
+
#
|
104
|
+
# @option params [Hash] :numbers
|
105
|
+
# - **:sms** (String) phone number used for sms channel
|
106
|
+
# - **:pstn** (String) phone number used for pstn channel
|
107
|
+
#
|
108
|
+
# @option params [Hash] :properties
|
109
|
+
# - **:ttl** (Integer) After how many seconds an empty conversation is deleted
|
110
|
+
#
|
111
|
+
# @param [String] id
|
112
|
+
# @param [Hash] params
|
113
|
+
#
|
114
|
+
# @return [Response]
|
115
|
+
#
|
116
|
+
# @see https://developer.nexmo.com/api/conversation#replaceConversation
|
117
|
+
#
|
118
|
+
sig { params(
|
119
|
+
id: String,
|
120
|
+
params: T::Hash[Symbol, T.untyped]
|
121
|
+
).returns(Vonage::Response) }
|
122
|
+
def update(id, params)
|
123
|
+
request('/beta/conversations/' + id, params: params, type: Put)
|
124
|
+
end
|
125
|
+
|
126
|
+
# Delete a conversation.
|
127
|
+
#
|
128
|
+
# @example
|
129
|
+
# response = client.conversations.delete(id)
|
130
|
+
#
|
131
|
+
# @param [String] id
|
132
|
+
#
|
133
|
+
# @return [Response]
|
134
|
+
#
|
135
|
+
# @see https://developer.nexmo.com/api/conversation#deleteConversation
|
136
|
+
#
|
137
|
+
sig { params(id: String).returns(Vonage::Response) }
|
138
|
+
def delete(id)
|
139
|
+
request('/beta/conversations/' + id, type: Delete)
|
140
|
+
end
|
141
|
+
|
142
|
+
# Record a conversation.
|
143
|
+
#
|
144
|
+
# @example
|
145
|
+
# response = client.conversations.record(id, action: 'start')
|
146
|
+
#
|
147
|
+
# @option params [String] :action
|
148
|
+
# Recording action. Must be one of `start` or `stop`.
|
149
|
+
#
|
150
|
+
# @option params [String] :event_url
|
151
|
+
# The webhook endpoint where recording progress events are sent to.
|
152
|
+
#
|
153
|
+
# @option params [String] :event_method
|
154
|
+
# The HTTP method used to send event information to **:event_url**.
|
155
|
+
#
|
156
|
+
# @option params [String] :split
|
157
|
+
# Record the sent and received audio in separate channels of a stereo recording.
|
158
|
+
#
|
159
|
+
# @option params [String] :format
|
160
|
+
# Record the conversation in a specific format.
|
161
|
+
#
|
162
|
+
# @param [String] id
|
163
|
+
# @param [Hash] params
|
164
|
+
#
|
165
|
+
# @return [Response]
|
166
|
+
#
|
167
|
+
# @see https://developer.nexmo.com/api/conversation#recordConversation
|
168
|
+
#
|
169
|
+
sig { params(
|
170
|
+
id: String,
|
171
|
+
params: T::Hash[Symbol, T.untyped]
|
172
|
+
).returns(Vonage::Response) }
|
173
|
+
def record(id, params)
|
174
|
+
request('/v1/conversations/' + id + '/record', params: params, type: Put)
|
175
|
+
end
|
176
|
+
|
177
|
+
# @return [Events]
|
178
|
+
#
|
179
|
+
sig { returns(T.nilable(Vonage::Conversations::Events)) }
|
180
|
+
def events
|
181
|
+
@events = T.let(@events, T.nilable(Vonage::Conversations::Events))
|
182
|
+
@config = T.let(@config, T.nilable(Vonage::Config))
|
183
|
+
@events ||= Events.new(@config)
|
184
|
+
end
|
185
|
+
|
186
|
+
# @return [Legs]
|
187
|
+
#
|
188
|
+
sig { returns(T.nilable(Vonage::Conversations::Legs)) }
|
189
|
+
def legs
|
190
|
+
@legs = T.let(@legs, T.nilable(Vonage::Conversations::Legs))
|
191
|
+
@legs ||= Legs.new(@config)
|
192
|
+
end
|
193
|
+
|
194
|
+
# @return [Members]
|
195
|
+
#
|
196
|
+
sig { returns(T.nilable(Vonage::Conversations::Members)) }
|
197
|
+
def members
|
198
|
+
@members = T.let(@members, T.nilable(Vonage::Conversations::Members))
|
199
|
+
@members ||= Members.new(@config)
|
200
|
+
end
|
201
|
+
|
202
|
+
# @return [Users]
|
203
|
+
#
|
204
|
+
sig { returns(T.nilable(Vonage::Conversations::Users)) }
|
205
|
+
def users
|
206
|
+
@users = T.let(@users, T.nilable(Vonage::Conversations::Users))
|
207
|
+
@users ||= Users.new(@config)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Vonage
|
5
|
+
class Conversations::Events < Namespace
|
6
|
+
self.authentication = BearerToken
|
7
|
+
|
8
|
+
self.request_body = JSON
|
9
|
+
|
10
|
+
# Create an event.
|
11
|
+
#
|
12
|
+
# @option params [required, String] :type
|
13
|
+
# Event type.
|
14
|
+
#
|
15
|
+
# @option params [String] :to
|
16
|
+
# Member ID.
|
17
|
+
#
|
18
|
+
# @option params [required, String] :from
|
19
|
+
# Member ID.
|
20
|
+
#
|
21
|
+
# @option params [Hash] :body
|
22
|
+
# Event Body.
|
23
|
+
#
|
24
|
+
# @param [String] conversation_id
|
25
|
+
# @param [Hash] params
|
26
|
+
#
|
27
|
+
# @return [Response]
|
28
|
+
#
|
29
|
+
# @see https://developer.nexmo.com/api/conversation#createEvent
|
30
|
+
#
|
31
|
+
def create(conversation_id, params)
|
32
|
+
request('/beta/conversations/' + conversation_id + '/events', params: params, type: Post)
|
33
|
+
end
|
34
|
+
|
35
|
+
# List events.
|
36
|
+
#
|
37
|
+
# @param [String] conversation_id
|
38
|
+
#
|
39
|
+
# @return [Response]
|
40
|
+
#
|
41
|
+
# @see https://developer.nexmo.com/api/conversation#getEvents
|
42
|
+
#
|
43
|
+
def list(conversation_id)
|
44
|
+
request('/beta/conversations/' + conversation_id + '/events')
|
45
|
+
end
|
46
|
+
|
47
|
+
# Retrieve an event.
|
48
|
+
#
|
49
|
+
# @param [String] conversation_id
|
50
|
+
# @param [String] event_id
|
51
|
+
#
|
52
|
+
# @return [Response]
|
53
|
+
#
|
54
|
+
# @see https://developer.nexmo.com/api/conversation#getEvent
|
55
|
+
#
|
56
|
+
def get(conversation_id, event_id)
|
57
|
+
request('/beta/conversations/' + conversation_id + '/events/' + event_id.to_s)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Delete an event.
|
61
|
+
#
|
62
|
+
# @param [String] conversation_id
|
63
|
+
# @param [String] event_id
|
64
|
+
#
|
65
|
+
# @return [Response]
|
66
|
+
#
|
67
|
+
# @see https://developer.nexmo.com/api/conversation#deleteEvent
|
68
|
+
#
|
69
|
+
def delete(conversation_id, event_id)
|
70
|
+
request('/beta/conversations/' + conversation_id + '/events/' + event_id.to_s, type: Delete)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Vonage
|
5
|
+
class Conversations::Legs < Namespace
|
6
|
+
self.authentication = BearerToken
|
7
|
+
|
8
|
+
# List legs.
|
9
|
+
#
|
10
|
+
# @return [Response]
|
11
|
+
#
|
12
|
+
# @see https://developer.nexmo.com/api/conversation#listLegs
|
13
|
+
#
|
14
|
+
def list
|
15
|
+
request('/beta/legs')
|
16
|
+
end
|
17
|
+
|
18
|
+
# Delete a leg.
|
19
|
+
#
|
20
|
+
# @param [String] leg_id
|
21
|
+
#
|
22
|
+
# @return [Response]
|
23
|
+
#
|
24
|
+
# @see https://developer.nexmo.com/api/conversation#deleteLeg
|
25
|
+
#
|
26
|
+
def delete(leg_id)
|
27
|
+
request('/beta/legs/' + leg_id, type: Delete)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Vonage
|
5
|
+
class Conversations::Members < Namespace
|
6
|
+
self.authentication = BearerToken
|
7
|
+
|
8
|
+
self.request_body = JSON
|
9
|
+
|
10
|
+
# Create a member.
|
11
|
+
#
|
12
|
+
# @option params [String] :action
|
13
|
+
# Invite or join a member to a conversation.
|
14
|
+
# Must be one of: `invite` or `join`.
|
15
|
+
#
|
16
|
+
# @option params [required, String] :user_id
|
17
|
+
# User ID.
|
18
|
+
#
|
19
|
+
# @option params [String] :member_id
|
20
|
+
# Member ID.
|
21
|
+
#
|
22
|
+
# @option params [required, Hash] :channel
|
23
|
+
# A user who joins a conversation as a member can have one channel per membership type.
|
24
|
+
#
|
25
|
+
# @option params [Hash] :media
|
26
|
+
# Media Object.
|
27
|
+
#
|
28
|
+
# @option params [String] :knocking_id
|
29
|
+
# Knocker ID.
|
30
|
+
# A knocker is a pre-member of a conversation who does not exist yet.
|
31
|
+
#
|
32
|
+
# @option params [String] :member_id_inviting
|
33
|
+
# Member ID of the member that sends the invitation.
|
34
|
+
#
|
35
|
+
# @param [String] conversation_id
|
36
|
+
# @param [Hash] params
|
37
|
+
#
|
38
|
+
# @return [Response]
|
39
|
+
#
|
40
|
+
# @see https://developer.nexmo.com/api/conversation#createMember
|
41
|
+
#
|
42
|
+
def create(conversation_id, params)
|
43
|
+
request('/beta/conversations/' + conversation_id + '/members', params: params, type: Post)
|
44
|
+
end
|
45
|
+
|
46
|
+
# List members.
|
47
|
+
#
|
48
|
+
# @param [String] conversation_id
|
49
|
+
#
|
50
|
+
# @return [Response]
|
51
|
+
#
|
52
|
+
# @see https://developer.nexmo.com/api/conversation#getMembers
|
53
|
+
#
|
54
|
+
def list(conversation_id)
|
55
|
+
request('/beta/conversations/' + conversation_id + '/members')
|
56
|
+
end
|
57
|
+
|
58
|
+
# Retrieve a member.
|
59
|
+
#
|
60
|
+
# @param [String] conversation_id
|
61
|
+
# @param [String] member_id
|
62
|
+
#
|
63
|
+
# @return [Response]
|
64
|
+
#
|
65
|
+
# @see https://developer.nexmo.com/api/conversation#getMember
|
66
|
+
#
|
67
|
+
def get(conversation_id, member_id)
|
68
|
+
request('/beta/conversations/' + conversation_id + '/members/' + member_id)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Update a member.
|
72
|
+
#
|
73
|
+
# @option params [String] :action
|
74
|
+
# Invite or join a member to a conversation.
|
75
|
+
#
|
76
|
+
# @option params [Hash] :channel
|
77
|
+
# A user who joins a conversation as a member can have one channel per membership type.
|
78
|
+
#
|
79
|
+
# @param [String] conversation_id
|
80
|
+
# @param [String] member_id
|
81
|
+
# @param [Hash] params
|
82
|
+
#
|
83
|
+
# @return [Response]
|
84
|
+
#
|
85
|
+
# @see https://developer.nexmo.com/api/conversation#updateMember
|
86
|
+
#
|
87
|
+
def update(conversation_id, member_id, params)
|
88
|
+
request('/beta/conversations/' + conversation_id + '/members/' + member_id, params: params, type: Put)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Delete a member.
|
92
|
+
#
|
93
|
+
# @param [String] conversation_id
|
94
|
+
# @param [String] member_id
|
95
|
+
#
|
96
|
+
# @return [Response]
|
97
|
+
#
|
98
|
+
# @see https://developer.nexmo.com/api/conversation#deleteMember
|
99
|
+
#
|
100
|
+
def delete(conversation_id, member_id)
|
101
|
+
request('/beta/conversations/' + conversation_id + '/members/' + member_id, type: Delete)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Vonage
|
5
|
+
class Conversations::Users < Namespace
|
6
|
+
self.authentication = BearerToken
|
7
|
+
|
8
|
+
self.request_body = JSON
|
9
|
+
|
10
|
+
# Create a user.
|
11
|
+
#
|
12
|
+
# @option params [String] :name
|
13
|
+
# Unique name for a user.
|
14
|
+
#
|
15
|
+
# @option params [String] :display_name
|
16
|
+
# A string to be displayed as user name.
|
17
|
+
# It does not need to be unique.
|
18
|
+
#
|
19
|
+
# @option params [String] :image_url
|
20
|
+
# A link to an image for conversations' and users' avatars.
|
21
|
+
#
|
22
|
+
# @param [Hash] params
|
23
|
+
#
|
24
|
+
# @return [Response]
|
25
|
+
#
|
26
|
+
# @see https://developer.nexmo.com/api/conversation#createUser
|
27
|
+
#
|
28
|
+
def create(params)
|
29
|
+
request('/beta/users', params: params, type: Post)
|
30
|
+
end
|
31
|
+
|
32
|
+
# List users.
|
33
|
+
#
|
34
|
+
# @return [Response]
|
35
|
+
#
|
36
|
+
# @see https://developer.nexmo.com/api/conversation#getUsers
|
37
|
+
#
|
38
|
+
def list
|
39
|
+
request('/beta/users')
|
40
|
+
end
|
41
|
+
|
42
|
+
# Retrieve a user.
|
43
|
+
#
|
44
|
+
# @param [String] id
|
45
|
+
#
|
46
|
+
# @return [Response]
|
47
|
+
#
|
48
|
+
# @see https://developer.nexmo.com/api/conversation#getUser
|
49
|
+
#
|
50
|
+
def get(id)
|
51
|
+
request('/beta/users/' + id)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Update a user.
|
55
|
+
#
|
56
|
+
# @option params [String] :name
|
57
|
+
# Unique name for a user.
|
58
|
+
#
|
59
|
+
# @option params [String] :display_name
|
60
|
+
# A string to be displayed as user name.
|
61
|
+
# It does not need to be unique.
|
62
|
+
#
|
63
|
+
# @option params [String] :image_url
|
64
|
+
# A link to an image for conversations' and users' avatars.
|
65
|
+
#
|
66
|
+
# @option params [Hash] :channels
|
67
|
+
# A user who joins a conversation as a member can have one channel per membership type.
|
68
|
+
# Channels can be `app`, `phone`, `sip`, `websocket`, or `vbc`.
|
69
|
+
#
|
70
|
+
# @param [String] id
|
71
|
+
# @param [Hash] params
|
72
|
+
#
|
73
|
+
# @return [Response]
|
74
|
+
#
|
75
|
+
# @see https://developer.nexmo.com/api/conversation#updateUser
|
76
|
+
#
|
77
|
+
def update(id, params)
|
78
|
+
request('/beta/users/' + id, params: params, type: Put)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Delete a user.
|
82
|
+
#
|
83
|
+
# @param [String] id
|
84
|
+
#
|
85
|
+
# @return [Response]
|
86
|
+
#
|
87
|
+
# @see https://developer.nexmo.com/api/conversation#deleteUser
|
88
|
+
#
|
89
|
+
def delete(id)
|
90
|
+
request('/beta/users/' + id, type: Delete)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|