vonage 7.30.0 → 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.
- checksums.yaml +4 -4
- data/README.md +92 -604
- data/lib/vonage/applications.rb +4 -12
- data/lib/vonage/basic.rb +1 -1
- data/lib/vonage/bearer_token.rb +1 -1
- data/lib/vonage/client.rb +0 -65
- data/lib/vonage/client_error.rb +1 -1
- data/lib/vonage/config.rb +1 -9
- data/lib/vonage/conversations/events.rb +0 -12
- data/lib/vonage/conversations/legs.rb +0 -6
- data/lib/vonage/conversations/members.rb +0 -15
- data/lib/vonage/conversations/users.rb +0 -15
- data/lib/vonage/conversations.rb +0 -30
- data/lib/vonage/errors.rb +20 -37
- data/lib/vonage/gsm7.rb +1 -1
- data/lib/vonage/http.rb +3 -3
- data/lib/vonage/jwt.rb +0 -17
- data/lib/vonage/key_secret_params.rb +2 -3
- data/lib/vonage/keys.rb +1 -14
- data/lib/vonage/logger.rb +3 -5
- data/lib/vonage/messaging/channels/messenger.rb +0 -2
- data/lib/vonage/messaging/channels/mms.rb +0 -2
- data/lib/vonage/messaging/channels/sms.rb +0 -2
- data/lib/vonage/messaging/channels/viber.rb +2 -11
- data/lib/vonage/messaging/channels/whats_app.rb +1 -5
- data/lib/vonage/messaging/message.rb +1 -4
- data/lib/vonage/messaging.rb +3 -42
- data/lib/vonage/namespace.rb +68 -137
- data/lib/vonage/numbers.rb +17 -40
- data/lib/vonage/server_error.rb +1 -1
- data/lib/vonage/signature.rb +5 -5
- data/lib/vonage/sms.rb +20 -20
- data/lib/vonage/version.rb +1 -1
- data/lib/vonage/video/archives.rb +58 -25
- data/lib/vonage/video/list_response.rb +11 -0
- data/lib/vonage/video/moderation.rb +22 -7
- data/lib/vonage/video/signals.rb +9 -4
- data/lib/vonage/video/streams.rb +12 -6
- data/lib/vonage/video.rb +13 -50
- data/lib/vonage/voice/actions/connect.rb +5 -34
- data/lib/vonage/voice/actions/conversation.rb +4 -10
- data/lib/vonage/voice/actions/input.rb +3 -19
- data/lib/vonage/voice/actions/notify.rb +3 -8
- data/lib/vonage/voice/actions/pay.rb +107 -0
- data/lib/vonage/voice/actions/record.rb +4 -52
- data/lib/vonage/voice/actions/stream.rb +4 -48
- data/lib/vonage/voice/actions/talk.rb +4 -54
- data/lib/vonage/voice/talk.rb +1 -11
- data/lib/vonage/voice.rb +0 -24
- data/lib/vonage.rb +0 -4
- data/vonage.gemspec +1 -3
- metadata +12 -108
- data/lib/vonage/api_error.rb +0 -33
- data/lib/vonage/conversation/event/list_response.rb +0 -11
- data/lib/vonage/conversation/event.rb +0 -108
- data/lib/vonage/conversation/list_response.rb +0 -11
- data/lib/vonage/conversation/member/list_response.rb +0 -11
- data/lib/vonage/conversation/member.rb +0 -134
- data/lib/vonage/conversation/user/conversations_list_response.rb +0 -11
- data/lib/vonage/conversation/user/sessions_list_response.rb +0 -11
- data/lib/vonage/conversation/user.rb +0 -67
- data/lib/vonage/conversation.rb +0 -164
- data/lib/vonage/meetings/applications.rb +0 -28
- data/lib/vonage/meetings/dial_in_numbers/list_response.rb +0 -11
- data/lib/vonage/meetings/dial_in_numbers.rb +0 -26
- data/lib/vonage/meetings/recordings.rb +0 -42
- data/lib/vonage/meetings/rooms/list_response.rb +0 -11
- data/lib/vonage/meetings/rooms.rb +0 -167
- data/lib/vonage/meetings/sessions/list_response.rb +0 -11
- data/lib/vonage/meetings/sessions.rb +0 -31
- data/lib/vonage/meetings/themes/list_response.rb +0 -11
- data/lib/vonage/meetings/themes.rb +0 -239
- data/lib/vonage/meetings.rb +0 -50
- data/lib/vonage/messaging/channels/rcs.rb +0 -44
- data/lib/vonage/network_authentication/client_authentication.rb +0 -39
- data/lib/vonage/network_authentication/server_authentication.rb +0 -47
- data/lib/vonage/network_authentication.rb +0 -22
- data/lib/vonage/network_number_verification.rb +0 -92
- data/lib/vonage/network_sim_swap.rb +0 -84
- data/lib/vonage/number_insight_2.rb +0 -36
- data/lib/vonage/proactive_connect/events/list_response.rb +0 -11
- data/lib/vonage/proactive_connect/events.rb +0 -71
- data/lib/vonage/proactive_connect/item.rb +0 -116
- data/lib/vonage/proactive_connect/items/file_response.rb +0 -32
- data/lib/vonage/proactive_connect/items/list_response.rb +0 -11
- data/lib/vonage/proactive_connect/items.rb +0 -116
- data/lib/vonage/proactive_connect/list.rb +0 -186
- data/lib/vonage/proactive_connect/lists/list_response.rb +0 -11
- data/lib/vonage/proactive_connect/lists.rb +0 -38
- data/lib/vonage/proactive_connect.rb +0 -43
- data/lib/vonage/subaccounts/balance_transfers/list_response.rb +0 -11
- data/lib/vonage/subaccounts/credit_transfers/list_response.rb +0 -11
- data/lib/vonage/subaccounts/list_response.rb +0 -15
- data/lib/vonage/subaccounts.rb +0 -203
- data/lib/vonage/users/list_response.rb +0 -11
- data/lib/vonage/users.rb +0 -156
- data/lib/vonage/verify2/channels/email.rb +0 -36
- data/lib/vonage/verify2/channels/silent_auth.rb +0 -45
- data/lib/vonage/verify2/channels/sms.rb +0 -63
- data/lib/vonage/verify2/channels/voice.rb +0 -32
- data/lib/vonage/verify2/channels/whats_app.rb +0 -39
- data/lib/vonage/verify2/channels/whats_app_interactive.rb +0 -32
- data/lib/vonage/verify2/start_verification_options.rb +0 -63
- data/lib/vonage/verify2/template_fragments/list_response.rb +0 -11
- data/lib/vonage/verify2/template_fragments.rb +0 -125
- data/lib/vonage/verify2/templates/list_response.rb +0 -11
- data/lib/vonage/verify2/templates.rb +0 -86
- data/lib/vonage/verify2/workflow.rb +0 -39
- data/lib/vonage/verify2/workflow_builder.rb +0 -25
- data/lib/vonage/verify2.rb +0 -112
- data/lib/vonage/video/archives/list_response.rb +0 -11
- data/lib/vonage/video/broadcasts/list_response.rb +0 -11
- data/lib/vonage/video/broadcasts.rb +0 -75
- data/lib/vonage/video/captions.rb +0 -67
- data/lib/vonage/video/renders/list_response.rb +0 -11
- data/lib/vonage/video/renders.rb +0 -107
- data/lib/vonage/video/sip.rb +0 -48
- data/lib/vonage/video/streams/list_response.rb +0 -11
- data/lib/vonage/video/web_socket.rb +0 -61
data/lib/vonage/errors.rb
CHANGED
@@ -1,25 +1,14 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
|
-
require
|
3
|
+
require 'json'
|
4
4
|
|
5
5
|
module Vonage
|
6
6
|
module Errors
|
7
7
|
extend T::Sig
|
8
8
|
|
9
|
-
sig
|
10
|
-
params(
|
11
|
-
response:
|
12
|
-
T.any(
|
13
|
-
Net::HTTPUnauthorized,
|
14
|
-
Net::HTTPClientError,
|
15
|
-
Net::HTTPServerError,
|
16
|
-
T.untyped
|
17
|
-
)
|
18
|
-
).returns(Vonage::Error)
|
19
|
-
end
|
9
|
+
sig {params(response: T.any(Net::HTTPUnauthorized, Net::HTTPClientError, Net::HTTPServerError, T.untyped)).returns(Vonage::Error)}
|
20
10
|
def self.parse(response)
|
21
|
-
exception_class =
|
22
|
-
case response
|
11
|
+
exception_class = case response
|
23
12
|
when Net::HTTPUnauthorized
|
24
13
|
AuthenticationError
|
25
14
|
when Net::HTTPClientError
|
@@ -27,40 +16,34 @@ module Vonage
|
|
27
16
|
when Net::HTTPServerError
|
28
17
|
ServerError
|
29
18
|
else
|
30
|
-
|
19
|
+
Error
|
31
20
|
end
|
32
21
|
|
33
|
-
message = response.content_type
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
hash
|
43
|
-
|
44
|
-
|
45
|
-
elsif hash.key?("description")
|
46
|
-
hash["description"]
|
47
|
-
elsif hash.key?("message")
|
48
|
-
hash["message"]
|
49
|
-
elsif problem_details?(hash)
|
50
|
-
problem_details_message(hash)
|
51
|
-
else
|
52
|
-
""
|
22
|
+
message = if response.content_type == 'application/json'
|
23
|
+
hash = ::JSON.parse(response.body)
|
24
|
+
|
25
|
+
if hash.key?('error_title')
|
26
|
+
hash['error_title']
|
27
|
+
elsif hash.key?('error-code-label')
|
28
|
+
hash['error-code-label']
|
29
|
+
elsif hash.key?('description')
|
30
|
+
hash['description']
|
31
|
+
elsif problem_details?(hash)
|
32
|
+
problem_details_message(hash)
|
33
|
+
end
|
53
34
|
end
|
35
|
+
|
36
|
+
exception_class.new(message)
|
54
37
|
end
|
55
38
|
|
56
39
|
sig { params(hash: T::Hash[String, T.untyped]).returns(T::Boolean) }
|
57
40
|
def self.problem_details?(hash)
|
58
|
-
hash.key?(
|
41
|
+
hash.key?('title') && hash.key?('detail') && hash.key?('type')
|
59
42
|
end
|
60
43
|
|
61
44
|
sig { params(hash: T::Hash[String, T.untyped]).returns(String) }
|
62
45
|
def self.problem_details_message(hash)
|
63
|
-
"#{hash[
|
46
|
+
"#{hash['title']}. #{hash['detail']} See #{hash['type']} for more info, or email support@nexmo.com if you have any questions."
|
64
47
|
end
|
65
48
|
end
|
66
49
|
|
data/lib/vonage/gsm7.rb
CHANGED
@@ -4,7 +4,7 @@ module Vonage
|
|
4
4
|
module GSM7
|
5
5
|
extend T::Sig
|
6
6
|
|
7
|
-
CHARACTERS = "\n\f\r !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~
|
7
|
+
CHARACTERS = "\n\f\r !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~ ¡£¤¥§¿ÄÅÆÉÑÖØÜßàäåæçèéìñòöøùüΓΔΘΛΞΠΣΦΨΩ€"
|
8
8
|
|
9
9
|
REGEXP = /\A[#{Regexp.escape(CHARACTERS)}]*\z/
|
10
10
|
|
data/lib/vonage/http.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
|
-
require 'net/http
|
3
|
+
require 'net/http'
|
4
4
|
|
5
5
|
module Vonage
|
6
6
|
module HTTP
|
@@ -21,7 +21,7 @@ module Vonage
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
sig { params(http: Net::HTTP
|
24
|
+
sig { params(http: Net::HTTP).returns(T::Hash[Symbol, T.untyped]) }
|
25
25
|
def set(http)
|
26
26
|
@hash.each do |name, value|
|
27
27
|
http.public_send(defined_options.fetch(name), value)
|
@@ -34,7 +34,7 @@ module Vonage
|
|
34
34
|
def defined_options
|
35
35
|
@defined_options = T.let(@defined_options, T.nilable(T::Hash[Symbol, T.untyped]))
|
36
36
|
|
37
|
-
@defined_options ||= Net::HTTP
|
37
|
+
@defined_options ||= Net::HTTP.instance_methods.grep(/\w=\z/).each_with_object({}) do |name, hash|
|
38
38
|
hash[name.to_s.chomp('=').to_sym] = name
|
39
39
|
end
|
40
40
|
end
|
data/lib/vonage/jwt.rb
CHANGED
@@ -39,22 +39,5 @@ module Vonage
|
|
39
39
|
payload[:private_key] = private_key if private_key && !payload[:private_key]
|
40
40
|
@token = Vonage::JWTBuilder.new(payload).jwt.generate
|
41
41
|
end
|
42
|
-
|
43
|
-
# Validate a JSON Web Token from a Vonage Webhook.
|
44
|
-
#
|
45
|
-
# Certain Vonage APIs include a JWT signed with a user's account signature secret in
|
46
|
-
# the Authorization header of Webhook requests. This method can be used to verify that those requests originate
|
47
|
-
# from the Vonage API.
|
48
|
-
#
|
49
|
-
# @param [String, required] :token The JWT from the Webhook's Authorization header
|
50
|
-
# @param [String, required] :signature_secret The account signature secret
|
51
|
-
#
|
52
|
-
# @return [Boolean] true, if the JWT is verified, false otherwise
|
53
|
-
#
|
54
|
-
# @see https://developer.vonage.com/en/getting-started/concepts/webhooks#decoding-signed-webhooks
|
55
|
-
#
|
56
|
-
def self.verify_hs256_signature(token:, signature_secret:)
|
57
|
-
verify_signature(token, signature_secret, 'HS256')
|
58
|
-
end
|
59
42
|
end
|
60
43
|
end
|
@@ -5,10 +5,9 @@ module Vonage
|
|
5
5
|
extend T::Sig
|
6
6
|
|
7
7
|
sig { params(
|
8
|
-
object: T.any(T::Hash[T.untyped, T.untyped], URI::HTTPS, Net::HTTP::Post, Net::HTTP::Get)
|
9
|
-
data: T.nilable(Hash)
|
8
|
+
object: T.any(T::Hash[T.untyped, T.untyped], URI::HTTPS, Net::HTTP::Post, Net::HTTP::Get)
|
10
9
|
).void }
|
11
|
-
def update(object
|
10
|
+
def update(object)
|
12
11
|
return unless object.is_a?(Hash)
|
13
12
|
|
14
13
|
@config = T.let(@config, T.nilable(Vonage::Config))
|
data/lib/vonage/keys.rb
CHANGED
@@ -27,20 +27,7 @@ module Vonage
|
|
27
27
|
'has_video',
|
28
28
|
'remove_stream',
|
29
29
|
'screenshare_type',
|
30
|
-
'
|
31
|
-
'output_mode',
|
32
|
-
'stream_mode',
|
33
|
-
'archive_mode',
|
34
|
-
'multi_archive_tag',
|
35
|
-
'language_code',
|
36
|
-
'max_duration',
|
37
|
-
'partial_captions',
|
38
|
-
'status_callback_url',
|
39
|
-
'audio_rate',
|
40
|
-
'phone_number',
|
41
|
-
'hashed_phone_number',
|
42
|
-
'max_age',
|
43
|
-
'max_bitrate'
|
30
|
+
'archive_mode'
|
44
31
|
]
|
45
32
|
hash.transform_keys do |k|
|
46
33
|
if exceptions.include?(k.to_s)
|
data/lib/vonage/logger.rb
CHANGED
@@ -7,11 +7,7 @@ module Vonage
|
|
7
7
|
class Logger
|
8
8
|
extend T::Sig
|
9
9
|
|
10
|
-
sig { params(logger: T.nilable(
|
11
|
-
defined?(ActiveSupport::BroadcastLogger) ?
|
12
|
-
T.any(::Logger, Vonage::Logger, ActiveSupport::BroadcastLogger)
|
13
|
-
: T.any(::Logger, Vonage::Logger)
|
14
|
-
)).void }
|
10
|
+
sig { params(logger: T.nilable(T.any(::Logger, Vonage::Logger))).void }
|
15
11
|
def initialize(logger)
|
16
12
|
@logger = logger || ::Logger.new(nil)
|
17
13
|
end
|
@@ -24,6 +20,8 @@ module Vonage
|
|
24
20
|
|
25
21
|
sig { params(request: T.any(Net::HTTP::Post, Net::HTTP::Get, Net::HTTP::Delete, Net::HTTP::Put, Net::HTTP::Patch)).void }
|
26
22
|
def log_request_info(request)
|
23
|
+
@logger = T.let(@logger, T.nilable(T.any(::Logger, Vonage::Logger)))
|
24
|
+
|
27
25
|
T.must(@logger).info do
|
28
26
|
format('Vonage API request', {
|
29
27
|
method: request.method,
|
@@ -7,8 +7,6 @@ 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)
|
12
10
|
@type = attributes.fetch(:type, nil)
|
13
11
|
@message = attributes.fetch(:message, nil)
|
14
12
|
@opts = attributes.fetch(:opts, {})
|
@@ -7,8 +7,6 @@ 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)
|
12
10
|
@type = attributes.fetch(:type, nil)
|
13
11
|
@message = attributes.fetch(:message, nil)
|
14
12
|
@opts = attributes.fetch(:opts, {})
|
@@ -5,8 +5,6 @@ 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)
|
10
8
|
@type = attributes.fetch(:type, 'text')
|
11
9
|
@message = attributes.fetch(:message, nil)
|
12
10
|
@opts = attributes.fetch(:opts, {})
|
@@ -2,13 +2,11 @@
|
|
2
2
|
|
3
3
|
module Vonage
|
4
4
|
class Messaging::Channels::Viber < Messaging::Message
|
5
|
-
MESSAGE_TYPES = ['text', 'image'
|
5
|
+
MESSAGE_TYPES = ['text', 'image']
|
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)
|
12
10
|
@type = attributes.fetch(:type, nil)
|
13
11
|
@message = attributes.fetch(:message, nil)
|
14
12
|
@opts = attributes.fetch(:opts, {})
|
@@ -20,7 +18,7 @@ module Vonage
|
|
20
18
|
private
|
21
19
|
|
22
20
|
def build
|
23
|
-
data[:channel] = 'viber_service'
|
21
|
+
data[:channel] = ' viber_service'
|
24
22
|
super
|
25
23
|
end
|
26
24
|
|
@@ -35,13 +33,6 @@ module Vonage
|
|
35
33
|
when 'image'
|
36
34
|
raise Vonage::ClientError.new(":message must be a Hash") unless message.is_a? Hash
|
37
35
|
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]
|
45
36
|
end
|
46
37
|
end
|
47
38
|
end
|
@@ -2,13 +2,11 @@
|
|
2
2
|
|
3
3
|
module Vonage
|
4
4
|
class Messaging::Channels::WhatsApp < Messaging::Message
|
5
|
-
MESSAGE_TYPES = ['text', 'image', 'audio', 'video', 'file', 'template', '
|
5
|
+
MESSAGE_TYPES = ['text', 'image', 'audio', 'video', 'file', 'template', '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)
|
12
10
|
@type = attributes.fetch(:type, nil)
|
13
11
|
@message = attributes.fetch(:message, nil)
|
14
12
|
@opts = attributes.fetch(:opts, {})
|
@@ -37,8 +35,6 @@ module Vonage
|
|
37
35
|
raise Vonage::ClientError.new(":name is required in :template") unless message[:name]
|
38
36
|
raise Vonage::ClientError.new(":whatsapp is required in :opts") unless opts[:whatsapp]
|
39
37
|
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)
|
42
38
|
when 'custom'
|
43
39
|
raise Vonage::ClientError.new(":message must be a Hash") unless message.is_a? Hash
|
44
40
|
else
|
@@ -5,7 +5,6 @@ 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,
|
9
8
|
whatsapp: Vonage::Messaging::Channels::WhatsApp,
|
10
9
|
messenger: Vonage::Messaging::Channels::Messenger,
|
11
10
|
viber: Vonage::Messaging::Channels::Viber
|
@@ -25,7 +24,7 @@ module Vonage
|
|
25
24
|
|
26
25
|
private
|
27
26
|
|
28
|
-
attr_accessor :
|
27
|
+
attr_accessor :type, :message, :opts
|
29
28
|
attr_writer :data
|
30
29
|
|
31
30
|
def after_initialize!
|
@@ -35,8 +34,6 @@ module Vonage
|
|
35
34
|
end
|
36
35
|
|
37
36
|
def build
|
38
|
-
data[:to] = to if to
|
39
|
-
data[:from] = from if from
|
40
37
|
data[:message_type] = type
|
41
38
|
data[type.to_sym] = message
|
42
39
|
data.merge!(opts)
|
data/lib/vonage/messaging.rb
CHANGED
@@ -1,21 +1,16 @@
|
|
1
1
|
# typed: true
|
2
2
|
# frozen_string_literal: true
|
3
|
-
require 'forwardable'
|
4
3
|
|
5
4
|
module Vonage
|
6
5
|
class Messaging < Namespace
|
7
|
-
extend Forwardable
|
8
|
-
|
9
6
|
self.authentication = BearerToken
|
10
7
|
|
11
8
|
self.request_body = JSON
|
12
9
|
|
13
|
-
def_delegators Message, *Message::CHANNELS.keys
|
14
|
-
|
15
10
|
# Send a Message.
|
16
11
|
#
|
17
12
|
# @example
|
18
|
-
# message =
|
13
|
+
# message = Vonage::Messaging::Message.sms(message: "Hello world!")
|
19
14
|
# response = client.messaging.send(to: "447700900000", from: "447700900001", **message)
|
20
15
|
#
|
21
16
|
# @option params [required, String] :to
|
@@ -25,44 +20,10 @@ module Vonage
|
|
25
20
|
# @option params [required, Hash] **message
|
26
21
|
# The Vonage Message object to use for this message.
|
27
22
|
#
|
28
|
-
# @see https://developer.vonage.com/api/messages#SendMessage
|
23
|
+
# @see https://developer.vonage.com/api/messages-olympus#SendMessage
|
29
24
|
#
|
30
|
-
def send(
|
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
|
-
|
25
|
+
def send(params)
|
40
26
|
request('/v1/messages', params: params, type: Post)
|
41
27
|
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
|
67
28
|
end
|
68
29
|
end
|