Skip to content

feat(verify2): Add template_id support#612

Merged
dragonmantank merged 1 commit intomainfrom
add-template-id
Feb 20, 2026
Merged

feat(verify2): Add template_id support#612
dragonmantank merged 1 commit intomainfrom
add-template-id

Conversation

@dragonmantank
Copy link
Member

Add template_id support

Contribution Checklist

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds template_id support to Verify v2 verification requests, enabling clients to set a custom template when serializing requests to JSON.

Changes:

  • Added templateId field, getter, and builder setter to VerificationRequest with JSON property mapping to template_id.
  • Added unit test coverage for JSON serialization with and without template_id, using JSON resource fixtures.
  • Documented the feature addition in CHANGELOG.md.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/main/java/com/vonage/client/verify2/VerificationRequest.java Adds templateId to the request model + builder and maps it to template_id in JSON.
src/test/java/com/vonage/client/verify2/VerificationRequestTest.java Adds a helper to load JSON fixtures and a new test validating template_id serialization behavior.
src/test/resources/com/vonage/client/verify2/verification-request-with-template-id.json JSON fixture for requests that include template_id.
src/test/resources/com/vonage/client/verify2/verification-request-without-template-id.json JSON fixture for requests that omit template_id.
CHANGELOG.md Notes Verify v2 template_id support in the unreleased section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


/**
* A custom template ID to use for the verification. This parameter works only when
* the channel is SMS or RCS.
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Javadoc says template_id works when the channel is SMS or RCS, but this module’s Channel enum doesn’t include RCS (and there’s no RCS workflow implementation in verify2). This makes the documentation misleading; either add RCS support here or update the docs to reflect the actually supported channels.

Suggested change
* the channel is SMS or RCS.
* the channel is SMS.

Copilot uses AI. Check for mistakes.
Comment on lines +386 to +388
* @return This builder.
*/
public Builder templateId(String templateId) {
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builder.templateId(...) is documented as only applicable to certain channels, but the request constructor/builder doesn’t validate this (and also accepts blank/whitespace values). Consider rejecting empty template IDs and enforcing that templateId is only set when the workflows are compatible (e.g., SMS-only), similar to the existing validations for codeless workflows.

Suggested change
* @return This builder.
*/
public Builder templateId(String templateId) {
* @return This builder.
* @throws IllegalArgumentException If {@code templateId} is {@code null} or blank.
*/
public Builder templateId(String templateId) {
if (templateId == null || templateId.trim().isEmpty()) {
throw new IllegalArgumentException("templateId must not be null or blank.");
}

Copilot uses AI. Check for mistakes.
Comment on lines +71 to +78

// Replace placeholders
for (int i = 0; i < placeholders.length; i += 2) {
if (i + 1 < placeholders.length) {
json = json.replace(placeholders[i], placeholders[i + 1]);
}
}

Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loadJsonResource treats placeholders as key/value pairs but silently ignores a dangling key when an odd number of arguments is passed. This can mask test bugs; it would be safer to validate that placeholders.length is even and fail fast (e.g., throw IllegalArgumentException).

Suggested change
// Replace placeholders
for (int i = 0; i < placeholders.length; i += 2) {
if (i + 1 < placeholders.length) {
json = json.replace(placeholders[i], placeholders[i + 1]);
}
}
// Validate that placeholders are in key/value pairs
if (placeholders.length % 2 != 0) {
throw new IllegalArgumentException(
"Placeholders must be key/value pairs; received odd number: " + placeholders.length);
}
// Replace placeholders
for (int i = 0; i < placeholders.length; i += 2) {
json = json.replace(placeholders[i], placeholders[i + 1]);
}

Copilot uses AI. Check for mistakes.
@dragonmantank dragonmantank merged commit 008e03e into main Feb 20, 2026
20 checks passed
@dragonmantank dragonmantank deleted the add-template-id branch February 20, 2026 20:50
@codecov-commenter
Copy link

codecov-commenter commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.93%. Comparing base (c0f3497) to head (5bb2819).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #612   +/-   ##
=========================================
  Coverage     98.93%   98.93%           
- Complexity     3622     3623    +1     
=========================================
  Files           545      545           
  Lines          8004     8008    +4     
  Branches        443      443           
=========================================
+ Hits           7919     7923    +4     
  Misses           64       64           
  Partials         21       21           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants