Class NumberVerificationClient
java.lang.Object
com.vonage.client.camara.NetworkApiClient
com.vonage.client.camara.numberverification.NumberVerificationClient
A client for communicating with the Vonage Number Verification API. The standard way to obtain an instance
of this class is to use
VonageClient.getNumberVerificationClient().-
Field Summary
Fields inherited from class com.vonage.client.camara.NetworkApiClient
networkAuthClient -
Constructor Summary
ConstructorsConstructorDescriptionNumberVerificationClient(HttpWrapper wrapper) Create a new NumberVerificationClient. -
Method Summary
Modifier and TypeMethodDescriptioninitiateVerification(String phoneNumber, URI redirectUrl, String state) Sets up the client for verifying the given phone number.booleanverifyNumber(String code) Exchanges the code for an access token, makes the API call to the Number Verification API's "verify" endpoint and extracts the result.booleanverifyNumber(String phoneNumber, URI redirectUri, String code) Stateless implementation ofverifyNumber(String), which creates a new request without having to callinitiateVerification(String, URI, String)first.Methods inherited from class com.vonage.client.camara.NetworkApiClient
getCamaraBaseUri, setNetworkAuth, setNetworkAuth
-
Constructor Details
-
NumberVerificationClient
Create a new NumberVerificationClient.- Parameters:
wrapper- Http Wrapper used to create requests.
-
-
Method Details
-
initiateVerification
Sets up the client for verifying the given phone number. This method will cache the provided number and redirect URL for verification when callingverifyNumber(String). The intended usage is to call this method first, and follow the returned URL on the target device which the phone number is supposed to be associated with. When the URL is followed, it will trigger an inbound request to theredirectUrlwith two query parameters:CODEandSTATE(if provided as a parameter to this method). The code should then be extracted from the query parameters and passed toverifyNumber(String).- Parameters:
phoneNumber- The MSISDN to verify.redirectUrl- Redirect URL, as set in your Vonage application for Network APIs.state- An optional string for identifying the request. For simplicity, this could be set to the same value asphoneNumber, or it may benull.- Returns:
- A link with appropriate parameters which should be followed on the end user's device.
The link should be followed when using the SIM card associated the provided phone number.
Therefore, on the target device, Wi-Fi should be disabled when doing this, otherwise the result
of
verifyNumber(String)will befalse.
-
verifyNumber
Exchanges the code for an access token, makes the API call to the Number Verification API's "verify" endpoint and extracts the result.- Parameters:
code- The code obtained from the inbound callback's query parameters.- Returns:
trueif the device that followed the link was using the SIM card associated with the phone number provided in initiateVerification(String, URI, String),falseotherwise (e.g. it was unknown, the link was not followed, the device that followed the link didn't use the SIM card with that phone number when doing so).- Throws:
NetworkAuthResponseException- If there was an error exchanging the code for an access token when using the Vonage Network Auth API.CamaraResponseException- If there was an error in communicating with the Number Verification API.
-
verifyNumber
Stateless implementation ofverifyNumber(String), which creates a new request without having to callinitiateVerification(String, URI, String)first. This is useful in cases where concurrent verifications are required, or the URL is obtained another way.- Parameters:
phoneNumber- MSISDN of the target device to verify.redirectUri- Redirect URL, as set in your Vonage application for Network APIs.code- The code obtained from the inbound callback's query parameters.- Returns:
trueif the device that followed the link was using the SIM card associated with the phone number provided in initiateVerification(String, URI, String),falseotherwise (e.g. it was unknown, the link was not followed, the device that followed the link didn't use the SIM card with that phone number when doing so).- Throws:
NetworkAuthResponseException- If there was an error exchanging the code for an access token when using the Vonage Network Auth API.CamaraResponseException- If there was an error in communicating with the Number Verification API.
-