vonage 7.36.0 → 7.37.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/lib/vonage/messaging/channels/email.rb +60 -0
- data/lib/vonage/messaging/message.rb +2 -1
- data/lib/vonage/version.rb +1 -1
- data/lib/vonage/voice.rb +3 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a07f30eea61e555c314f3dccb86f4e71c2bce196108331cd330d296096aab53a
|
|
4
|
+
data.tar.gz: 5809203571fc5ea2644d6adcf39ebcdf51d883e4dd1a957905ef87ab61bb88ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 12f441f5c3df05c1afe3cea7aeb2f35e5c3cdc3279c18dfa10f369df2bdb69952ee9cc1b437be05910ad84bd52aade71eb34131c258974d7fae38e75c20d7dd5
|
|
7
|
+
data.tar.gz: eb2bd822c7709056041083d938f538050e3bf3a1a45581ece8f04557423ff4c2e2a027526cbef76f035f51772f085bfdc6d4f9f7d5a420102835d297595934e9
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
|
|
3
|
+
module Vonage
|
|
4
|
+
class Messaging::Channels::Email < Messaging::Message
|
|
5
|
+
MESSAGE_TYPES = ['text', 'html', 'content'].freeze
|
|
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 after_initialize!
|
|
23
|
+
verify_type
|
|
24
|
+
verify_message
|
|
25
|
+
verify_opts
|
|
26
|
+
build
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def build
|
|
30
|
+
data[:channel] = 'email'
|
|
31
|
+
super
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def verify_type
|
|
35
|
+
raise Vonage::ClientError.new("Invalid message type") unless MESSAGE_TYPES.include?(type)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def verify_message
|
|
39
|
+
case type
|
|
40
|
+
when 'text'
|
|
41
|
+
raise Vonage::ClientError.new("Invalid parameter type. `:message` must be a String") unless message.is_a? String
|
|
42
|
+
when 'html'
|
|
43
|
+
raise Vonage::ClientError.new("Invalid parameter type. `:message` must be a Hash") unless message.is_a? Hash
|
|
44
|
+
raise Vonage::ClientError.new("Missing parameter. `:message` must contain a `:body` key") unless message[:body]
|
|
45
|
+
when 'content'
|
|
46
|
+
raise Vonage::ClientError.new("Invalid parameter type. `:message` must be an Array") unless message.is_a? Array
|
|
47
|
+
raise Vonage::ClientError.new("Invalid parameter content. `:message` must not be empty") if message.empty?
|
|
48
|
+
raise Vonage::ClientError.new("Invalid array contents. Each element of `:message` must be a Hash") unless message.all? { |m| m.is_a? Hash }
|
|
49
|
+
else
|
|
50
|
+
raise Vonage::ClientError.new("Invalid message type")
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def verify_opts
|
|
55
|
+
raise Vonage::ClientError.new("Missing required parameter. `:opts` is required") if opts.nil? || opts.empty?
|
|
56
|
+
raise Vonage::ClientError.new("Missing required parameter. `:email` is required in `:opts`") unless opts[:email]
|
|
57
|
+
raise Vonage::ClientError.new("Missing required parameter. `:subject` is required in `:email`") unless opts[:email][:subject]
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -8,7 +8,8 @@ module Vonage
|
|
|
8
8
|
rcs: Vonage::Messaging::Channels::RCS,
|
|
9
9
|
whatsapp: Vonage::Messaging::Channels::WhatsApp,
|
|
10
10
|
messenger: Vonage::Messaging::Channels::Messenger,
|
|
11
|
-
viber: Vonage::Messaging::Channels::Viber
|
|
11
|
+
viber: Vonage::Messaging::Channels::Viber,
|
|
12
|
+
email: Vonage::Messaging::Channels::Email
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
class << self
|
data/lib/vonage/version.rb
CHANGED
data/lib/vonage/voice.rb
CHANGED
|
@@ -66,6 +66,9 @@ module Vonage
|
|
|
66
66
|
#
|
|
67
67
|
# @option params [Integer] :ringing_timer
|
|
68
68
|
# Set the number of seconds that elapse before Vonage hangs up after the call state changes to `ringing`.
|
|
69
|
+
#
|
|
70
|
+
# @option params [Boolean] :return_cps_on_started
|
|
71
|
+
# Set this to `true` to return CPS information when the call is started.
|
|
69
72
|
#
|
|
70
73
|
# @param [Hash] params
|
|
71
74
|
#
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vonage
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.
|
|
4
|
+
version: 7.37.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vonage
|
|
@@ -185,6 +185,7 @@ files:
|
|
|
185
185
|
- lib/vonage/meetings/themes/list_response.rb
|
|
186
186
|
- lib/vonage/messages.rb
|
|
187
187
|
- lib/vonage/messaging.rb
|
|
188
|
+
- lib/vonage/messaging/channels/email.rb
|
|
188
189
|
- lib/vonage/messaging/channels/messenger.rb
|
|
189
190
|
- lib/vonage/messaging/channels/mms.rb
|
|
190
191
|
- lib/vonage/messaging/channels/rcs.rb
|