Skip to content

Commit 9f21145

Browse files
committed
Removing hashed option from network number verification
1 parent a972691 commit 9f21145

File tree

2 files changed

+4
-40
lines changed

2 files changed

+4
-40
lines changed

lib/vonage/network_number_verification.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,20 @@ class NetworkNumberVerification < Namespace
3131
# @option auth_data [required, String] :redirect_uri The redirect URI.
3232
# @see https://developer.vonage.com/en/getting-started-network/authentication#client-authentication-flow
3333
#
34-
# @param [required, Boolean] :hashed Whether the value of `phone_number` is hashed (true) or not hashed (false, the default).
35-
#
3634
# @return [Response]
3735
#
3836
# @see https://developer.vonage.com/en/api/camara/number-verification#verifyNumberVerification
3937
#
40-
sig { params(phone_number: String, auth_data: Hash, hashed: T::Boolean).returns(Vonage::Response) }
41-
def verify(phone_number:, auth_data:, hashed: false)
42-
raise ArgumentError.new("`phone_number` must be in E.164 format") unless Phonelib.parse(phone_number).valid? || hashed == true
43-
raise ArgumentError.new("`phone_number` must be prepended with a `+`") unless phone_number.start_with?('+') || hashed == true
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?('+')
4442
raise ArgumentError.new("`auth_data` must contain key `:oidc_auth_code`") unless auth_data.has_key?(:oidc_auth_code)
4543
raise ArgumentError.new("`auth_data[:oidc_auth_code]` must be a String") unless auth_data[:oidc_auth_code].is_a?(String)
4644
raise ArgumentError.new("`auth_data` must contain key `:redirect_uri`") unless auth_data.has_key?(:redirect_uri)
4745
raise ArgumentError.new("`auth_data[:redirect_uri]` must be a String") unless auth_data[:redirect_uri].is_a?(String)
4846

4947
params = {phone_number: phone_number}
50-
params[:hashed_phone_number] = params.delete(:phone_number) if hashed == true
5148

5249
request(
5350
'/camara/number-verification/v031/verify',

test/vonage/network_number_verification_test.rb

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,6 @@ def test_verify_method
4949
assert_kind_of Vonage::Response, response
5050
end
5151

52-
def test_verify_method_with_hashed_phone_number
53-
request_access_token_request_params = {
54-
grant_type: 'authorization_code',
55-
code: example_oidc_auth_code,
56-
redirect_uri: example_redirect_uri
57-
}
58-
59-
number_verification_verify_params = {hashedPhoneNumber: hashed_phone_number}
60-
61-
stub_request(:post, "https://api-eu.vonage.com/oauth2/token").with(request(body: request_access_token_request_params, headers: headers)).to_return(network_authentication_token_response)
62-
stub_request(:post, uri + '/verify').with(body: number_verification_verify_params).to_return(response)
63-
64-
response = network_number_verification.verify(
65-
phone_number: hashed_phone_number,
66-
hashed: true,
67-
auth_data: {
68-
oidc_auth_code: example_oidc_auth_code,
69-
redirect_uri: example_redirect_uri
70-
}
71-
)
72-
73-
assert_kind_of Vonage::Response, response
74-
end
75-
7652
def test_verify_method_without_phone_number
7753
assert_raises(ArgumentError) do
7854
network_number_verification.verify(
@@ -95,15 +71,6 @@ def test_verify_method_with_invalid_phone_number
9571
assert_raises(ArgumentError) { network_number_verification.verify(phone_number: '447904603505', auth_data: auth_data) }
9672
end
9773

98-
def test_verify_method_with_invalid_hashed
99-
auth_data = {
100-
oidc_auth_code: example_oidc_auth_code,
101-
redirect_uri: example_redirect_uri
102-
}
103-
104-
assert_raises(TypeError) { network_number_verification.verify(phone_number: hashed_phone_number, auth_data: auth_data, hashed: 'true') }
105-
end
106-
10774
def test_verify_method_without_auth_data
10875
assert_raises(ArgumentError) { network_number_verification.verify(phone_number: phone_number) }
10976
end

0 commit comments

Comments
 (0)