Package com.nexmo.client.verify
Class VerifyClient
- java.lang.Object
-
- com.nexmo.client.AbstractClient
-
- com.nexmo.client.verify.VerifyClient
-
public class VerifyClient extends AbstractClient
A client for talking to the Nexmo Verify API. The standard way to obtain an instance of this class is to useNexmoClient.getVerifyClient().Send a verification request with a call to
verify, confirm the code entered by the user withcheck, and search in-progress or completed verification requests withsearchMore information on method parameters can be found at Nexmo website: https://docs.nexmo.com/verify
-
-
Field Summary
-
Fields inherited from class com.nexmo.client.AbstractClient
httpWrapper
-
-
Constructor Summary
Constructors Constructor Description VerifyClient(HttpWrapper httpWrapper)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ControlResponseadvanceVerification(java.lang.String requestId)Advance a current verification request to the next stage in the process.ControlResponsecancelVerification(java.lang.String requestId)Cancel a current verification request.CheckResponsecheck(java.lang.String requestId, java.lang.String code)Validate a code provided by a user in response to a call fromverify.CheckResponsecheck(java.lang.String requestId, java.lang.String code, java.lang.String ipAddress)Validate a code provided by a user in response to a call fromverify.SearchVerifyResponsesearch(java.lang.String requestId)Search for a previous verification request.SearchVerifyResponsesearch(java.lang.String... requestIds)Search for a previous verification request.VerifyResponseverify(VerifyRequest request)Send a verification request to a phone number.VerifyResponseverify(java.lang.String number, java.lang.String brand)Send a verification request to a phone number.VerifyResponseverify(java.lang.String number, java.lang.String brand, java.lang.String from)Send a verification request to a phone number.VerifyResponseverify(java.lang.String number, java.lang.String brand, java.lang.String from, int length, java.util.Locale locale)Send a verification request to a phone number.VerifyResponseverify(java.lang.String number, java.lang.String brand, java.lang.String from, int length, java.util.Locale locale, VerifyRequest.LineType type)Send a verification request to a phone number.
-
-
-
Constructor Detail
-
VerifyClient
public VerifyClient(HttpWrapper httpWrapper)
Constructor.- Parameters:
httpWrapper- (required) shared HTTP wrapper object used for making REST calls.
-
-
Method Detail
-
verify
public VerifyResponse verify(java.lang.String number, java.lang.String brand) throws NexmoResponseParseException, NexmoClientException
Send a verification request to a phone number.- Parameters:
number- (required) The recipient's phone number in E.164 format.brand- (required) The name of the company or app to be verified for. Must not be longer than 18 characters.- Returns:
- a VerifyResponse representing the response received from the Verify API call.
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.
-
verify
public VerifyResponse verify(java.lang.String number, java.lang.String brand, java.lang.String from) throws java.io.IOException, NexmoClientException
Send a verification request to a phone number.- Parameters:
number- (required) The recipient's phone number in E.164 format.brand- (required) The name of the company or app to be verified for. Must not be longer than 18 characters.from- (optional The Nexmo number to use as the sender for the verification SMS message and calls, in E.164 format.- Returns:
- a VerifyResponse representing the response received from the Verify API call.
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.java.io.IOException
-
verify
public VerifyResponse verify(java.lang.String number, java.lang.String brand, java.lang.String from, int length, java.util.Locale locale) throws java.io.IOException, NexmoClientException
Send a verification request to a phone number.- Parameters:
number- (required) The recipient's phone number in E.164 format.brand- (required) The name of the company or app to be verified for. Must not be longer than 18 characters.from- (optional The Nexmo number to use as the sender for the verification SMS message and calls, in E.164 format.length- (optional) The length of the verification code to be sent to the user. Must be either 4 or 6. Use -1 to use the default value.locale- (optional) Override the default locale used for verification. By default the locale is determined from the country code included innumber- Returns:
- a VerifyResponse representing the response received from the Verify API call.
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.java.io.IOException
-
verify
public VerifyResponse verify(java.lang.String number, java.lang.String brand, java.lang.String from, int length, java.util.Locale locale, VerifyRequest.LineType type) throws java.io.IOException, NexmoClientException
Send a verification request to a phone number.- Parameters:
number- (required) The recipient's phone number in E.164 format.brand- (required) The name of the company or app to be verified for. Must not be longer than 18 characters.from- (optional The Nexmo number to use as the sender for the verification SMS message and calls, in E.164 format.length- (optional) The length of the verification code to be sent to the user. Must be either 4 or 6. Use -1 to use the default value.locale- (optional) Override the default locale used for verification. By default the locale is determined from the country code included innumbertype- (optional) If provided, restrict the verification to the specified network type. Contact support@nexmo.com to enable this feature.- Returns:
- a VerifyResponse representing the response received from the Verify API call.
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.java.io.IOException
-
verify
public VerifyResponse verify(VerifyRequest request) throws java.io.IOException, NexmoClientException
Send a verification request to a phone number.- Throws:
java.io.IOExceptionNexmoClientException
-
check
public CheckResponse check(java.lang.String requestId, java.lang.String code) throws java.io.IOException, NexmoClientException
Validate a code provided by a user in response to a call fromverify.- Parameters:
requestId- (required) The requestId returned by theverifycall.code- (required) The code entered by the user.- Returns:
- a CheckResponse representing the response received from the API call.
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.java.io.IOException
-
check
public CheckResponse check(java.lang.String requestId, java.lang.String code, java.lang.String ipAddress) throws java.io.IOException, NexmoClientException
Validate a code provided by a user in response to a call fromverify.- Parameters:
requestId- (required) The requestId returned by theverifycall.code- (required) The code entered by the user.ipAddress- (optional) The IP address obtained from the HTTP request made when the user entered their code.- Returns:
- a CheckResponse representing the response received from the API call.
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.java.io.IOException
-
search
public SearchVerifyResponse search(java.lang.String requestId) throws java.io.IOException, NexmoClientException
Search for a previous verification request.- Parameters:
requestId- The requestId of a single Verify request to be looked up.- Returns:
- A SearchVerifyResponse containing the details of the Verify request that was looked up, or
nullif no record was found. - Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.java.io.IOException
-
search
public SearchVerifyResponse search(java.lang.String... requestIds) throws java.io.IOException, NexmoClientException
Search for a previous verification request.- Parameters:
requestIds- The requestIds of Verify requests to be looked up.- Returns:
- An array SearchVerifyResponse for each record that was found.
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.java.io.IOException
-
advanceVerification
public ControlResponse advanceVerification(java.lang.String requestId) throws java.io.IOException, NexmoClientException
Advance a current verification request to the next stage in the process.- Parameters:
requestId- The requestId of the ongoing verification request.- Returns:
- A
ControlResponserepresenting the response from the API. - Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.java.io.IOException
-
cancelVerification
public ControlResponse cancelVerification(java.lang.String requestId) throws java.io.IOException, NexmoClientException
Cancel a current verification request.- Parameters:
requestId- The requestId of the ongoing verification request.- Returns:
- A
ControlResponserepresenting the response from the API. - Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.java.io.IOException
-
-