vonage 7.8.2 → 7.36.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 +4 -4
- data/README.md +880 -87
- data/lib/vonage/account.rb +2 -0
- data/lib/vonage/api_error.rb +33 -0
- data/lib/vonage/applications.rb +12 -4
- data/lib/vonage/basic.rb +1 -1
- data/lib/vonage/basic_and_bearer_token.rb +18 -0
- data/lib/vonage/basic_and_signature.rb +22 -0
- data/lib/vonage/bearer_token.rb +1 -1
- data/lib/vonage/client.rb +79 -0
- data/lib/vonage/client_error.rb +1 -1
- data/lib/vonage/config.rb +11 -1
- data/lib/vonage/conversation/event/list_response.rb +11 -0
- data/lib/vonage/conversation/event.rb +108 -0
- data/lib/vonage/conversation/list_response.rb +11 -0
- data/lib/vonage/conversation/member/list_response.rb +11 -0
- data/lib/vonage/conversation/member.rb +134 -0
- data/lib/vonage/conversation/user/conversations_list_response.rb +11 -0
- data/lib/vonage/conversation/user/sessions_list_response.rb +11 -0
- data/lib/vonage/conversation/user.rb +67 -0
- data/lib/vonage/conversation.rb +164 -0
- data/lib/vonage/conversations/events.rb +12 -0
- data/lib/vonage/conversations/legs.rb +6 -0
- data/lib/vonage/conversations/members.rb +15 -0
- data/lib/vonage/conversations/users.rb +15 -0
- data/lib/vonage/conversations.rb +30 -0
- data/lib/vonage/conversions.rb +2 -0
- data/lib/vonage/errors.rb +37 -20
- data/lib/vonage/http.rb +3 -3
- data/lib/vonage/identity_insights/insights_builder.rb +75 -0
- data/lib/vonage/identity_insights.rb +75 -0
- data/lib/vonage/jwt.rb +17 -0
- data/lib/vonage/key_secret_params.rb +3 -2
- data/lib/vonage/keys.rb +24 -1
- data/lib/vonage/logger.rb +0 -3
- data/lib/vonage/meetings/applications.rb +28 -0
- data/lib/vonage/meetings/dial_in_numbers/list_response.rb +11 -0
- data/lib/vonage/meetings/dial_in_numbers.rb +26 -0
- data/lib/vonage/meetings/recordings.rb +42 -0
- data/lib/vonage/meetings/rooms/list_response.rb +11 -0
- data/lib/vonage/meetings/rooms.rb +167 -0
- data/lib/vonage/meetings/sessions/list_response.rb +11 -0
- data/lib/vonage/meetings/sessions.rb +31 -0
- data/lib/vonage/meetings/themes/list_response.rb +11 -0
- data/lib/vonage/meetings/themes.rb +239 -0
- data/lib/vonage/meetings.rb +50 -0
- data/lib/vonage/messaging/channels/messenger.rb +2 -0
- data/lib/vonage/messaging/channels/mms.rb +13 -3
- data/lib/vonage/messaging/channels/rcs.rb +44 -0
- data/lib/vonage/messaging/channels/sms.rb +2 -0
- data/lib/vonage/messaging/channels/viber.rb +11 -2
- data/lib/vonage/messaging/channels/whats_app.rb +5 -1
- data/lib/vonage/messaging/message.rb +4 -1
- data/lib/vonage/messaging.rb +43 -4
- data/lib/vonage/namespace.rb +152 -69
- data/lib/vonage/network_authentication/client_authentication.rb +39 -0
- data/lib/vonage/network_authentication/server_authentication.rb +47 -0
- data/lib/vonage/network_authentication.rb +22 -0
- data/lib/vonage/network_number_verification.rb +92 -0
- data/lib/vonage/network_sim_swap.rb +84 -0
- data/lib/vonage/number_insight.rb +1 -0
- data/lib/vonage/number_insight_2.rb +21 -0
- data/lib/vonage/numbers.rb +40 -17
- data/lib/vonage/proactive_connect/events/list_response.rb +11 -0
- data/lib/vonage/proactive_connect/events.rb +71 -0
- data/lib/vonage/proactive_connect/item.rb +116 -0
- data/lib/vonage/proactive_connect/items/file_response.rb +32 -0
- data/lib/vonage/proactive_connect/items/list_response.rb +11 -0
- data/lib/vonage/proactive_connect/items.rb +116 -0
- data/lib/vonage/proactive_connect/list.rb +186 -0
- data/lib/vonage/proactive_connect/lists/list_response.rb +11 -0
- data/lib/vonage/proactive_connect/lists.rb +38 -0
- data/lib/vonage/proactive_connect.rb +43 -0
- data/lib/vonage/server_error.rb +1 -1
- data/lib/vonage/signature.rb +29 -6
- data/lib/vonage/sms.rb +25 -0
- data/lib/vonage/subaccounts/balance_transfers/list_response.rb +11 -0
- data/lib/vonage/subaccounts/credit_transfers/list_response.rb +11 -0
- data/lib/vonage/subaccounts/list_response.rb +15 -0
- data/lib/vonage/subaccounts.rb +203 -0
- data/lib/vonage/users/list_response.rb +11 -0
- data/lib/vonage/users.rb +156 -0
- data/lib/vonage/verify.rb +2 -0
- data/lib/vonage/verify2/channels/email.rb +36 -0
- data/lib/vonage/verify2/channels/silent_auth.rb +46 -0
- data/lib/vonage/verify2/channels/sms.rb +63 -0
- data/lib/vonage/verify2/channels/voice.rb +32 -0
- data/lib/vonage/verify2/channels/whats_app.rb +45 -0
- data/lib/vonage/verify2/channels/whats_app_interactive.rb +32 -0
- data/lib/vonage/verify2/start_verification_options.rb +63 -0
- data/lib/vonage/verify2/template_fragments/list_response.rb +11 -0
- data/lib/vonage/verify2/template_fragments.rb +125 -0
- data/lib/vonage/verify2/templates/list_response.rb +11 -0
- data/lib/vonage/verify2/templates.rb +86 -0
- data/lib/vonage/verify2/workflow.rb +39 -0
- data/lib/vonage/verify2/workflow_builder.rb +25 -0
- data/lib/vonage/verify2.rb +112 -0
- data/lib/vonage/version.rb +1 -1
- data/lib/vonage/video/archives/list_response.rb +11 -0
- data/lib/vonage/video/archives.rb +164 -0
- data/lib/vonage/video/broadcasts/list_response.rb +11 -0
- data/lib/vonage/video/broadcasts.rb +75 -0
- data/lib/vonage/video/captions.rb +67 -0
- data/lib/vonage/video/connections/list_response.rb +11 -0
- data/lib/vonage/video/connections.rb +29 -0
- data/lib/vonage/video/moderation.rb +58 -0
- data/lib/vonage/video/renders/list_response.rb +11 -0
- data/lib/vonage/video/renders.rb +107 -0
- data/lib/vonage/video/signals.rb +50 -0
- data/lib/vonage/video/sip.rb +48 -0
- data/lib/vonage/video/streams/list_response.rb +11 -0
- data/lib/vonage/video/streams.rb +70 -0
- data/lib/vonage/video/web_socket.rb +68 -0
- data/lib/vonage/video.rb +134 -0
- data/lib/vonage/voice/actions/connect.rb +45 -9
- data/lib/vonage/voice/actions/conversation.rb +10 -4
- data/lib/vonage/voice/actions/input.rb +26 -3
- data/lib/vonage/voice/actions/notify.rb +8 -3
- data/lib/vonage/voice/actions/record.rb +52 -4
- data/lib/vonage/voice/actions/stream.rb +7 -3
- data/lib/vonage/voice/actions/talk.rb +29 -4
- data/lib/vonage/voice/actions/transfer.rb +83 -0
- data/lib/vonage/voice/actions/wait.rb +43 -0
- data/lib/vonage/voice/ncco.rb +3 -1
- data/lib/vonage/voice/talk.rb +11 -1
- data/lib/vonage/voice.rb +24 -0
- data/lib/vonage.rb +4 -0
- data/vonage.gemspec +3 -1
- metadata +119 -9
- data/lib/vonage/voice/actions/pay.rb +0 -107
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Vonage
|
|
5
|
+
class Meetings::Sessions < Namespace
|
|
6
|
+
extend T::Sig
|
|
7
|
+
|
|
8
|
+
self.authentication = BearerToken
|
|
9
|
+
|
|
10
|
+
self.request_body = JSON
|
|
11
|
+
|
|
12
|
+
self.host = :vonage_host
|
|
13
|
+
|
|
14
|
+
# Return a list of recordings for a specified session.
|
|
15
|
+
#
|
|
16
|
+
# @deprecated
|
|
17
|
+
#
|
|
18
|
+
# @param [required, String] session_id The id of the session for which the recordings list should be returned
|
|
19
|
+
#
|
|
20
|
+
# @return [ListResponse]
|
|
21
|
+
#
|
|
22
|
+
# @see https://developer.vonage.com/en/api/meetings#getSessionRecordings
|
|
23
|
+
def list_recordings(session_id:)
|
|
24
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
25
|
+
request(
|
|
26
|
+
"/v1/meetings/sessions/" + session_id + "/recordings",
|
|
27
|
+
response_class: ListResponse
|
|
28
|
+
)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Vonage
|
|
5
|
+
class Meetings::Themes < Namespace
|
|
6
|
+
extend T::Sig
|
|
7
|
+
|
|
8
|
+
self.authentication = BearerToken
|
|
9
|
+
|
|
10
|
+
self.request_body = JSON
|
|
11
|
+
|
|
12
|
+
self.host = :vonage_host
|
|
13
|
+
|
|
14
|
+
# Get a list of themes associated with the Vonage application.
|
|
15
|
+
#
|
|
16
|
+
# @deprecated
|
|
17
|
+
#
|
|
18
|
+
# @return [ListResponse]
|
|
19
|
+
#
|
|
20
|
+
# @see https://developer.vonage.com/en/api/meetings#getThemes
|
|
21
|
+
def list
|
|
22
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
23
|
+
request("/v1/meetings/themes", response_class: ListResponse)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Return information for specified theme.
|
|
27
|
+
#
|
|
28
|
+
# @deprecated
|
|
29
|
+
#
|
|
30
|
+
# @param [required, String] theme_id The id of the theme for which the info should be returned
|
|
31
|
+
#
|
|
32
|
+
# @return [Response]
|
|
33
|
+
#
|
|
34
|
+
# @see https://developer.vonage.com/en/api/meetings#getThemeById
|
|
35
|
+
def info(theme_id:)
|
|
36
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
37
|
+
request("/v1/meetings/themes/" + theme_id)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Create a new theme.
|
|
41
|
+
#
|
|
42
|
+
# @deprecated
|
|
43
|
+
#
|
|
44
|
+
# @param [required, String] :main_color
|
|
45
|
+
# The main color that will be used for the meeting room.
|
|
46
|
+
#
|
|
47
|
+
# @param [required, String] :brand_text
|
|
48
|
+
# The text that will appear on the meeting homepage, in the case that there is no brand image
|
|
49
|
+
#
|
|
50
|
+
# @param [optional, String] :theme_name
|
|
51
|
+
# The name of the theme (must be unique). If null, a UUID will automatically be generated
|
|
52
|
+
#
|
|
53
|
+
# @param [optional, String] :short_company_url
|
|
54
|
+
# The URL that will represent every meeting room with this theme. The value must be unique across Vonage
|
|
55
|
+
#
|
|
56
|
+
# @return [Response]
|
|
57
|
+
#
|
|
58
|
+
# @see https://developer.vonage.com/en/api/meetings#createTheme
|
|
59
|
+
def create(main_color:, brand_text:, **params)
|
|
60
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
61
|
+
request(
|
|
62
|
+
"/v1/meetings/themes",
|
|
63
|
+
params: params.merge(main_color: main_color, brand_text: brand_text),
|
|
64
|
+
type: Post
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Update an existing theme.
|
|
69
|
+
#
|
|
70
|
+
# @deprecated
|
|
71
|
+
#
|
|
72
|
+
# @param [required, String] theme_id The id of the theme to be updated
|
|
73
|
+
#
|
|
74
|
+
# @param [required, String] :main_color
|
|
75
|
+
# The main color that will be used for the meeting room.
|
|
76
|
+
#
|
|
77
|
+
# @param [required, String] :brand_text
|
|
78
|
+
# The text that will appear on the meeting homepage, in the case that there is no brand image
|
|
79
|
+
#
|
|
80
|
+
# @param [optional, String] :theme_name
|
|
81
|
+
# The name of the theme (must be unique). If null, a UUID will automatically be generated
|
|
82
|
+
#
|
|
83
|
+
# @param [optional, String] :short_company_url
|
|
84
|
+
# The URL that will represent every meeting room with this theme. The value must be unique across Vonage
|
|
85
|
+
#
|
|
86
|
+
# @return [Response]
|
|
87
|
+
#
|
|
88
|
+
# @see https://developer.vonage.com/en/api/meetings#updateTheme
|
|
89
|
+
def update(theme_id:, **params)
|
|
90
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
91
|
+
request(
|
|
92
|
+
"/v1/meetings/themes/" + theme_id,
|
|
93
|
+
params: {
|
|
94
|
+
update_details: params
|
|
95
|
+
},
|
|
96
|
+
type: Patch
|
|
97
|
+
)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Delete an existing theme.
|
|
101
|
+
#
|
|
102
|
+
# @deprecated
|
|
103
|
+
#
|
|
104
|
+
# @param [required, String] :theme_id The id of the theme to be deleted
|
|
105
|
+
#
|
|
106
|
+
# @param [optional, Boolean] :force. Set to `true` to force delete a theme currently being used for a room, or as
|
|
107
|
+
# a default theme. (Defaults to `false`)
|
|
108
|
+
#
|
|
109
|
+
# @return [Response]
|
|
110
|
+
#
|
|
111
|
+
# @see https://developer.vonage.com/en/api/meetings#deleteTheme
|
|
112
|
+
def delete(theme_id:, force: false)
|
|
113
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
114
|
+
request(
|
|
115
|
+
"/v1/meetings/themes/" + theme_id + "?force=#{force}",
|
|
116
|
+
type: Delete
|
|
117
|
+
)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Get a list of rooms that are associated with a theme id.
|
|
121
|
+
#
|
|
122
|
+
# @deprecated
|
|
123
|
+
#
|
|
124
|
+
# @param [required, String] theme_id THe ID of the theme to search for rooms associated with.
|
|
125
|
+
#
|
|
126
|
+
# @param [optional, Integer] :start_id
|
|
127
|
+
#
|
|
128
|
+
# @param [optional, Integer] :end_id
|
|
129
|
+
#
|
|
130
|
+
# @param [optional, Integer] :page_size
|
|
131
|
+
#
|
|
132
|
+
# @return [Response]
|
|
133
|
+
#
|
|
134
|
+
# @see https://developer.vonage.com/en/api/meetings#getRoomsByThemeId
|
|
135
|
+
def list_rooms(theme_id:, **params)
|
|
136
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
137
|
+
path = "/v1/meetings/themes/" + theme_id + "/rooms"
|
|
138
|
+
path += "?#{Params.encode(params)}" unless params.empty?
|
|
139
|
+
|
|
140
|
+
request(path, response_class: Meetings::Rooms::ListResponse)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Set a logo for a theme.
|
|
144
|
+
#
|
|
145
|
+
# @deprecated
|
|
146
|
+
#
|
|
147
|
+
# @param [required, String] :theme_id The ID of the theme for which the logo should be set
|
|
148
|
+
#
|
|
149
|
+
# @param [required, String] :filepath
|
|
150
|
+
# The filepath of the logo file. Logo files must conform to the following requirements:
|
|
151
|
+
# - Format: PNG
|
|
152
|
+
# - Maximum size: 1MB
|
|
153
|
+
# - Background must be transparent
|
|
154
|
+
# - Dimensions:
|
|
155
|
+
# - 1 px - 300 px (`white` and `colored` logos)
|
|
156
|
+
# - 16 x 16 - 32 x 32 and must be square (favicon)
|
|
157
|
+
#
|
|
158
|
+
# @param [required, String] :logo_type
|
|
159
|
+
# The type of logo to be set. Must be one of `white`, `colored`, `favicon`
|
|
160
|
+
#
|
|
161
|
+
# @return [Response]
|
|
162
|
+
#
|
|
163
|
+
# @see https://developer.vonage.com/en/meetings/guides/theme-management#uploading-icons-and-logos
|
|
164
|
+
# @see https://developer.vonage.com/en/api/meetings#getUploadUrlsForTheme
|
|
165
|
+
# @see https://developer.vonage.com/en/api/meetings#finalizeLogosForTheme
|
|
166
|
+
#
|
|
167
|
+
# TODO: add type signature
|
|
168
|
+
def set_logo(theme_id:, filepath:, logo_type:)
|
|
169
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
170
|
+
pn = Pathname.new(filepath)
|
|
171
|
+
valid_logo_types = ['white', 'colored', 'favicon']
|
|
172
|
+
raise ArgumentError, ':filepath not for a file' unless pn.file?
|
|
173
|
+
raise ArgumentError, 'file at :filepath not readable' unless pn.readable?
|
|
174
|
+
raise ArgumentError, "logo_type: must be one of #{valid_logo_types}" unless valid_logo_types.include?(logo_type)
|
|
175
|
+
|
|
176
|
+
logo_upload_credentials = get_logo_upload_credentials
|
|
177
|
+
|
|
178
|
+
filtered_logo_upload_credentials = logo_upload_credentials.select {|cred| cred.fields.logo_type == logo_type }.first
|
|
179
|
+
|
|
180
|
+
upload_logo_file(filepath: filepath, credentials: filtered_logo_upload_credentials)
|
|
181
|
+
|
|
182
|
+
finalize_logos(theme_id: theme_id, keys: [filtered_logo_upload_credentials.fields.key])
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
private
|
|
186
|
+
|
|
187
|
+
def get_logo_upload_credentials
|
|
188
|
+
request("/v1/meetings/themes/logos-upload-urls", response_class: ListResponse)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def upload_logo_file(filepath:, credentials:)
|
|
192
|
+
pn = Pathname.new(filepath)
|
|
193
|
+
|
|
194
|
+
params = format_s3_upload_credentials(credentials)
|
|
195
|
+
|
|
196
|
+
multipart_post_request(
|
|
197
|
+
nil,
|
|
198
|
+
filepath: filepath,
|
|
199
|
+
file_name: pn.basename,
|
|
200
|
+
mime_type: credentials.fields.content_type,
|
|
201
|
+
params: params,
|
|
202
|
+
override_uri: credentials.url,
|
|
203
|
+
no_auth: true
|
|
204
|
+
)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def finalize_logos(theme_id:, keys: [])
|
|
208
|
+
request(
|
|
209
|
+
"/v1/meetings/themes/" + theme_id + "/finalizeLogos",
|
|
210
|
+
params: {
|
|
211
|
+
keys: keys
|
|
212
|
+
},
|
|
213
|
+
type: Put
|
|
214
|
+
)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def format_s3_upload_credentials(credentials)
|
|
218
|
+
credentials_key_map = {
|
|
219
|
+
content_type: "Content-Type",
|
|
220
|
+
logo_type: "logoType",
|
|
221
|
+
x_amz_algorithm: "X-Amz-Algorithm",
|
|
222
|
+
x_amz_credential: "X-Amz-Credential",
|
|
223
|
+
x_amz_date: "X-Amz-Date",
|
|
224
|
+
x_amz_security_token: "X-Amz-Security-Token",
|
|
225
|
+
policy: "Policy",
|
|
226
|
+
x_amz_signature: "X-Amz-Signature"
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
params = credentials.fields.attributes
|
|
230
|
+
params.transform_keys do |k|
|
|
231
|
+
if credentials_key_map.keys.include?(k)
|
|
232
|
+
credentials_key_map[k]
|
|
233
|
+
else
|
|
234
|
+
k.to_s
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Vonage
|
|
5
|
+
class Meetings < Namespace
|
|
6
|
+
extend T::Sig
|
|
7
|
+
|
|
8
|
+
# @deprecated
|
|
9
|
+
sig { returns(T.nilable(Vonage::Meetings::Rooms)) }
|
|
10
|
+
def rooms
|
|
11
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
12
|
+
@rooms ||= Rooms.new(@config)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @deprecated
|
|
16
|
+
sig { returns(T.nilable(Vonage::Meetings::Recordings)) }
|
|
17
|
+
def recordings
|
|
18
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
19
|
+
@recordings ||= Recordings.new(@config)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @deprecated
|
|
23
|
+
sig { returns(T.nilable(Vonage::Meetings::Sessions)) }
|
|
24
|
+
def sessions
|
|
25
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
26
|
+
@sessions ||= Sessions.new(@config)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @deprecated
|
|
30
|
+
sig { returns(T.nilable(Vonage::Meetings::Themes)) }
|
|
31
|
+
def themes
|
|
32
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
33
|
+
@themes ||= Themes.new(@config)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @deprecated
|
|
37
|
+
sig { returns(T.nilable(Vonage::Meetings::Applications)) }
|
|
38
|
+
def applications
|
|
39
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
40
|
+
@applications ||= Applications.new(@config)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @deprecated
|
|
44
|
+
sig { returns(T.nilable(Vonage::Meetings::DialInNumbers)) }
|
|
45
|
+
def dial_in_numbers
|
|
46
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
47
|
+
@dial_in_numbers ||= DialInNumbers.new(@config)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -7,6 +7,8 @@ module Vonage
|
|
|
7
7
|
attr_reader :data
|
|
8
8
|
|
|
9
9
|
def initialize(attributes = {})
|
|
10
|
+
@to = attributes.fetch(:to, nil)
|
|
11
|
+
@from = attributes.fetch(:from, nil)
|
|
10
12
|
@type = attributes.fetch(:type, nil)
|
|
11
13
|
@message = attributes.fetch(:message, nil)
|
|
12
14
|
@opts = attributes.fetch(:opts, {})
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
module Vonage
|
|
4
4
|
class Messaging::Channels::MMS < Messaging::Message
|
|
5
|
-
MESSAGE_TYPES = ['image', 'vcard', 'audio', 'video']
|
|
5
|
+
MESSAGE_TYPES = ['text', 'image', 'vcard', 'audio', 'video', 'file', 'content'].freeze
|
|
6
6
|
|
|
7
7
|
attr_reader :data
|
|
8
8
|
|
|
9
9
|
def initialize(attributes = {})
|
|
10
|
+
@to = attributes.fetch(:to, nil)
|
|
11
|
+
@from = attributes.fetch(:from, nil)
|
|
10
12
|
@type = attributes.fetch(:type, nil)
|
|
11
13
|
@message = attributes.fetch(:message, nil)
|
|
12
14
|
@opts = attributes.fetch(:opts, {})
|
|
@@ -27,8 +29,16 @@ module Vonage
|
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def verify_message
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
case type
|
|
33
|
+
when 'text'
|
|
34
|
+
raise Vonage::ClientError.new("Invalid parameter type. `:message` must be a String") unless message.is_a? String
|
|
35
|
+
when 'content'
|
|
36
|
+
raise Vonage::ClientError.new("Invalid parameter type. `:message` must be an Array") unless message.is_a? Array
|
|
37
|
+
raise Vonage::ClientError.new("Invalid parameter content. `:message` must not be empty") if message.empty?
|
|
38
|
+
else
|
|
39
|
+
raise Vonage::ClientError.new("Invalid parameter type. `:message` must be a Hash") unless message.is_a? Hash
|
|
40
|
+
raise Vonage::ClientError.new("Missing parameter. `:message` must contain a `:url` key") unless message[:url]
|
|
41
|
+
end
|
|
32
42
|
end
|
|
33
43
|
end
|
|
34
44
|
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
|
|
3
|
+
module Vonage
|
|
4
|
+
class Messaging::Channels::RCS < Messaging::Message
|
|
5
|
+
MESSAGE_TYPES = ['text', 'image', 'video', 'file', 'card', 'carousel', 'custom']
|
|
6
|
+
|
|
7
|
+
attr_reader :data
|
|
8
|
+
|
|
9
|
+
def initialize(attributes = {})
|
|
10
|
+
@to = attributes.fetch(:to, nil)
|
|
11
|
+
@from = attributes.fetch(:from, nil)
|
|
12
|
+
@type = attributes.fetch(:type, nil)
|
|
13
|
+
@message = attributes.fetch(:message, nil)
|
|
14
|
+
@opts = attributes.fetch(:opts, {})
|
|
15
|
+
@data = {}
|
|
16
|
+
|
|
17
|
+
after_initialize!
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def build
|
|
23
|
+
data[:channel] = 'rcs'
|
|
24
|
+
super
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def verify_type
|
|
28
|
+
raise ClientError.new("Invalid message type") unless MESSAGE_TYPES.include?(type)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def verify_message
|
|
32
|
+
case type
|
|
33
|
+
when 'text'
|
|
34
|
+
raise Vonage::ClientError.new("Invalid parameter type. `:message` must be a String") unless message.is_a? String
|
|
35
|
+
when 'card', 'carousel', 'custom'
|
|
36
|
+
raise Vonage::ClientError.new("Invalid parameter type. `:message` must be a Hash") unless message.is_a? Hash
|
|
37
|
+
raise Vonage::ClientError.new("Invalid parameter content. `:message` must not be empty") if message.empty?
|
|
38
|
+
else
|
|
39
|
+
raise Vonage::ClientError.new("Invalid parameter type. `:message` must be a Hash") unless message.is_a? Hash
|
|
40
|
+
raise Vonage::ClientError.new("Missing parameter. `:message` must contain a `:url` key") unless message[:url]
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -5,6 +5,8 @@ module Vonage
|
|
|
5
5
|
attr_reader :data
|
|
6
6
|
|
|
7
7
|
def initialize(attributes = {})
|
|
8
|
+
@to = attributes.fetch(:to, nil)
|
|
9
|
+
@from = attributes.fetch(:from, nil)
|
|
8
10
|
@type = attributes.fetch(:type, 'text')
|
|
9
11
|
@message = attributes.fetch(:message, nil)
|
|
10
12
|
@opts = attributes.fetch(:opts, {})
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
module Vonage
|
|
4
4
|
class Messaging::Channels::Viber < Messaging::Message
|
|
5
|
-
MESSAGE_TYPES = ['text', 'image']
|
|
5
|
+
MESSAGE_TYPES = ['text', 'image', 'video', 'file']
|
|
6
6
|
|
|
7
7
|
attr_reader :data
|
|
8
8
|
|
|
9
9
|
def initialize(attributes = {})
|
|
10
|
+
@to = attributes.fetch(:to, nil)
|
|
11
|
+
@from = attributes.fetch(:from, nil)
|
|
10
12
|
@type = attributes.fetch(:type, nil)
|
|
11
13
|
@message = attributes.fetch(:message, nil)
|
|
12
14
|
@opts = attributes.fetch(:opts, {})
|
|
@@ -18,7 +20,7 @@ module Vonage
|
|
|
18
20
|
private
|
|
19
21
|
|
|
20
22
|
def build
|
|
21
|
-
data[:channel] = '
|
|
23
|
+
data[:channel] = 'viber_service'
|
|
22
24
|
super
|
|
23
25
|
end
|
|
24
26
|
|
|
@@ -33,6 +35,13 @@ module Vonage
|
|
|
33
35
|
when 'image'
|
|
34
36
|
raise Vonage::ClientError.new(":message must be a Hash") unless message.is_a? Hash
|
|
35
37
|
raise Vonage::ClientError.new(":url is required in :message") unless message[:url]
|
|
38
|
+
when 'video'
|
|
39
|
+
raise Vonage::ClientError.new(":message must be a Hash") unless message.is_a? Hash
|
|
40
|
+
raise Vonage::ClientError.new(":url is required in :message") unless message[:url]
|
|
41
|
+
raise Vonage::ClientError.new(":thumb_url is required in :message") unless message[:thumb_url]
|
|
42
|
+
when 'file'
|
|
43
|
+
raise Vonage::ClientError.new(":message must be a Hash") unless message.is_a? Hash
|
|
44
|
+
raise Vonage::ClientError.new(":url is required in :message") unless message[:url]
|
|
36
45
|
end
|
|
37
46
|
end
|
|
38
47
|
end
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
module Vonage
|
|
4
4
|
class Messaging::Channels::WhatsApp < Messaging::Message
|
|
5
|
-
MESSAGE_TYPES = ['text', 'image', 'audio', 'video', 'file', 'template', 'custom']
|
|
5
|
+
MESSAGE_TYPES = ['text', 'image', 'audio', 'video', 'file', 'template', 'sticker', 'custom']
|
|
6
6
|
|
|
7
7
|
attr_reader :data
|
|
8
8
|
|
|
9
9
|
def initialize(attributes = {})
|
|
10
|
+
@to = attributes.fetch(:to, nil)
|
|
11
|
+
@from = attributes.fetch(:from, nil)
|
|
10
12
|
@type = attributes.fetch(:type, nil)
|
|
11
13
|
@message = attributes.fetch(:message, nil)
|
|
12
14
|
@opts = attributes.fetch(:opts, {})
|
|
@@ -35,6 +37,8 @@ module Vonage
|
|
|
35
37
|
raise Vonage::ClientError.new(":name is required in :template") unless message[:name]
|
|
36
38
|
raise Vonage::ClientError.new(":whatsapp is required in :opts") unless opts[:whatsapp]
|
|
37
39
|
raise Vonage::ClientError.new(":locale is required in :whatsapp") unless opts[:whatsapp][:locale]
|
|
40
|
+
when 'sticker'
|
|
41
|
+
raise Vonage::ClientError.new(":message must contain either :id or :url") unless message.has_key?(:id) ^ message.has_key?(:url)
|
|
38
42
|
when 'custom'
|
|
39
43
|
raise Vonage::ClientError.new(":message must be a Hash") unless message.is_a? Hash
|
|
40
44
|
else
|
|
@@ -5,6 +5,7 @@ module Vonage
|
|
|
5
5
|
CHANNELS = {
|
|
6
6
|
sms: Vonage::Messaging::Channels::SMS,
|
|
7
7
|
mms: Vonage::Messaging::Channels::MMS,
|
|
8
|
+
rcs: Vonage::Messaging::Channels::RCS,
|
|
8
9
|
whatsapp: Vonage::Messaging::Channels::WhatsApp,
|
|
9
10
|
messenger: Vonage::Messaging::Channels::Messenger,
|
|
10
11
|
viber: Vonage::Messaging::Channels::Viber
|
|
@@ -24,7 +25,7 @@ module Vonage
|
|
|
24
25
|
|
|
25
26
|
private
|
|
26
27
|
|
|
27
|
-
attr_accessor :type, :message, :opts
|
|
28
|
+
attr_accessor :to, :from, :type, :message, :opts
|
|
28
29
|
attr_writer :data
|
|
29
30
|
|
|
30
31
|
def after_initialize!
|
|
@@ -34,6 +35,8 @@ module Vonage
|
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def build
|
|
38
|
+
data[:to] = to if to
|
|
39
|
+
data[:from] = from if from
|
|
37
40
|
data[:message_type] = type
|
|
38
41
|
data[type.to_sym] = message
|
|
39
42
|
data.merge!(opts)
|
data/lib/vonage/messaging.rb
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
# typed: true
|
|
2
2
|
# frozen_string_literal: true
|
|
3
|
+
require 'forwardable'
|
|
3
4
|
|
|
4
5
|
module Vonage
|
|
5
6
|
class Messaging < Namespace
|
|
6
|
-
|
|
7
|
+
extend Forwardable
|
|
8
|
+
|
|
9
|
+
self.authentication = BasicAndBearerToken
|
|
7
10
|
|
|
8
11
|
self.request_body = JSON
|
|
9
12
|
|
|
13
|
+
def_delegators Message, *Message::CHANNELS.keys
|
|
14
|
+
|
|
10
15
|
# Send a Message.
|
|
11
16
|
#
|
|
12
17
|
# @example
|
|
13
|
-
# message =
|
|
18
|
+
# message = client.messaging.sms(message: "Hello world!")
|
|
14
19
|
# response = client.messaging.send(to: "447700900000", from: "447700900001", **message)
|
|
15
20
|
#
|
|
16
21
|
# @option params [required, String] :to
|
|
@@ -20,10 +25,44 @@ module Vonage
|
|
|
20
25
|
# @option params [required, Hash] **message
|
|
21
26
|
# The Vonage Message object to use for this message.
|
|
22
27
|
#
|
|
23
|
-
# @see https://developer.vonage.com/api/messages
|
|
28
|
+
# @see https://developer.vonage.com/api/messages#SendMessage
|
|
24
29
|
#
|
|
25
|
-
def send(
|
|
30
|
+
def send(to:, from:, channel:, message_type:, failover: nil, **message)
|
|
31
|
+
params = { to: to, from: from, channel: channel, message_type: message_type }.merge(message)
|
|
32
|
+
|
|
33
|
+
if failover
|
|
34
|
+
raise ArgumentError.new("`failover` must be an array") unless failover.is_a?(Array)
|
|
35
|
+
raise ArgumentError.new("`failover` must not be empty") if failover.empty?
|
|
36
|
+
raise ArgumentError.new("`failover` must contain only Hashes") unless failover.all?(Hash)
|
|
37
|
+
params[:failover] = failover
|
|
38
|
+
end
|
|
39
|
+
|
|
26
40
|
request('/v1/messages', params: params, type: Post)
|
|
27
41
|
end
|
|
42
|
+
|
|
43
|
+
# Update a Message Object.
|
|
44
|
+
#
|
|
45
|
+
# @example
|
|
46
|
+
# message = client.messaging.update(message_uuid: "aaaaaaaa-bbbb-4ccc-8ddd-0123456789ab", status: "read")
|
|
47
|
+
#
|
|
48
|
+
# @option params [required, String] :message_uuid. the UUID of the message to update.
|
|
49
|
+
#
|
|
50
|
+
# `:message_uuid` is always required. Other parameters will depend on the message channel and the specific action being performed.
|
|
51
|
+
# @see https://developer.vonage.com/api/messages#UpdateMessage
|
|
52
|
+
#
|
|
53
|
+
def update(message_uuid:, **params)
|
|
54
|
+
request("/v1/messages/#{message_uuid}", params: params, type: Patch)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Validate a JSON Web Token from a Messages API Webhook.
|
|
58
|
+
#
|
|
59
|
+
# @param [String, required] :token The JWT from the Webhook's Authorization header
|
|
60
|
+
# @param [String, optional] :signature_secret The account signature secret. Required, unless `signature_secret`
|
|
61
|
+
# is set in `Config`
|
|
62
|
+
#
|
|
63
|
+
# @return [Boolean] true, if the JWT is verified, false otherwise
|
|
64
|
+
def verify_webhook_token(token:, signature_secret: @config.signature_secret)
|
|
65
|
+
JWT.verify_hs256_signature(token: token, signature_secret: signature_secret)
|
|
66
|
+
end
|
|
28
67
|
end
|
|
29
68
|
end
|