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,186 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Vonage
|
|
5
|
+
class ProactiveConnect::List < Namespace
|
|
6
|
+
extend T::Sig
|
|
7
|
+
|
|
8
|
+
self.authentication = BearerToken
|
|
9
|
+
|
|
10
|
+
self.host = :vonage_host
|
|
11
|
+
|
|
12
|
+
self.request_body = JSON
|
|
13
|
+
|
|
14
|
+
# Create list
|
|
15
|
+
#
|
|
16
|
+
# @deprecated
|
|
17
|
+
#
|
|
18
|
+
# @example
|
|
19
|
+
# response = proactive_connect.list.create(name: 'List Number 1')
|
|
20
|
+
#
|
|
21
|
+
# @param [required, String] :name
|
|
22
|
+
# A name for the list
|
|
23
|
+
#
|
|
24
|
+
# @param [optional, String] :description
|
|
25
|
+
# A description of the list
|
|
26
|
+
#
|
|
27
|
+
# @param [optional, Array] :tags
|
|
28
|
+
# An Array of up to 10 Strings assigining tags to the list. Each String must be between 1 and 15 characters
|
|
29
|
+
#
|
|
30
|
+
# @param [optional, Array] :attributes
|
|
31
|
+
# Array of Hash objects. Each Hash represents an attribute for the list.
|
|
32
|
+
#
|
|
33
|
+
# @option attributes [required, String] :name
|
|
34
|
+
# The name of the attribute
|
|
35
|
+
#
|
|
36
|
+
# @option attributes [optional, String] :alias
|
|
37
|
+
# Alternative name to use for this attribute.
|
|
38
|
+
# Use when you wish to correlate between 2 or more list that are using different attribute names for the same semantic data
|
|
39
|
+
#
|
|
40
|
+
# @option attributes [optional, Boolean] :key
|
|
41
|
+
# Set to `true` if this attribute should be used to correlate between 2 or more lists. Default is `false`
|
|
42
|
+
#
|
|
43
|
+
# @param [optional, Hash] :datasource
|
|
44
|
+
# Datasource for the list
|
|
45
|
+
#
|
|
46
|
+
# @option datasource [required, String] :type
|
|
47
|
+
# Must be set to `manual`, which is the default
|
|
48
|
+
#
|
|
49
|
+
# @see https://developer.vonage.com/en/api/proactive-connect#listsCreate
|
|
50
|
+
#
|
|
51
|
+
def create(name:, **params)
|
|
52
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
53
|
+
request(
|
|
54
|
+
"/v0.1/bulk/lists",
|
|
55
|
+
params: params.merge({ name: name }),
|
|
56
|
+
type: Post
|
|
57
|
+
)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Get list by id
|
|
61
|
+
#
|
|
62
|
+
# @deprecated
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
# response = proactive_connect.list.find(id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
|
|
66
|
+
#
|
|
67
|
+
# @param [required, String] :id
|
|
68
|
+
# Unique identifier for the list
|
|
69
|
+
#
|
|
70
|
+
# @see https://developer.vonage.com/en/api/proactive-connect#listsGet
|
|
71
|
+
#
|
|
72
|
+
def find(id:)
|
|
73
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
74
|
+
request("/v0.1/bulk/lists/#{id}")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Update list
|
|
78
|
+
#
|
|
79
|
+
# @deprecated
|
|
80
|
+
#
|
|
81
|
+
# @example
|
|
82
|
+
# response = proactive_connect.list.update(name: 'List Number 1')
|
|
83
|
+
#
|
|
84
|
+
# @param [required, String] :id
|
|
85
|
+
# The id of the list to update
|
|
86
|
+
#
|
|
87
|
+
# @param [required, String] :name
|
|
88
|
+
# The name of the list
|
|
89
|
+
#
|
|
90
|
+
# @param [optional, String] :description
|
|
91
|
+
# A description of the list
|
|
92
|
+
#
|
|
93
|
+
# @param [optional, Array] :tags
|
|
94
|
+
# An Array of up to 10 Strings assigining tags to the list. Each String must be between 1 and 15 characters
|
|
95
|
+
#
|
|
96
|
+
# @param [optional, Array] :attributes
|
|
97
|
+
# Array of Hash objects. Each Hash represents an attribute for the list.
|
|
98
|
+
#
|
|
99
|
+
# @option attributes [required, String] :name
|
|
100
|
+
# The name of the attribute
|
|
101
|
+
#
|
|
102
|
+
# @option attributes [optional, String] :alias
|
|
103
|
+
# Alternative name to use for this attribute.
|
|
104
|
+
# Use when you wish to correlate between 2 or more list that are using different attribute names for the same semantic data
|
|
105
|
+
#
|
|
106
|
+
# @option attributes [optional, Boolean] :key
|
|
107
|
+
# Set to `true` if this attribute should be used to correlate between 2 or more lists. Default is `false`
|
|
108
|
+
#
|
|
109
|
+
# @param [optional, Hash] :datasource
|
|
110
|
+
# Datasource for the list
|
|
111
|
+
#
|
|
112
|
+
# @option datasource [required, String] :type
|
|
113
|
+
# Must be set to `manual`, which is the default
|
|
114
|
+
#
|
|
115
|
+
# @see https://developer.vonage.com/en/api/proactive-connect#listsUpdate
|
|
116
|
+
#
|
|
117
|
+
def update(id:, name:, **params)
|
|
118
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
119
|
+
request(
|
|
120
|
+
"/v0.1/bulk/lists/#{id}",
|
|
121
|
+
params: params.merge({ name: name }),
|
|
122
|
+
type: Put
|
|
123
|
+
)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Delete a list by id
|
|
127
|
+
#
|
|
128
|
+
# @deprecated
|
|
129
|
+
#
|
|
130
|
+
# @example
|
|
131
|
+
# response = proactive_connect.list.delete(id: '74ea1ecf-06c9-4072-a285-61677bd353e8')
|
|
132
|
+
#
|
|
133
|
+
# @param [required, String] :id
|
|
134
|
+
# Unique identifier for the list
|
|
135
|
+
#
|
|
136
|
+
# @see https://developer.vonage.com/en/api/proactive-connect#listsDelete
|
|
137
|
+
#
|
|
138
|
+
def delete(id:)
|
|
139
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
140
|
+
request(
|
|
141
|
+
"/v0.1/bulk/lists/#{id}",
|
|
142
|
+
type: Delete
|
|
143
|
+
)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Clear list by deleting all items
|
|
147
|
+
#
|
|
148
|
+
# @deprecated
|
|
149
|
+
#
|
|
150
|
+
# @example
|
|
151
|
+
# response = proactive_connect.list.clear_items(id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
|
|
152
|
+
#
|
|
153
|
+
# @param [required, String] :id
|
|
154
|
+
# Unique identifier for the list
|
|
155
|
+
#
|
|
156
|
+
# @see https://developer.vonage.com/en/api/proactive-connect#listsClear
|
|
157
|
+
#
|
|
158
|
+
def clear_items(id:)
|
|
159
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
160
|
+
request(
|
|
161
|
+
"/v0.1/bulk/lists/#{id}/clear",
|
|
162
|
+
type: Post
|
|
163
|
+
)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Fetch and replace all items from datasource
|
|
167
|
+
#
|
|
168
|
+
# @deprecated
|
|
169
|
+
#
|
|
170
|
+
# @example
|
|
171
|
+
# response = proactive_connect.list.fetch_and_replace_items(id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
|
|
172
|
+
#
|
|
173
|
+
# @param [required, String] :id
|
|
174
|
+
# Unique identifier for the list
|
|
175
|
+
#
|
|
176
|
+
# @see https://developer.vonage.com/en/api/proactive-connect#listsFetch
|
|
177
|
+
#
|
|
178
|
+
def fetch_and_replace_items(id:)
|
|
179
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
180
|
+
request(
|
|
181
|
+
"/v0.1/bulk/lists/#{id}/fetch",
|
|
182
|
+
type: Post
|
|
183
|
+
)
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Vonage
|
|
5
|
+
class ProactiveConnect::Lists < Namespace
|
|
6
|
+
extend T::Sig
|
|
7
|
+
|
|
8
|
+
self.authentication = BearerToken
|
|
9
|
+
|
|
10
|
+
self.host = :vonage_host
|
|
11
|
+
|
|
12
|
+
# Find all lists
|
|
13
|
+
#
|
|
14
|
+
# @deprecated
|
|
15
|
+
#
|
|
16
|
+
# @example
|
|
17
|
+
# response = proactive_connect.lists.list
|
|
18
|
+
#
|
|
19
|
+
# @param [optional, String] :page
|
|
20
|
+
# Page of results to jump to
|
|
21
|
+
#
|
|
22
|
+
# @param [optional, String] :page_size
|
|
23
|
+
# Number of results per page
|
|
24
|
+
#
|
|
25
|
+
# @param [optional, String] order
|
|
26
|
+
# Sort in either ascending (asc, the default) or descending (desc) order
|
|
27
|
+
#
|
|
28
|
+
# @see https://developer.vonage.com/en/api/proactive-connect#listsFindAll
|
|
29
|
+
#
|
|
30
|
+
def list(**params)
|
|
31
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
32
|
+
path = "/v0.1/bulk/lists"
|
|
33
|
+
path += "?#{Params.encode(params)}" unless params.empty?
|
|
34
|
+
|
|
35
|
+
request(path, response_class: ListResponse)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Vonage
|
|
5
|
+
class ProactiveConnect < Namespace
|
|
6
|
+
extend T::Sig
|
|
7
|
+
|
|
8
|
+
# @deprecated
|
|
9
|
+
sig { returns(T.nilable(Vonage::ProactiveConnect::Lists)) }
|
|
10
|
+
def lists
|
|
11
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
12
|
+
@lists ||= Lists.new(@config)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @deprecated
|
|
16
|
+
sig { returns(T.nilable(Vonage::ProactiveConnect::List)) }
|
|
17
|
+
def list
|
|
18
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
19
|
+
@list ||= List.new(@config)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @deprecated
|
|
23
|
+
sig { returns(T.nilable(Vonage::ProactiveConnect::Items)) }
|
|
24
|
+
def items
|
|
25
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
26
|
+
@items ||= Items.new(@config)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @deprecated
|
|
30
|
+
sig { returns(T.nilable(Vonage::ProactiveConnect::Item)) }
|
|
31
|
+
def item
|
|
32
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
33
|
+
@item ||= Item.new(@config)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @deprecated
|
|
37
|
+
sig { returns(T.nilable(Vonage::ProactiveConnect::Events)) }
|
|
38
|
+
def events
|
|
39
|
+
logger.info('This method is deprecated and will be removed in a future release.')
|
|
40
|
+
@events ||= Events.new(@config)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/lib/vonage/server_error.rb
CHANGED
data/lib/vonage/signature.rb
CHANGED
|
@@ -10,6 +10,29 @@ module Vonage
|
|
|
10
10
|
@config = config
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
# Generate a request signature.
|
|
14
|
+
#
|
|
15
|
+
# @example
|
|
16
|
+
# client = Vonage::Client.new
|
|
17
|
+
# client.config.signature_secret = 'secret'
|
|
18
|
+
# client.config.signature_method = 'sha512'
|
|
19
|
+
# params = {
|
|
20
|
+
# 'api_key' => 'abc123',
|
|
21
|
+
# 'to' => '447900000000',
|
|
22
|
+
# 'from' => '447900000001',
|
|
23
|
+
# 'text' => 'Hello World',
|
|
24
|
+
# 'timestamp' => '1385047698'
|
|
25
|
+
# }
|
|
26
|
+
#
|
|
27
|
+
# sig = client.signature.generate(params)
|
|
28
|
+
#
|
|
29
|
+
# @param [Hash] params
|
|
30
|
+
#
|
|
31
|
+
# @see https://developer.nexmo.com/concepts/guides/signing-messages
|
|
32
|
+
def generate(params, signature_secret: @config.signature_secret, signature_method: @config.signature_method)
|
|
33
|
+
digest(params, signature_secret, signature_method)
|
|
34
|
+
end
|
|
35
|
+
|
|
13
36
|
# Check webhook request signature.
|
|
14
37
|
#
|
|
15
38
|
# @example
|
|
@@ -27,24 +50,24 @@ module Vonage
|
|
|
27
50
|
#
|
|
28
51
|
# @see https://developer.nexmo.com/concepts/guides/signing-messages
|
|
29
52
|
#
|
|
30
|
-
def check(params, signature_method: @config.signature_method)
|
|
53
|
+
def check(params, signature_secret: @config.signature_secret, signature_method: @config.signature_method)
|
|
31
54
|
params = params.dup
|
|
32
55
|
|
|
33
56
|
signature = params.delete('sig')
|
|
34
57
|
|
|
35
|
-
::JWT::
|
|
58
|
+
::JWT::JWA::Hmac::SecurityUtils.secure_compare(signature, digest(params, signature_secret, signature_method))
|
|
36
59
|
end
|
|
37
60
|
|
|
38
61
|
private
|
|
39
62
|
|
|
40
|
-
def digest(params, signature_method)
|
|
41
|
-
digest_string = params.sort.map { |k, v| "&#{k}=#{v.tr('&=', '_')}" }.join
|
|
63
|
+
def digest(params, signature_secret, signature_method)
|
|
64
|
+
digest_string = params.sort.map { |k, v| "&#{k}=#{v.to_s.tr('&=', '_')}" }.join
|
|
42
65
|
|
|
43
66
|
case signature_method
|
|
44
67
|
when 'md5', 'sha1', 'sha256', 'sha512'
|
|
45
|
-
OpenSSL::HMAC.hexdigest(signature_method,
|
|
68
|
+
OpenSSL::HMAC.hexdigest(signature_method, signature_secret, digest_string).upcase
|
|
46
69
|
when 'md5hash'
|
|
47
|
-
Digest::MD5.hexdigest("#{digest_string}#{
|
|
70
|
+
Digest::MD5.hexdigest("#{digest_string}#{signature_secret}")
|
|
48
71
|
else
|
|
49
72
|
raise ArgumentError, "Unknown signature algorithm: #{signature_method}. Expected: md5hash, md5, sha1, sha256, or sha512."
|
|
50
73
|
end
|
data/lib/vonage/sms.rb
CHANGED
|
@@ -6,6 +6,8 @@ module Vonage
|
|
|
6
6
|
extend T::Sig
|
|
7
7
|
include Keys
|
|
8
8
|
|
|
9
|
+
self.authentication = BasicAndSignature
|
|
10
|
+
|
|
9
11
|
self.host = :rest_host
|
|
10
12
|
|
|
11
13
|
# Send an outbound SMS from your Vonage account.
|
|
@@ -66,6 +68,9 @@ module Vonage
|
|
|
66
68
|
# An optional string used to identify separate accounts using the SMS endpoint for billing purposes.
|
|
67
69
|
# To use this feature, please email [support@nexmo.com](mailto:support@nexmo.com).
|
|
68
70
|
#
|
|
71
|
+
# @option params [String] :trusted_number
|
|
72
|
+
# Setting this parameter to true overrides, on a per-message basis, any protections set up via Fraud Defender (Traffic Rules, SMS Burst Protection, AIT Protection).
|
|
73
|
+
#
|
|
69
74
|
# @param [Hash] params
|
|
70
75
|
#
|
|
71
76
|
# @return [Response]
|
|
@@ -91,11 +96,31 @@ module Vonage
|
|
|
91
96
|
response
|
|
92
97
|
end
|
|
93
98
|
|
|
99
|
+
# Validate a Signature from an SMS API Webhook.
|
|
100
|
+
#
|
|
101
|
+
# @param [Hash, required] :webhook_params The parameters from the webhook request body
|
|
102
|
+
# @param [String, optional] :signature_secret The account signature secret. Required, unless `signature_secret`
|
|
103
|
+
# is set in `Config`
|
|
104
|
+
# @param [String, optional] :signature_method The account signature method. Required, unless `signature_method`
|
|
105
|
+
# is set in `Config`
|
|
106
|
+
#
|
|
107
|
+
# @return [Boolean] true, if the JWT is verified, false otherwise
|
|
108
|
+
def verify_webhook_sig(webhook_params:, signature_secret: @config.signature_secret, signature_method: @config.signature_method)
|
|
109
|
+
signature.check(webhook_params, signature_secret: signature_secret, signature_method: signature_method)
|
|
110
|
+
end
|
|
111
|
+
|
|
94
112
|
private
|
|
95
113
|
|
|
96
114
|
sig { params(text: String).returns(T::Boolean) }
|
|
97
115
|
def unicode?(text)
|
|
98
116
|
!Vonage::GSM7.encoded?(text)
|
|
99
117
|
end
|
|
118
|
+
|
|
119
|
+
# @return [Signature]
|
|
120
|
+
#
|
|
121
|
+
sig { returns(T.nilable(Vonage::Signature)) }
|
|
122
|
+
def signature
|
|
123
|
+
@signature ||= T.let(Signature.new(@config), T.nilable(Vonage::Signature))
|
|
124
|
+
end
|
|
100
125
|
end
|
|
101
126
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
|
|
3
|
+
class Vonage::Subaccounts::ListResponse < Vonage::Response
|
|
4
|
+
include Enumerable
|
|
5
|
+
|
|
6
|
+
def primary_account
|
|
7
|
+
@entity._embedded.primary_account
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def each
|
|
11
|
+
return enum_for(:each) unless block_given?
|
|
12
|
+
|
|
13
|
+
@entity._embedded.subaccounts.each { |item| yield item }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Vonage
|
|
5
|
+
class Subaccounts < Namespace
|
|
6
|
+
self.authentication = Basic
|
|
7
|
+
|
|
8
|
+
self.request_body = JSON
|
|
9
|
+
|
|
10
|
+
# Retrieve list of subaccounts.
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
# response = client.subaccounts.list
|
|
14
|
+
#
|
|
15
|
+
# @see https://developer.vonage.com/en/api/subaccounts#retrieveSubaccountsList
|
|
16
|
+
#
|
|
17
|
+
def list
|
|
18
|
+
request("/accounts/#{@config.api_key}/subaccounts", response_class: ListResponse)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Retrieve a subaccount.
|
|
22
|
+
#
|
|
23
|
+
# @example
|
|
24
|
+
# response = client.subaccounts.find(subaccount_key: 'abc123')
|
|
25
|
+
#
|
|
26
|
+
# @option params [required, String] :subaccount_key
|
|
27
|
+
# The API key for the subaccount you want to retrieve
|
|
28
|
+
#
|
|
29
|
+
# @see https://developer.vonage.com/en/api/subaccounts#retrieveSubaccount
|
|
30
|
+
#
|
|
31
|
+
def find(subaccount_key:)
|
|
32
|
+
request("/accounts/#{@config.api_key}/subaccounts/#{subaccount_key}")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Create a subaccount.
|
|
36
|
+
#
|
|
37
|
+
# @example
|
|
38
|
+
# response = client.subaccounts.create(name: 'Foo')
|
|
39
|
+
#
|
|
40
|
+
# @option params [required, String] :name
|
|
41
|
+
# The name of the subaccount
|
|
42
|
+
#
|
|
43
|
+
# @option params [optional, String] :secret
|
|
44
|
+
# An account secret for use by the subaccount. Can be used in combination with your API key to authenticate your API requests.
|
|
45
|
+
# Requirements:
|
|
46
|
+
# - 8 characters and no more than 25
|
|
47
|
+
# - 1 lower-case letter
|
|
48
|
+
# - 1 capital letter
|
|
49
|
+
# - 1 digit
|
|
50
|
+
# - must be unique
|
|
51
|
+
#
|
|
52
|
+
# @option params [optional, Boolean] :use_primary_account_balance
|
|
53
|
+
# Whether the subaccount uses the primary account balance (true, the default) or has its own balance (false).
|
|
54
|
+
# Once set to `false` cannot be changed back to `true`
|
|
55
|
+
#
|
|
56
|
+
# @see https://developer.vonage.com/en/api/subaccounts#createSubAccount
|
|
57
|
+
#
|
|
58
|
+
def create(name:, **params)
|
|
59
|
+
request("/accounts/#{@config.api_key}/subaccounts", params: params.merge(name: name), type: Post)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Modify a subaccount.
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
# response = client.subaccounts.update(name: 'Bar')
|
|
66
|
+
#
|
|
67
|
+
# @option params [required, String] :subaccount_key
|
|
68
|
+
# The API key for the subaccount you want to modify
|
|
69
|
+
#
|
|
70
|
+
# @option params [optional, String] :name
|
|
71
|
+
# The name of the subaccount
|
|
72
|
+
#
|
|
73
|
+
# @option params [optional, Boolean] :use_primary_account_balance
|
|
74
|
+
# Whether the subaccount uses the primary account balance (true, the default) or has its own balance (false).
|
|
75
|
+
# Once set to `false` cannot be changed back to `true`
|
|
76
|
+
#
|
|
77
|
+
# @option params [optional, String] :suspended
|
|
78
|
+
# Whether the subaccount is suspended (true) or not (false, the default)
|
|
79
|
+
#
|
|
80
|
+
# @see https://developer.vonage.com/en/api/subaccounts#modifySubaccount
|
|
81
|
+
#
|
|
82
|
+
def update(subaccount_key:, **params)
|
|
83
|
+
request("/accounts/#{@config.api_key}/subaccounts/#{subaccount_key}", params: params, type: Patch)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Retrieve list of credit transfers.
|
|
87
|
+
#
|
|
88
|
+
# @example
|
|
89
|
+
# response = client.subaccounts.list_credit_transfers(start_date: "2023-06-15T15:53:50Z")
|
|
90
|
+
#
|
|
91
|
+
# @option params [optional, String] :start_date
|
|
92
|
+
# The ISO format datetime from which to list transfers. Example: 2019-03-02T16:34:49Z.
|
|
93
|
+
# Defaults to "1970-01-01T00:00:00Z" if omitted
|
|
94
|
+
#
|
|
95
|
+
# @option params [optional, String] :end_date
|
|
96
|
+
# The ISO format datetime to which to list transfers. Example: 2019-03-02T16:34:49Z.
|
|
97
|
+
# If absent then all transfers until now is returned.
|
|
98
|
+
#
|
|
99
|
+
# @option params [optional, String] :subaccount
|
|
100
|
+
# Subaccount to filter by.
|
|
101
|
+
#
|
|
102
|
+
# @see https://developer.vonage.com/en/api/subaccounts#retrieveCreditTransfers
|
|
103
|
+
#
|
|
104
|
+
def list_credit_transfers(start_date: "1970-01-01T00:00:00Z", **params)
|
|
105
|
+
path = "/accounts/#{@config.api_key}/credit-transfers?#{Params.encode(params.merge(start_date: start_date))}"
|
|
106
|
+
|
|
107
|
+
request(path, response_class: CreditTransfers::ListResponse)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Transfer credit.
|
|
111
|
+
#
|
|
112
|
+
# @example
|
|
113
|
+
# response = client.subaccounts.transfer_credit(from: 'abc123', to: 'def456', amount: 10.00)
|
|
114
|
+
#
|
|
115
|
+
# @option params [required, String] :from
|
|
116
|
+
# The API key of the account or subaccount to transfer credit from.
|
|
117
|
+
#
|
|
118
|
+
# @option params [required, String] :to
|
|
119
|
+
# The API key of the account or subaccount to transfer credit to.
|
|
120
|
+
#
|
|
121
|
+
# @option params [required, Number] :amount
|
|
122
|
+
# The amount to transfer
|
|
123
|
+
#
|
|
124
|
+
# @option params [optional, String] :reference
|
|
125
|
+
# A reference for the transfer.
|
|
126
|
+
#
|
|
127
|
+
# @see https://developer.vonage.com/en/api/subaccounts#transferCredit
|
|
128
|
+
#
|
|
129
|
+
def transfer_credit(from:, to:, amount:, **params)
|
|
130
|
+
request("/accounts/#{@config.api_key}/credit-transfers", params: params.merge(from: from, to: to, amount: amount), type: Post)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Retrieve list of balance transfers.
|
|
134
|
+
#
|
|
135
|
+
# @example
|
|
136
|
+
# response = client.subaccounts.list_balance_transfers(start_date: "2023-06-15T15:53:50Z")
|
|
137
|
+
#
|
|
138
|
+
# @option params [optional, String] :start_date
|
|
139
|
+
# The ISO format datetime from which to list transfers. Example: 2019-03-02T16:34:49Z.
|
|
140
|
+
# Defaults to "1970-01-01T00:00:00Z" if omitted
|
|
141
|
+
#
|
|
142
|
+
# @option params [optional, String] :end_date
|
|
143
|
+
# The ISO format datetime to which to list transfers. Example: 2019-03-02T16:34:49Z.
|
|
144
|
+
# If absent then all transfers until now is returned.
|
|
145
|
+
#
|
|
146
|
+
# @option params [optional, String] :subaccount
|
|
147
|
+
# Subaccount to filter by.
|
|
148
|
+
#
|
|
149
|
+
# @see https://developer.vonage.com/en/api/subaccounts#retrieveBalanceTransfers
|
|
150
|
+
#
|
|
151
|
+
def list_balance_transfers(start_date: "1970-01-01T00:00:00Z", **params)
|
|
152
|
+
path = "/accounts/#{@config.api_key}/balance-transfers?#{Params.encode(params.merge(start_date: start_date))}"
|
|
153
|
+
|
|
154
|
+
request(path, response_class: BalanceTransfers::ListResponse)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Transfer balance.
|
|
158
|
+
#
|
|
159
|
+
# @example
|
|
160
|
+
# response = client.subaccounts.transfer_balance(from: 'abc123', to: 'def456', amount: 10.00)
|
|
161
|
+
#
|
|
162
|
+
# @option params [required, String] :from
|
|
163
|
+
# The API key of the account or subaccount to transfer balance from.
|
|
164
|
+
#
|
|
165
|
+
# @option params [required, String] :to
|
|
166
|
+
# The API key of the account or subaccount to transfer balance to.
|
|
167
|
+
#
|
|
168
|
+
# @option params [required, Number] :amount
|
|
169
|
+
# The amount to transfer
|
|
170
|
+
#
|
|
171
|
+
# @option params [optional, String] :reference
|
|
172
|
+
# A reference for the transfer.
|
|
173
|
+
#
|
|
174
|
+
# @see https://developer.vonage.com/en/api/subaccounts#transferBalance
|
|
175
|
+
#
|
|
176
|
+
def transfer_balance(from:, to:, amount:, **params)
|
|
177
|
+
request("/accounts/#{@config.api_key}/balance-transfers", params: params.merge(from: from, to: to, amount: amount), type: Post)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Transfer number.
|
|
181
|
+
#
|
|
182
|
+
# @example
|
|
183
|
+
# response = client.subaccounts.transfer_number(from: 'abc123', to: 'def456', number: 447900000000, country: 'GB')
|
|
184
|
+
#
|
|
185
|
+
# @option params [required, String] :from
|
|
186
|
+
# The API key of the account or subaccount to transfer the number from.
|
|
187
|
+
#
|
|
188
|
+
# @option params [required, String] :to
|
|
189
|
+
# The API key of the account or subaccount to transfer the number to.
|
|
190
|
+
#
|
|
191
|
+
# @option params [required, Number] :number
|
|
192
|
+
# The number to transfer
|
|
193
|
+
#
|
|
194
|
+
# @option params [required, String] :country
|
|
195
|
+
# An ISO-3166-1 alpha 2 code representing the country for the number, e.g. GB.
|
|
196
|
+
#
|
|
197
|
+
# @see https://developer.vonage.com/en/api/subaccounts#transferNumber
|
|
198
|
+
#
|
|
199
|
+
def transfer_number(from:, to:, number:, country:)
|
|
200
|
+
request("/accounts/#{@config.api_key}/transfer-number", params: {from: from, to: to, number: number, country: country}, type: Post)
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|