Package com.vonage.client.verify2
Class Verify2Client
java.lang.Object
com.vonage.client.verify2.Verify2Client
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelVerification(UUID requestId) Attempts to abort an active verification workflow.checkVerificationCode(UUID requestId, String code) Check a supplied code against an existing verification request.createTemplate(String name) Create a new custom template.createTemplateFragment(UUID templateId, TemplateFragment fragment) Create a new template fragment.voiddeleteTemplate(UUID templateId) Delete a template.voiddeleteTemplateFragment(UUID templateId, UUID fragmentId) Delete a template fragment.getTemplate(UUID templateId) Retrieve a specific template.getTemplateFragment(UUID templateId, UUID fragmentId) Retrieve a specific fragment.listTemplateFragments(UUID templateId) List all fragments associated with a template.List all custom templates associated with the account.voidnextWorkflow(UUID requestId) Move the request onto the next workflow, if available.sendVerification(VerificationRequest request) Request a verification be sent to a user.updateTemplate(UUID templateId, String name, Boolean isDefault) Update an existing template.updateTemplateFragment(UUID templateId, UUID fragmentId, String text) Update an existing template fragment.
-
Constructor Details
-
Verify2Client
Create a new Verify2Client.- Parameters:
wrapper- Http Wrapper used to create verification requests.
-
-
Method Details
-
sendVerification
Request a verification be sent to a user. This is the first step in the verification process.- Parameters:
request- Properties of the verification request. You must specify the brand name and at least one contact method (workflow). For example, to verify using Whatsapp and fall back to a voice call as backup to the same number with a 6-digit code and a 3-minute wait between attempts:VerificationRequest.builder() .brand("My Company") .addWorkflow(new WhatsappWorkflow("447000000001")) .addWorkflow(new VoiceWorkflow("447000000001")) .codeLength(6) .channelTimeout(180) .build().- Returns:
- The server's response, if successful.
- Throws:
VerifyResponseException- If the request was unsuccessful. This could be for the following reasons:- 409: Concurrent verifications to the same number are not allowed.
- 422: The value of one or more parameters is invalid.
- 429: Rate limit hit. Please wait and try again.
- 500: An error occurred on the Vonage platform.
-
checkVerificationCode
Check a supplied code against an existing verification request. If the code is valid, this method will return normally. Otherwise, aVerifyResponseExceptionwill be thrown.- Parameters:
requestId- ID of the verify request, obtained fromVerificationResponse.getRequestId().code- The code supplied by the user.- Returns:
- Details of the verification request (if the code matched).
- Throws:
VerifyResponseException- If the code could not be verified. This could be for the following reasons:- 400: The provided code does not match the expected value.
- 401: Invalid credentials.
- 402: Low balance.
- 404: Request ID was not found or it has been verified already.
- 409: The current workflow step does not support a code.
- 410: An incorrect code has been provided too many times.
- 429: Rate limit hit. Please wait and try again.
- 500: An error occurred on the Vonage platform.
-
cancelVerification
Attempts to abort an active verification workflow. If successful (HTTP status 204), this method will return normally. Otherwise, aVerifyResponseExceptionexception will be thrown, indicating a 404 response.- Parameters:
requestId- ID of the verify request, obtained fromVerificationResponse.getRequestId().- Throws:
VerifyResponseException- If the request could not be cancelled. This could be for the following reasons:- 401: Invalid credentials.
- 402: Low balance.
- 404: Request ID was not found or it has been verified / cancelled already.
- 500: An error occurred on the Vonage platform.
-
nextWorkflow
Move the request onto the next workflow, if available. If successful, this method will return normally. Otherwise, aVerifyResponseExceptionwill be thrown.- Parameters:
requestId- ID of the verify request, obtained fromVerificationResponse.getRequestId().- Throws:
VerifyResponseException- If the workflow could not be advanced. This could be for the following reasons:- 401: Invalid credentials.
- 404: Request ID was not found or it has been verified already.
- 409: There are no more events left to trigger.
- 500: An error occurred on the Vonage platform.
- Since:
- 8.5.0
-
createTemplate
Create a new custom template.- Parameters:
name- Reference name for the template. Must not contain spaces or special characters other than _ and -.- Returns:
- The created template metadata.
- Throws:
VerifyResponseException- If the template could not be created. This could be for the following reasons:- 401: Invalid credentials.
- 402: Low balance.
- 403: Template management is not enabled for your account.
- 409: A template with the same name already exists, or you have more than 9 templates.
- 429: Rate limit hit. Please wait and try again.
- 500: An error occurred on the Vonage platform.
- Since:
- 8.13.0
-
listTemplates
List all custom templates associated with the account.- Returns:
- The list of templates.
- Throws:
VerifyResponseException- If the templates could not be retrieved. This could be for the following reasons:- 401: Invalid credentials.
- 402: Low balance.
- 429: Rate limit hit. Please wait and try again.
- 500: An error occurred on the Vonage platform.
- Since:
- 8.13.0
-
getTemplate
Retrieve a specific template.- Parameters:
templateId- ID of the template to retrieve.- Returns:
- The template metadata.
- Throws:
VerifyResponseException- If the template could not be retrieved. This could be for the following reasons:- 401: Invalid credentials.
- 402: Low balance.
- 404: Template ID was not found.
- 429: Rate limit hit. Please wait and try again.
- 500: An error occurred on the Vonage platform.
- Since:
- 8.13.0
-
updateTemplate
Update an existing template.- Parameters:
templateId- ID of the template to update.name- New reference name for the template. Must not contain spaces or special characters.isDefault- Whether this template should be the default for the account.- Returns:
- The updated template metadata.
- Throws:
VerifyResponseException- If the template could not be updated. This could be for the following reasons:- 401: Invalid credentials.
- 402: Low balance.
- 403: Template management is not enabled for your account.
- 404: Template ID was not found.
- 409: A template with the same name already exists, or you have more than 9 templates.
- 429: Rate limit hit. Please wait and try again.
- 500: An error occurred on the Vonage platform.
- Since:
- 8.13.0
-
deleteTemplate
Delete a template.- Parameters:
templateId- ID of the template to delete.- Throws:
VerifyResponseException- If the template could not be deleted. This could be for the following reasons:- 401: Invalid credentials.
- 402: Low balance.
- 403: Template management is not enabled for your account.
- 404: Template not found.
- 409: Template contains undeleted fragments or is the default.
- 429: Rate limit hit. Please wait and try again.
- 500: An error occurred on the Vonage platform.
- Since:
- 8.13.0
-
createTemplateFragment
Create a new template fragment.- Parameters:
templateId- ID of the template to which the fragment belongs.fragment- The fragment to create.- Returns:
- The created fragment metadata.
- Throws:
VerifyResponseException- If the fragment could not be created. This could be for the following reasons:- 401: Invalid credentials.
- 402: Low balance.
- 403: Template management is not enabled for your account.
- 404: Template ID was not found.
- 409: Fragment for this channel and locale already exists.
- 422: Invalid parameters (e.g. unsupported locale or invalid text variables).
- 429: Rate limit hit. Please wait and try again.
- 500: An error occurred on the Vonage platform.
- Since:
- 8.13.0
-
listTemplateFragments
List all fragments associated with a template.- Parameters:
templateId- ID of the template to list fragments for.- Returns:
- The list of fragments.
- Throws:
VerifyResponseException- If the fragments could not be retrieved. This could be for the following reasons:- 401: Invalid credentials.
- 402: Low balance.
- 404: Template ID was not found.
- 429: Rate limit hit. Please wait and try again.
- 500: An error occurred on the Vonage platform.
- Since:
- 8.13.0
-
getTemplateFragment
Retrieve a specific fragment.- Parameters:
templateId- ID of the template to which the fragment belongs.fragmentId- ID of the fragment to retrieve.- Returns:
- The fragment metadata.
- Throws:
VerifyResponseException- If the fragment could not be retrieved. This could be for the following reasons:- 401: Invalid credentials.
- 402: Low balance.
- 404: Fragment not found for the provided IDs.
- 429: Rate limit hit. Please wait and try again.
- 500: An error occurred on the Vonage platform.
- Since:
- 8.13.0
-
updateTemplateFragment
Update an existing template fragment.- Parameters:
templateId- ID of the template to which the fragment belongs.fragmentId- ID of the fragment to update.text- New text for the fragment. There are 4 reserved variables available to use: ${code}, ${brand}, ${time-limit} and ${time-limit-unit}.- Returns:
- The updated fragment metadata.
- Throws:
VerifyResponseException- If the fragment could not be updated. This could be for the following reasons:- 401: Invalid credentials.
- 402: Low balance.
- 403: Template management is not enabled for your account.
- 404: Fragment not found for the provided IDs.
- 409: Fragment for this channel and locale already exists.
- 422: Invalid parameters (e.g. unsupported locale or invalid text variables).
- 429: Rate limit hit. Please wait and try again.
- 500: An error occurred on the Vonage platform.
- Since:
- 8.13.0
-
deleteTemplateFragment
Delete a template fragment.- Parameters:
templateId- ID of the template to which the fragment belongs.fragmentId- ID of the fragment to delete.- Throws:
VerifyResponseException- If the fragment could not be deleted. This could be for the following reasons:- 401: Invalid credentials.
- 402: Low balance.
- 403: Template management is not enabled for your account.
- 404: Fragment not found for the provided IDs.
- 409: Fragment is in use by a template or is the default.
- 429: Rate limit hit. Please wait and try again.
- 500: An error occurred on the Vonage platform.
- Since:
- 8.13.0
-