vonage 7.29.1 → 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.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +89 -476
  3. data/lib/vonage/applications.rb +4 -12
  4. data/lib/vonage/basic.rb +1 -1
  5. data/lib/vonage/bearer_token.rb +1 -1
  6. data/lib/vonage/client.rb +0 -65
  7. data/lib/vonage/client_error.rb +1 -1
  8. data/lib/vonage/config.rb +1 -9
  9. data/lib/vonage/conversations/events.rb +0 -12
  10. data/lib/vonage/conversations/legs.rb +0 -6
  11. data/lib/vonage/conversations/members.rb +0 -15
  12. data/lib/vonage/conversations/users.rb +0 -15
  13. data/lib/vonage/conversations.rb +0 -30
  14. data/lib/vonage/errors.rb +20 -37
  15. data/lib/vonage/gsm7.rb +1 -1
  16. data/lib/vonage/http.rb +3 -3
  17. data/lib/vonage/jwt.rb +0 -17
  18. data/lib/vonage/key_secret_params.rb +2 -3
  19. data/lib/vonage/keys.rb +1 -14
  20. data/lib/vonage/logger.rb +3 -5
  21. data/lib/vonage/messaging/channels/viber.rb +2 -9
  22. data/lib/vonage/messaging/channels/whats_app.rb +1 -3
  23. data/lib/vonage/messaging/message.rb +0 -1
  24. data/lib/vonage/messaging.rb +4 -34
  25. data/lib/vonage/namespace.rb +68 -137
  26. data/lib/vonage/numbers.rb +17 -40
  27. data/lib/vonage/server_error.rb +1 -1
  28. data/lib/vonage/signature.rb +5 -5
  29. data/lib/vonage/sms.rb +20 -20
  30. data/lib/vonage/version.rb +1 -1
  31. data/lib/vonage/video/archives.rb +58 -25
  32. data/lib/vonage/video/list_response.rb +11 -0
  33. data/lib/vonage/video/moderation.rb +22 -7
  34. data/lib/vonage/video/signals.rb +9 -4
  35. data/lib/vonage/video/streams.rb +12 -6
  36. data/lib/vonage/video.rb +13 -50
  37. data/lib/vonage/voice/actions/connect.rb +5 -34
  38. data/lib/vonage/voice/actions/conversation.rb +4 -10
  39. data/lib/vonage/voice/actions/input.rb +3 -19
  40. data/lib/vonage/voice/actions/notify.rb +3 -8
  41. data/lib/vonage/voice/actions/pay.rb +107 -0
  42. data/lib/vonage/voice/actions/record.rb +4 -52
  43. data/lib/vonage/voice/actions/stream.rb +4 -48
  44. data/lib/vonage/voice/actions/talk.rb +4 -54
  45. data/lib/vonage/voice/talk.rb +1 -11
  46. data/lib/vonage/voice.rb +0 -24
  47. data/lib/vonage.rb +0 -4
  48. data/vonage.gemspec +1 -3
  49. metadata +12 -108
  50. data/lib/vonage/api_error.rb +0 -33
  51. data/lib/vonage/conversation/event/list_response.rb +0 -11
  52. data/lib/vonage/conversation/event.rb +0 -108
  53. data/lib/vonage/conversation/list_response.rb +0 -11
  54. data/lib/vonage/conversation/member/list_response.rb +0 -11
  55. data/lib/vonage/conversation/member.rb +0 -134
  56. data/lib/vonage/conversation/user/conversations_list_response.rb +0 -11
  57. data/lib/vonage/conversation/user/sessions_list_response.rb +0 -11
  58. data/lib/vonage/conversation/user.rb +0 -67
  59. data/lib/vonage/conversation.rb +0 -164
  60. data/lib/vonage/meetings/applications.rb +0 -28
  61. data/lib/vonage/meetings/dial_in_numbers/list_response.rb +0 -11
  62. data/lib/vonage/meetings/dial_in_numbers.rb +0 -26
  63. data/lib/vonage/meetings/recordings.rb +0 -42
  64. data/lib/vonage/meetings/rooms/list_response.rb +0 -11
  65. data/lib/vonage/meetings/rooms.rb +0 -167
  66. data/lib/vonage/meetings/sessions/list_response.rb +0 -11
  67. data/lib/vonage/meetings/sessions.rb +0 -31
  68. data/lib/vonage/meetings/themes/list_response.rb +0 -11
  69. data/lib/vonage/meetings/themes.rb +0 -239
  70. data/lib/vonage/meetings.rb +0 -50
  71. data/lib/vonage/messaging/channels/rcs.rb +0 -42
  72. data/lib/vonage/network_authentication/client_authentication.rb +0 -39
  73. data/lib/vonage/network_authentication/server_authentication.rb +0 -47
  74. data/lib/vonage/network_authentication.rb +0 -22
  75. data/lib/vonage/network_number_verification.rb +0 -92
  76. data/lib/vonage/network_sim_swap.rb +0 -84
  77. data/lib/vonage/number_insight_2.rb +0 -36
  78. data/lib/vonage/proactive_connect/events/list_response.rb +0 -11
  79. data/lib/vonage/proactive_connect/events.rb +0 -71
  80. data/lib/vonage/proactive_connect/item.rb +0 -116
  81. data/lib/vonage/proactive_connect/items/file_response.rb +0 -32
  82. data/lib/vonage/proactive_connect/items/list_response.rb +0 -11
  83. data/lib/vonage/proactive_connect/items.rb +0 -116
  84. data/lib/vonage/proactive_connect/list.rb +0 -186
  85. data/lib/vonage/proactive_connect/lists/list_response.rb +0 -11
  86. data/lib/vonage/proactive_connect/lists.rb +0 -38
  87. data/lib/vonage/proactive_connect.rb +0 -43
  88. data/lib/vonage/subaccounts/balance_transfers/list_response.rb +0 -11
  89. data/lib/vonage/subaccounts/credit_transfers/list_response.rb +0 -11
  90. data/lib/vonage/subaccounts/list_response.rb +0 -15
  91. data/lib/vonage/subaccounts.rb +0 -203
  92. data/lib/vonage/users/list_response.rb +0 -11
  93. data/lib/vonage/users.rb +0 -156
  94. data/lib/vonage/verify2/channels/email.rb +0 -36
  95. data/lib/vonage/verify2/channels/silent_auth.rb +0 -45
  96. data/lib/vonage/verify2/channels/sms.rb +0 -63
  97. data/lib/vonage/verify2/channels/voice.rb +0 -32
  98. data/lib/vonage/verify2/channels/whats_app.rb +0 -39
  99. data/lib/vonage/verify2/channels/whats_app_interactive.rb +0 -32
  100. data/lib/vonage/verify2/start_verification_options.rb +0 -63
  101. data/lib/vonage/verify2/template_fragments/list_response.rb +0 -11
  102. data/lib/vonage/verify2/template_fragments.rb +0 -125
  103. data/lib/vonage/verify2/templates/list_response.rb +0 -11
  104. data/lib/vonage/verify2/templates.rb +0 -86
  105. data/lib/vonage/verify2/workflow.rb +0 -39
  106. data/lib/vonage/verify2/workflow_builder.rb +0 -25
  107. data/lib/vonage/verify2.rb +0 -112
  108. data/lib/vonage/video/archives/list_response.rb +0 -11
  109. data/lib/vonage/video/broadcasts/list_response.rb +0 -11
  110. data/lib/vonage/video/broadcasts.rb +0 -75
  111. data/lib/vonage/video/captions.rb +0 -67
  112. data/lib/vonage/video/renders/list_response.rb +0 -11
  113. data/lib/vonage/video/renders.rb +0 -107
  114. data/lib/vonage/video/sip.rb +0 -48
  115. data/lib/vonage/video/streams/list_response.rb +0 -11
  116. data/lib/vonage/video/web_socket.rb +0 -61
@@ -1,31 +0,0 @@
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
@@ -1,11 +0,0 @@
1
- # typed: true
2
-
3
- class Vonage::Meetings::Themes::ListResponse < Vonage::Response
4
- include Enumerable
5
-
6
- def each
7
- return enum_for(:each) unless block_given?
8
-
9
- @entity.each { |item| yield item }
10
- end
11
- end
@@ -1,239 +0,0 @@
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
@@ -1,50 +0,0 @@
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
@@ -1,42 +0,0 @@
1
- # typed: true
2
-
3
- module Vonage
4
- class Messaging::Channels::RCS < Messaging::Message
5
- MESSAGE_TYPES = ['text', 'image', 'video', 'file', 'custom']
6
-
7
- attr_reader :data
8
-
9
- def initialize(attributes = {})
10
- @type = attributes.fetch(:type, nil)
11
- @message = attributes.fetch(:message, nil)
12
- @opts = attributes.fetch(:opts, {})
13
- @data = {}
14
-
15
- after_initialize!
16
- end
17
-
18
- private
19
-
20
- def build
21
- data[:channel] = 'rcs'
22
- super
23
- end
24
-
25
- def verify_type
26
- raise ClientError.new("Invalid message type") unless MESSAGE_TYPES.include?(type)
27
- end
28
-
29
- def verify_message
30
- case type
31
- when 'text'
32
- raise Vonage::ClientError.new("Invalid parameter type. `:message` must be a String") unless message.is_a? String
33
- when 'custom'
34
- raise Vonage::ClientError.new("Invalid parameter type. `:message` must be a Hash") unless message.is_a? Hash
35
- raise Vonage::ClientError.new("Invalid parameter content. `:message` must not be empty") if message.empty?
36
- else
37
- raise Vonage::ClientError.new("Invalid parameter type. `:message` must be a Hash") unless message.is_a? Hash
38
- raise Vonage::ClientError.new("Missing parameter. `:message` must contain a `:url` key") unless message[:url]
39
- end
40
- end
41
- end
42
- end
@@ -1,39 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- module Vonage
5
- class NetworkAuthentication::ClientAuthentication < Namespace
6
- extend T::Sig
7
-
8
- self.authentication = BearerToken
9
-
10
- self.host = :vonage_host
11
-
12
- self.request_headers['Content-Type'] = 'application/x-www-form-urlencoded'
13
-
14
- def token(oidc_auth_code:, redirect_uri:, **params)
15
- request(
16
- '/oauth2/token',
17
- params: {
18
- grant_type: 'authorization_code',
19
- code: oidc_auth_code,
20
- redirect_uri: redirect_uri
21
- },
22
- type: Post
23
- ).access_token
24
- end
25
-
26
- def generate_oidc_uri(purpose:, api_scope:, login_hint:, redirect_uri:, state:)
27
- scope = "openid%20dpv:#{purpose}%23#{api_scope}"
28
- uri = "https://oidc.idp.vonage.com/oauth2/auth?" +
29
- "client_id=#{@config.application_id}" +
30
- "&response_type=code" +
31
- "&scope=#{scope}" +
32
- "&login_hint=#{login_hint}" +
33
- "&redirect_uri=#{redirect_uri}" +
34
- "&state=#{state}"
35
-
36
- uri
37
- end
38
- end
39
- end
@@ -1,47 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- module Vonage
5
- class NetworkAuthentication::ServerAuthentication < Namespace
6
- extend T::Sig
7
-
8
- self.authentication = BearerToken
9
-
10
- self.host = :vonage_host
11
-
12
- self.request_headers['Content-Type'] = 'application/x-www-form-urlencoded'
13
-
14
- def token(purpose:, api_scope:, login_hint:, **params)
15
- auth_req_id = bc_authorize(
16
- purpose: purpose,
17
- api_scope: api_scope,
18
- login_hint: login_hint
19
- ).auth_req_id
20
-
21
- request_access_token(auth_req_id: auth_req_id).access_token
22
- end
23
-
24
- def bc_authorize(purpose:, api_scope:, login_hint:)
25
- scope = "openid dpv:#{purpose}##{api_scope}"
26
- request(
27
- "/oauth2/bc-authorize",
28
- params: {
29
- scope: scope,
30
- login_hint: login_hint
31
- },
32
- type: Post
33
- )
34
- end
35
-
36
- def request_access_token(auth_req_id:)
37
- request(
38
- "/oauth2/token",
39
- params: {
40
- grant_type: 'urn:openid:params:grant-type:ciba',
41
- auth_req_id: auth_req_id
42
- },
43
- type: Post
44
- )
45
- end
46
- end
47
- end
@@ -1,22 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- module Vonage
5
- class NetworkAuthentication < AbstractAuthentication
6
- def update(object, data)
7
- return unless object.is_a?(Net::HTTPRequest)
8
-
9
- token = self.public_send(data[:auth_flow]).token(**data)
10
-
11
- object['Authorization'] = 'Bearer ' + token
12
- end
13
-
14
- def client_authentication
15
- @client_authentication ||= ClientAuthentication.new(@config)
16
- end
17
-
18
- def server_authentication
19
- @server_authentication ||= ServerAuthentication.new(@config)
20
- end
21
- end
22
- end
@@ -1,92 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
- require 'phonelib'
4
-
5
- module Vonage
6
- class NetworkNumberVerification < Namespace
7
- extend T::Sig
8
- include Keys
9
-
10
- self.authentication = NetworkAuthentication
11
-
12
- self.host = :vonage_host
13
-
14
- self.request_body = JSON
15
-
16
- # Verifies if the specified phone number (plain text or hashed format) matches the one that the user is currently using.
17
- #
18
- # @example
19
- # response = client.network_number_verification.verify(
20
- # phone_number: '+447900000000',
21
- # auth_data: {
22
- # oidc_auth_code: '0dadaeb4-7c79-4d39-b4b0-5a6cc08bf537',
23
- # redirect_uri: 'https://example.com/callback'
24
- # }
25
- # )
26
- #
27
- # @param [required, String] :phone_number The phone number to check, in the E.164 format, prepended with a `+`.
28
- #
29
- # @param [required, Hash] :auth_data A hash of authentication data required for the client token request. Must contain the following keys:
30
- # @option auth_data [required, String] :oidc_auth_code The OIDC auth code.
31
- # @option auth_data [required, String] :redirect_uri The redirect URI.
32
- # @see https://developer.vonage.com/en/getting-started-network/authentication#client-authentication-flow
33
- #
34
- # @return [Response]
35
- #
36
- # @see https://developer.vonage.com/en/api/camara/number-verification#verifyNumberVerification
37
- #
38
- sig { params(phone_number: String, auth_data: Hash).returns(Vonage::Response) }
39
- def verify(phone_number:, auth_data:)
40
- raise ArgumentError.new("`phone_number` must be in E.164 format") unless Phonelib.parse(phone_number).valid?
41
- raise ArgumentError.new("`phone_number` must be prepended with a `+`") unless phone_number.start_with?('+')
42
- raise ArgumentError.new("`auth_data` must contain key `:oidc_auth_code`") unless auth_data.has_key?(:oidc_auth_code)
43
- raise ArgumentError.new("`auth_data[:oidc_auth_code]` must be a String") unless auth_data[:oidc_auth_code].is_a?(String)
44
- raise ArgumentError.new("`auth_data` must contain key `:redirect_uri`") unless auth_data.has_key?(:redirect_uri)
45
- raise ArgumentError.new("`auth_data[:redirect_uri]` must be a String") unless auth_data[:redirect_uri].is_a?(String)
46
-
47
- params = {phone_number: phone_number}
48
-
49
- request(
50
- '/camara/number-verification/v031/verify',
51
- params: camelcase(params),
52
- type: Post,
53
- auth_data: {
54
- oidc_auth_code: auth_data[:oidc_auth_code],
55
- redirect_uri: auth_data[:redirect_uri],
56
- auth_flow: :client_authentication
57
- }
58
- )
59
- end
60
-
61
- # Creates a URL for a client-side OIDC request.
62
- #
63
- # @example
64
- # response = client.network_number_verification.generate_oidc_uri(
65
- # phone_number: '+447900000000',
66
- # redirect_uri: 'https://example.com/callback'
67
- # )
68
- #
69
- # @param [required, String] :phone_number The phone number that will be checked during the verification request.
70
- #
71
- # @param [required, String] :redirect_uri The URI that will receive the callback containing the OIDC auth code.
72
- #
73
- # @param [required, String] :state A string that you can use for tracking.
74
- # Used to set a unique identifier for each access token you generate.
75
- #
76
- # @return [String]
77
- #
78
- # @see https://developer.vonage.com/en/getting-started-network/authentication#1-make-an-oidc-request
79
- sig { params(phone_number: String, redirect_uri: String, state: String).returns(String) }
80
- def generate_oidc_uri(phone_number:, redirect_uri:, state:)
81
- params = {
82
- purpose: 'FraudPreventionAndDetection',
83
- api_scope: 'number-verification-verify-read',
84
- login_hint: phone_number,
85
- redirect_uri: redirect_uri,
86
- state: state
87
- }
88
-
89
- Vonage::NetworkAuthentication::ClientAuthentication.new(@config).generate_oidc_uri(**params)
90
- end
91
- end
92
- end
@@ -1,84 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
- require 'phonelib'
4
-
5
- module Vonage
6
- class NetworkSIMSwap < Namespace
7
- extend T::Sig
8
- include Keys
9
-
10
- self.authentication = NetworkAuthentication
11
-
12
- self.host = :vonage_host
13
-
14
- self.request_body = JSON
15
-
16
- # Check if SIM swap has been performed during a past period.
17
- #
18
- # @example
19
- # response = client.network_sim_swap.check(phone_number: '+447900000000')
20
- #
21
- # @param [required, String] :phone_number The phone number to check, in the E.164 format, prepended with a `+`.
22
- #
23
- # @param [optional, Integer] :max_age Period in hours to be checked for SIM swap
24
- #
25
- # @return [Response]
26
- #
27
- # @see https://developer.vonage.com/en/api/camara/sim-swap#checkSimSwap
28
- #
29
- sig { params(phone_number: String, max_age: T.nilable(Integer)).returns(Vonage::Response) }
30
- def check(phone_number:, max_age: nil)
31
- raise ArgumentError.new("`phone_number` must be in E.164 format") unless Phonelib.parse(phone_number).valid?
32
- raise ArgumentError.new("`phone_number` must be prepended with a `+`") unless phone_number.start_with?('+')
33
- if max_age
34
- raise ArgumentError.new("`max_age` must between 1 and 2400") unless max_age.between?(1, 2400)
35
- end
36
-
37
- params = {phone_number: phone_number}
38
- params[:max_age] = max_age if max_age
39
-
40
- request(
41
- '/camara/sim-swap/v040/check',
42
- params: camelcase(params),
43
- type: Post,
44
- auth_data: {
45
- login_hint: phone_number,
46
- purpose: 'FraudPreventionAndDetection',
47
- api_scope: 'check-sim-swap',
48
- auth_flow: :server_authentication
49
- }
50
- )
51
- end
52
-
53
- # Get timestamp of last MSISDN <-> IMSI pairing change for a mobile user account provided with MSIDN.
54
- #
55
- # @example
56
- # response = client.network_sim_swap.retrieve_date(phone_number: '+447900000000')
57
- #
58
- # @param [required, String] :phone_number The phone number to check, in the E.164 format, prepended with a `+`.
59
- #
60
- # @return [Response]
61
- #
62
- # @see https://developer.vonage.com/en/api/camara/sim-swap#retrieveSimSwapDate
63
- #
64
- sig { params(phone_number: String).returns(Vonage::Response) }
65
- def retrieve_date(phone_number:)
66
- raise ArgumentError.new("`phone_number` must be in E.164 format") unless Phonelib.parse(phone_number).valid?
67
- raise ArgumentError.new("`phone_number` must be prepended with a `+`") unless phone_number.start_with?('+')
68
-
69
- params = {phone_number: phone_number}
70
-
71
- request(
72
- '/camara/sim-swap/v040/retrieve-date',
73
- params: camelcase(params),
74
- type: Post,
75
- auth_data: {
76
- login_hint: phone_number,
77
- purpose: 'FraudPreventionAndDetection',
78
- api_scope: 'retrieve-sim-swap-date',
79
- auth_flow: :server_authentication
80
- }
81
- )
82
- end
83
- end
84
- end