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
data/lib/vonage/users.rb
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Vonage
|
|
5
|
+
class Users < Namespace
|
|
6
|
+
extend T::Sig
|
|
7
|
+
self.authentication = BearerToken
|
|
8
|
+
|
|
9
|
+
self.request_body = JSON
|
|
10
|
+
|
|
11
|
+
# Get a list of Users associated with the Vonage Application.
|
|
12
|
+
#
|
|
13
|
+
# @param [optional, Integer] :page_size
|
|
14
|
+
# Specifies the number of records to be returned in the response.
|
|
15
|
+
#
|
|
16
|
+
# @param [optional, String] :order
|
|
17
|
+
# Specifies the order in which the records should be returned.
|
|
18
|
+
# Must be one of `asc`, `ASC`, `desc`, or `DESC`
|
|
19
|
+
#
|
|
20
|
+
# @param [optional, String] :cursor
|
|
21
|
+
# Specficy a cursor point from which to start returning results, for example the values of the `next` or `prev`
|
|
22
|
+
# `_links` contained in a response.
|
|
23
|
+
#
|
|
24
|
+
# @param [optional, String] :name
|
|
25
|
+
# Specify a user name with which to filter results
|
|
26
|
+
#
|
|
27
|
+
# @return [ListResponse]
|
|
28
|
+
#
|
|
29
|
+
# @see https://developer.vonage.com/en/api/application.v2#getUsers
|
|
30
|
+
#
|
|
31
|
+
def list(**params)
|
|
32
|
+
request('/v1/users', params: params, response_class: ListResponse)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Get a specified User associated with the Vonage Application.
|
|
36
|
+
#
|
|
37
|
+
# @param [required, String] :id
|
|
38
|
+
# The unique ID or name for the user.
|
|
39
|
+
#
|
|
40
|
+
# @return [Vonage::Response]
|
|
41
|
+
#
|
|
42
|
+
# @see https://developer.vonage.com/en/api/application.v2#getUser
|
|
43
|
+
#
|
|
44
|
+
def find(id:)
|
|
45
|
+
request("/v1/users/#{id}")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Create a new User associated with the Vonage Application.
|
|
49
|
+
#
|
|
50
|
+
# @param [optional, String] :name
|
|
51
|
+
# A unique name for the user. If not provided, a name will be auto-generated.
|
|
52
|
+
#
|
|
53
|
+
# @param [optional, String] :display_name
|
|
54
|
+
# A string to be displayed as user name. It does not need to be unique.
|
|
55
|
+
#
|
|
56
|
+
# @param [optional, String] :image_url
|
|
57
|
+
# A publicly accessible URL to an image file for an image to be associated with the user.
|
|
58
|
+
#
|
|
59
|
+
# @param [optional, Hash] :properties A hash defining properties for the User.
|
|
60
|
+
# @option properties [Hash] :custom_data A hash of custom data as key/value pairs.
|
|
61
|
+
#
|
|
62
|
+
# @param [optional, Hash] :channels A hash defining details of various channels.
|
|
63
|
+
# @option channels [Array] :pstn An array containing a Hash which defines data for the pstn channel.
|
|
64
|
+
# @option pstn [Integer] :number The pstn number.
|
|
65
|
+
# @option channels [Array] :sip An array containing a Hash which defines data for the sip channel.
|
|
66
|
+
# @option sip [String] :uri The sip uri.
|
|
67
|
+
# @option sip [String] :username The sip username.
|
|
68
|
+
# @option sip [String] :password The sip password.
|
|
69
|
+
# @option channels [Array] :vbc An array containing a Hash which defines data for the vbc channel.
|
|
70
|
+
# @option vbc [String] :extension The vbc extension.
|
|
71
|
+
# @option channels [Array] :websocket An array containing a Hash which defines data for the websocket channel.
|
|
72
|
+
# @option websocket [String] :uri The websocket uri.
|
|
73
|
+
# @option websocket [String] :content-type The websocket audio type. Must be one of: `audio/l16;rate=8000`, `audio/l16;rate=16000`.
|
|
74
|
+
# @option websocket [Hash] :headers A hash of custom websocket headers provided as key/value pairs.
|
|
75
|
+
# @option channels [Array] :sms An array containing a Hash which defines data for the sms channel.
|
|
76
|
+
# @option sms [Integer] :number The sms number.
|
|
77
|
+
# @option channels [Array] :mms An array containing a Hash which defines data for the mms channel.
|
|
78
|
+
# @option mms [Integer] :number The mms number.
|
|
79
|
+
# @option channels [Array] :whatsapp An array containing a Hash which defines data for the whatsapp channel.
|
|
80
|
+
# @option whatsapp [Integer] :number The whatsapp number.
|
|
81
|
+
# @option channels [Array] :viber An array containing a Hash which defines data for the sms channel.
|
|
82
|
+
# @option viber [Integer] :number The viber number.
|
|
83
|
+
# @option channels [Array] :messenger An array containing a Hash which defines data for the messenger channel.
|
|
84
|
+
# @option messenger [Integer] :id The messenger id.
|
|
85
|
+
#
|
|
86
|
+
# @return [Vonage::Response]
|
|
87
|
+
#
|
|
88
|
+
# @see https://developer.vonage.com/en/api/application.v2#createUser
|
|
89
|
+
#
|
|
90
|
+
def create(**params)
|
|
91
|
+
request('/v1/users', params: params, type: Post)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Update an existing User associated with the Vonage Application.
|
|
95
|
+
#
|
|
96
|
+
# @param [required, String] :id
|
|
97
|
+
# The unique ID or name for the user to be updated.
|
|
98
|
+
#
|
|
99
|
+
# @param [optional, String] :name
|
|
100
|
+
# A unique name for the user.
|
|
101
|
+
#
|
|
102
|
+
# @param [optional, String] :display_name
|
|
103
|
+
# A string to be displayed as user name. It does not need to be unique.
|
|
104
|
+
#
|
|
105
|
+
# @param [optional, String] :image_url
|
|
106
|
+
# A publicly accessible URL to an image file for an image to be associated with the user.
|
|
107
|
+
#
|
|
108
|
+
# @param [optional, Hash] :properties A hash defining properties for the User.
|
|
109
|
+
# @option properties [Hash] :custom_data A hash of custom data as key/value pairs.
|
|
110
|
+
#
|
|
111
|
+
# @param [optional, Hash] :channels A hash defining details of various channels.
|
|
112
|
+
# @option channels [Array] :pstn An array containing a Hash which defines data for the pstn channel.
|
|
113
|
+
# @option pstn [Integer] :number The pstn number.
|
|
114
|
+
# @option channels [Array] :sip An array containing a Hash which defines data for the sip channel.
|
|
115
|
+
# @option sip [String] :uri The sip uri.
|
|
116
|
+
# @option sip [String] :username The sip username.
|
|
117
|
+
# @option sip [String] :password The sip password.
|
|
118
|
+
# @option channels [Array] :vbc An array containing a Hash which defines data for the vbc channel.
|
|
119
|
+
# @option vbc [String] :extension The vbc extension.
|
|
120
|
+
# @option channels [Array] :websocket An array containing a Hash which defines data for the websocket channel.
|
|
121
|
+
# @option websocket [String] :uri The websocket uri.
|
|
122
|
+
# @option websocket [String] :content-type The websocket audio type. Must be one of: `audio/l16;rate=8000`, `audio/l16;rate=16000`.
|
|
123
|
+
# @option websocket [Hash] :headers A hash of custom websocket headers provided as key/value pairs.
|
|
124
|
+
# @option channels [Array] :sms An array containing a Hash which defines data for the sms channel.
|
|
125
|
+
# @option sms [Integer] :number The sms number.
|
|
126
|
+
# @option channels [Array] :mms An array containing a Hash which defines data for the mms channel.
|
|
127
|
+
# @option mms [Integer] :number The mms number.
|
|
128
|
+
# @option channels [Array] :whatsapp An array containing a Hash which defines data for the whatsapp channel.
|
|
129
|
+
# @option whatsapp [Integer] :number The whatsapp number.
|
|
130
|
+
# @option channels [Array] :viber An array containing a Hash which defines data for the sms channel.
|
|
131
|
+
# @option viber [Integer] :number The viber number.
|
|
132
|
+
# @option channels [Array] :messenger An array containing a Hash which defines data for the messenger channel.
|
|
133
|
+
# @option messenger [Integer] :id The messenger id.
|
|
134
|
+
#
|
|
135
|
+
# @return [Vonage::Response]
|
|
136
|
+
#
|
|
137
|
+
# @see https://developer.vonage.com/en/api/application.v2#createUser
|
|
138
|
+
#
|
|
139
|
+
def update(id:, **params)
|
|
140
|
+
request("/v1/users/#{id}", params: params, type: Patch)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Delete a specified User associated with the Vonage Application.
|
|
144
|
+
#
|
|
145
|
+
# @param [required, String] :id
|
|
146
|
+
# The unique ID or name for the user.
|
|
147
|
+
#
|
|
148
|
+
# @return [Vonage::Response]
|
|
149
|
+
#
|
|
150
|
+
# @see https://developer.vonage.com/en/api/application.v2#deleteUser
|
|
151
|
+
#
|
|
152
|
+
def delete(id:)
|
|
153
|
+
request("/v1/users/#{id}", type: Delete)
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
data/lib/vonage/verify.rb
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
require 'phonelib'
|
|
4
|
+
|
|
5
|
+
module Vonage
|
|
6
|
+
class Verify2::Channels::Email
|
|
7
|
+
|
|
8
|
+
attr_reader :channel, :to, :from
|
|
9
|
+
|
|
10
|
+
def initialize(to:, from: nil)
|
|
11
|
+
self.channel = 'email'
|
|
12
|
+
self.to = to
|
|
13
|
+
self.from = from unless from.nil?
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to=(to)
|
|
17
|
+
@to = to
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def from=(from)
|
|
21
|
+
@from = from
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def to_h
|
|
25
|
+
hash = Hash.new
|
|
26
|
+
self.instance_variables.each do |ivar|
|
|
27
|
+
hash[ivar.to_s.delete("@").to_sym] = self.instance_variable_get(ivar)
|
|
28
|
+
end
|
|
29
|
+
hash
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
attr_writer :channel
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
require 'phonelib'
|
|
4
|
+
require 'uri'
|
|
5
|
+
|
|
6
|
+
module Vonage
|
|
7
|
+
class Verify2::Channels::SilentAuth
|
|
8
|
+
|
|
9
|
+
attr_reader :channel, :to, :sandbox, :redirect_url
|
|
10
|
+
|
|
11
|
+
def initialize(to:, redirect_url: nil, sandbox: nil)
|
|
12
|
+
self.channel = 'silent_auth'
|
|
13
|
+
self.to = to
|
|
14
|
+
self.redirect_url = redirect_url unless redirect_url.nil?
|
|
15
|
+
self.sandbox = sandbox unless sandbox.nil?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def to=(to)
|
|
19
|
+
raise ArgumentError, "Invalid 'to' value #{to}. Expected to be in E.164 format" unless Phonelib.parse(to.to_i).valid?
|
|
20
|
+
@to = to
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def redirect_url=(redirect_url)
|
|
24
|
+
raise ArgumentError, "Invalid 'to' value #{redirect_url}. Expected to be a valid URL" unless URI.parse(redirect_url).is_a?(URI::HTTP)
|
|
25
|
+
@redirect_url = redirect_url
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @deprecated: This method is deprecated and will be removed in a future release.
|
|
29
|
+
def sandbox=(sandbox)
|
|
30
|
+
raise ArgumentError, "Invalid 'sandbox' value #{sandbox}. Expected to be boolean value" unless [true, false].include? sandbox
|
|
31
|
+
@sandbox = sandbox
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def to_h
|
|
35
|
+
hash = Hash.new
|
|
36
|
+
self.instance_variables.each do |ivar|
|
|
37
|
+
hash[ivar.to_s.delete("@").to_sym] = self.instance_variable_get(ivar)
|
|
38
|
+
end
|
|
39
|
+
hash
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
attr_writer :channel
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
require 'phonelib'
|
|
4
|
+
|
|
5
|
+
module Vonage
|
|
6
|
+
class Verify2::Channels::SMS
|
|
7
|
+
APP_HASH_LENGTH = 11
|
|
8
|
+
|
|
9
|
+
attr_reader :channel, :to, :from, :entity_id, :content_id, :app_hash
|
|
10
|
+
|
|
11
|
+
def initialize(to:, app_hash: nil)
|
|
12
|
+
self.channel = 'sms'
|
|
13
|
+
self.to = to
|
|
14
|
+
self.app_hash = app_hash unless app_hash.nil?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def to=(to)
|
|
18
|
+
raise ArgumentError, "Invalid 'to' value #{to}. Expected to be in E.164 format" unless Phonelib.parse(to).valid?
|
|
19
|
+
@to = to
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def from=(from)
|
|
23
|
+
validate_from(from)
|
|
24
|
+
@from = from
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def entity_id=(entity_id)
|
|
28
|
+
raise ArgumentError, "Invalid 'entity_id' value #{entity_id}. Length must be between 1 and 20 characters." unless entity_id.length.between?(1, 20)
|
|
29
|
+
@entity_id = entity_id
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def content_id=(content_id)
|
|
33
|
+
raise ArgumentError, "Invalid 'content_id' value #{content_id}. Length must be between 1 and 20 characters ." unless content_id.length.between?(1, 20)
|
|
34
|
+
@content_id = content_id
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def app_hash=(app_hash)
|
|
38
|
+
raise ArgumentError, "Invalid 'app_hash' value #{app_hash}. Length must be #{APP_HASH_LENGTH}" unless app_hash.length == APP_HASH_LENGTH
|
|
39
|
+
@app_hash = app_hash
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def to_h
|
|
43
|
+
hash = Hash.new
|
|
44
|
+
self.instance_variables.each do |ivar|
|
|
45
|
+
hash[ivar.to_s.delete("@").to_sym] = self.instance_variable_get(ivar)
|
|
46
|
+
end
|
|
47
|
+
hash
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
attr_writer :channel
|
|
53
|
+
|
|
54
|
+
def validate_from(from)
|
|
55
|
+
if from.match?(/\D/)
|
|
56
|
+
raise ArgumentError, "Invalid alpha-numeric 'from' value #{from}. Length must be between 3 and 11 characters." unless from.length.between?(3, 11)
|
|
57
|
+
else
|
|
58
|
+
raise ArgumentError, "Invalid numeric 'from' value #{from}. Length must be between 11 and 15 characters." unless from.length.between?(11, 15)
|
|
59
|
+
raise ArgumentError, "Invalid 'from' value #{from}. Expected to be in E.164 format" unless Phonelib.parse(from).valid?
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
require 'phonelib'
|
|
4
|
+
|
|
5
|
+
module Vonage
|
|
6
|
+
class Verify2::Channels::Voice
|
|
7
|
+
|
|
8
|
+
attr_reader :channel, :to
|
|
9
|
+
|
|
10
|
+
def initialize(to:)
|
|
11
|
+
self.channel = 'voice'
|
|
12
|
+
self.to = to
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to=(to)
|
|
16
|
+
raise ArgumentError, "Invalid 'to' value #{to}. Expected to be in E.164 format" unless Phonelib.parse(to.to_i).valid?
|
|
17
|
+
@to = to
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_h
|
|
21
|
+
hash = Hash.new
|
|
22
|
+
self.instance_variables.each do |ivar|
|
|
23
|
+
hash[ivar.to_s.delete("@").to_sym] = self.instance_variable_get(ivar)
|
|
24
|
+
end
|
|
25
|
+
hash
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
attr_writer :channel
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
require 'phonelib'
|
|
4
|
+
|
|
5
|
+
module Vonage
|
|
6
|
+
class Verify2::Channels::WhatsApp
|
|
7
|
+
|
|
8
|
+
attr_reader :channel, :to, :from
|
|
9
|
+
|
|
10
|
+
def initialize(to:, from:)
|
|
11
|
+
self.channel = 'whatsapp'
|
|
12
|
+
self.to = to
|
|
13
|
+
self.from = from
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to=(to)
|
|
17
|
+
raise ArgumentError, "Invalid 'to' value #{to}. Expected to be in E.164 format" unless Phonelib.parse(to.to_i).valid?
|
|
18
|
+
@to = to
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def from=(from)
|
|
22
|
+
raise ArgumentError, "Invalid 'from' value #{from}. Length must be between 11 and 15 characters." unless from.length.between?(11, 15)
|
|
23
|
+
raise ArgumentError, "Invalid 'from' value #{from}. Expected to be in E.164 format" unless Phonelib.parse(from.to_i).valid?
|
|
24
|
+
@from = from
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def mode=(mode)
|
|
28
|
+
valid_modes = ['otp_code', 'zero_tap']
|
|
29
|
+
raise ArgumentError, "Invalid 'mode' value #{mode}. Expected to be one of #{valid_modes.join(', ')}" unless valid_modes.include?(mode)
|
|
30
|
+
@mode = mode
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def to_h
|
|
34
|
+
hash = Hash.new
|
|
35
|
+
self.instance_variables.each do |ivar|
|
|
36
|
+
hash[ivar.to_s.delete("@").to_sym] = self.instance_variable_get(ivar)
|
|
37
|
+
end
|
|
38
|
+
hash
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
attr_writer :channel
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
require 'phonelib'
|
|
4
|
+
|
|
5
|
+
module Vonage
|
|
6
|
+
class Verify2::Channels::WhatsAppInteractive
|
|
7
|
+
|
|
8
|
+
attr_reader :channel, :to
|
|
9
|
+
|
|
10
|
+
def initialize(to:)
|
|
11
|
+
self.channel = 'whatsapp_interactive'
|
|
12
|
+
self.to = to
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to=(to)
|
|
16
|
+
raise ArgumentError, "Invalid 'to' value #{to}. Expected to be in E.164 format" unless Phonelib.parse(to.to_i).valid?
|
|
17
|
+
@to = to
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_h
|
|
21
|
+
hash = Hash.new
|
|
22
|
+
self.instance_variables.each do |ivar|
|
|
23
|
+
hash[ivar.to_s.delete("@").to_sym] = self.instance_variable_get(ivar)
|
|
24
|
+
end
|
|
25
|
+
hash
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
attr_writer :channel
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Vonage
|
|
5
|
+
class Verify2::StartVerificationOptions
|
|
6
|
+
VALID_OPTS = [:locale, :channel_timeout, :client_ref, :code_length, :code, :fraud_check].freeze
|
|
7
|
+
|
|
8
|
+
MIN_CHANNEL_TIMEOUT, MAX_CHANNEL_TIMEOUT = [15, 900]
|
|
9
|
+
|
|
10
|
+
MIN_CODE_LENGTH, MAX_CODE_LENGTH = [4, 10]
|
|
11
|
+
|
|
12
|
+
attr_reader(*VALID_OPTS)
|
|
13
|
+
|
|
14
|
+
def initialize(**opts)
|
|
15
|
+
VALID_OPTS.each do |opt|
|
|
16
|
+
send("#{opt}=", opts[opt]) unless opts[opt].nil?
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def locale=(locale)
|
|
21
|
+
@locale = locale
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def channel_timeout=(channel_timeout)
|
|
25
|
+
raise ArgumentError, "Invalid 'channel_timeout' #{channel_timeout}. Must be an integer" unless channel_timeout.is_a?(Integer)
|
|
26
|
+
unless channel_timeout.between?(MIN_CHANNEL_TIMEOUT, MAX_CHANNEL_TIMEOUT)
|
|
27
|
+
raise ArgumentError, "Invalid 'channel_timeout' #{channel_timeout}. Must be between #{MIN_CHANNEL_TIMEOUT} and #{MAX_CHANNEL_TIMEOUT} (inclusive)"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
@channel_timeout = channel_timeout
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def client_ref=(client_ref)
|
|
34
|
+
@client_ref = client_ref
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def code_length=(code_length)
|
|
38
|
+
unless code_length.between?(MIN_CODE_LENGTH, MAX_CODE_LENGTH)
|
|
39
|
+
raise ArgumentError, "Invalid 'code_length' #{code_length}. Must be between #{MIN_CODE_LENGTH} and #{MAX_CODE_LENGTH} (inclusive)"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
@code_length = code_length
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def code=(code)
|
|
46
|
+
@code = code
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def fraud_check=(fraud_check)
|
|
50
|
+
raise ArgumentError, "Invalid 'fraud_check' #{fraud_check}. Must be `false`" unless fraud_check == false
|
|
51
|
+
|
|
52
|
+
@fraud_check = fraud_check
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def to_h
|
|
56
|
+
hash = Hash.new
|
|
57
|
+
self.instance_variables.each do |ivar|
|
|
58
|
+
hash[ivar.to_s.delete("@").to_sym] = self.instance_variable_get(ivar)
|
|
59
|
+
end
|
|
60
|
+
hash
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Vonage
|
|
5
|
+
class Verify2::TemplateFragments < Namespace
|
|
6
|
+
CHANNELS = ['sms', 'voice'].freeze
|
|
7
|
+
|
|
8
|
+
self.authentication = BasicAndBearerToken
|
|
9
|
+
|
|
10
|
+
self.request_body = JSON
|
|
11
|
+
|
|
12
|
+
# Get a list of of template fragments for a specific template.
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# template_fragment_list = client.verify2.template_fragments.list(template_id: '8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9')
|
|
16
|
+
#
|
|
17
|
+
# @param [required, String] :template_id. The ID of the template for which to retreive the fragments
|
|
18
|
+
#
|
|
19
|
+
# @param [optional, Integer] :page_size. The amount of template fragments to list per page
|
|
20
|
+
#
|
|
21
|
+
# @param [optional, Integer] :page. The page number to retrieve
|
|
22
|
+
#
|
|
23
|
+
# @return [ListResponse]
|
|
24
|
+
#
|
|
25
|
+
# @see https://developer.vonage.com/en/api/verify.v2#listTemplateFragments
|
|
26
|
+
def list(template_id:, **params)
|
|
27
|
+
request("/v2/verify/templates/#{template_id}/template_fragments", params: params, response_class: ListResponse)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Get details of a specific template fragment.
|
|
31
|
+
#
|
|
32
|
+
# @example
|
|
33
|
+
# template_fragment = client.verify2.template_fragments.info(
|
|
34
|
+
# template_id: '8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9',
|
|
35
|
+
# template_fragment_id: 'c70f446e-997a-4313-a081-60a02a31dc19'
|
|
36
|
+
# )
|
|
37
|
+
#
|
|
38
|
+
# @param [required, String] :template_id. The ID of the template for which to retreive the fragment
|
|
39
|
+
#
|
|
40
|
+
# @param [required, String] :template_fragment_id. The ID of the fragment to be retreived
|
|
41
|
+
#
|
|
42
|
+
# @return [Response]
|
|
43
|
+
#
|
|
44
|
+
# @see https://developer.vonage.com/en/api/verify.v2#getTemplateFragment
|
|
45
|
+
def info(template_id:, template_fragment_id:)
|
|
46
|
+
request("/v2/verify/templates/#{template_id}/template_fragments/#{template_fragment_id}")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Create a new template fragment.
|
|
50
|
+
#
|
|
51
|
+
# @example
|
|
52
|
+
# client.verify2.template_fragments.create(
|
|
53
|
+
# template_id: '8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9',
|
|
54
|
+
# channel: 'sms',
|
|
55
|
+
# locale: 'en-gb',
|
|
56
|
+
# text: 'Your code is: ${code}'
|
|
57
|
+
# )
|
|
58
|
+
#
|
|
59
|
+
# @param [required, String] :template_id. The ID of the template for which to create the fragment
|
|
60
|
+
#
|
|
61
|
+
# @param [required, String] :channel. The verification channel for which to create the fragment. Must be one of 'sms' or 'voice'
|
|
62
|
+
#
|
|
63
|
+
# @param [required, String] :locale. The locale for which to create the fragment.
|
|
64
|
+
#
|
|
65
|
+
# @param [required, String] :text. The text to be used in the template fragment.
|
|
66
|
+
# There are 4 reserved variables available to use as part of the text: ${code}, ${brand}, ${time-limit} and ${time-limit-unit}
|
|
67
|
+
#
|
|
68
|
+
# @return [Response]
|
|
69
|
+
#
|
|
70
|
+
# @see https://developer.vonage.com/en/api/verify.v2#addTemplateFragmentToTemplate
|
|
71
|
+
def create(template_id:, channel:, locale:, text:)
|
|
72
|
+
raise ArgumentError, "Invalid 'channel' #{channel}. Must be one of #{CHANNELS.join(', ')}" unless CHANNELS.include?(channel)
|
|
73
|
+
request(
|
|
74
|
+
"/v2/verify/templates/#{template_id}/template_fragments",
|
|
75
|
+
params: {
|
|
76
|
+
channel: channel,
|
|
77
|
+
locale: locale,
|
|
78
|
+
text: text
|
|
79
|
+
},
|
|
80
|
+
type: Post)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Update an existing template fragment.
|
|
84
|
+
#
|
|
85
|
+
# @example
|
|
86
|
+
# client.verify2.template_fragments.update(
|
|
87
|
+
# template_id: '8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9',
|
|
88
|
+
# template_fragment_id: 'c70f446e-997a-4313-a081-60a02a31dc19',
|
|
89
|
+
# text: 'Your one-time code is: ${code}'
|
|
90
|
+
# )
|
|
91
|
+
#
|
|
92
|
+
# @param [required, String] :template_id. The ID of the template with which the fragment to be updated is associated
|
|
93
|
+
#
|
|
94
|
+
# @param [required, String] :template_fragment_id. The ID of the fragment to be updated
|
|
95
|
+
#
|
|
96
|
+
# @param [required, String] :text. The text to be used in the template fragment.
|
|
97
|
+
# There are 4 reserved variables available to use as part of the text: ${code}, ${brand}, ${time-limit} and ${time-limit-unit}
|
|
98
|
+
#
|
|
99
|
+
# @return [Response]
|
|
100
|
+
#
|
|
101
|
+
# @see https://developer.vonage.com/en/api/verify.v2#updateTemplateFragment
|
|
102
|
+
def update(template_id:, template_fragment_id:, text:)
|
|
103
|
+
request("/v2/verify/templates/#{template_id}/template_fragments/#{template_fragment_id}", params: {text: text}, type: Patch)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Delete a template fragment.
|
|
107
|
+
#
|
|
108
|
+
# @example
|
|
109
|
+
# client.verify2.template_fragments.delete(
|
|
110
|
+
# template_id: '8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9',
|
|
111
|
+
# template_fragment_id: 'c70f446e-997a-4313-a081-60a02a31dc19'
|
|
112
|
+
# )
|
|
113
|
+
#
|
|
114
|
+
# @param [required, String] :template_id. The ID of the template with which the fragment to be deleted is associated
|
|
115
|
+
#
|
|
116
|
+
# @param [required, String] :template_fragment_id. The ID of the fragment to be deleted
|
|
117
|
+
#
|
|
118
|
+
# @return [Response]
|
|
119
|
+
#
|
|
120
|
+
# @see https://developer.vonage.com/en/api/verify.v2#deleteTemplateFragment
|
|
121
|
+
def delete(template_id:, template_fragment_id:)
|
|
122
|
+
request("/v2/verify/templates/#{template_id}/template_fragments/#{template_fragment_id}", type: Delete)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|