39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/vonage/network_number_verification.rb', line 39
def verify(phone_number:, auth_data:)
raise ArgumentError.new("`phone_number` must be in E.164 format") unless Phonelib.parse(phone_number).valid?
raise ArgumentError.new("`phone_number` must be prepended with a `+`") unless phone_number.start_with?('+')
raise ArgumentError.new("`auth_data` must contain key `:oidc_auth_code`") unless auth_data.has_key?(:oidc_auth_code)
raise ArgumentError.new("`auth_data[:oidc_auth_code]` must be a String") unless auth_data[:oidc_auth_code].is_a?(String)
raise ArgumentError.new("`auth_data` must contain key `:redirect_uri`") unless auth_data.has_key?(:redirect_uri)
raise ArgumentError.new("`auth_data[:redirect_uri]` must be a String") unless auth_data[:redirect_uri].is_a?(String)
params = {phone_number: phone_number}
request(
'/camara/number-verification/v031/verify',
params: camelcase(params),
type: Post,
auth_data: {
oidc_auth_code: auth_data[:oidc_auth_code],
redirect_uri: auth_data[:redirect_uri],
auth_flow: :client_authentication
}
)
end
|