Skip to content

DEVX-11247: Add Reports API to the SDK#623

Open
dragonmantank wants to merge 3 commits into
mainfrom
DEVX-11247-add-reports-api
Open

DEVX-11247: Add Reports API to the SDK#623
dragonmantank wants to merge 3 commits into
mainfrom
DEVX-11247-add-reports-api

Conversation

@dragonmantank
Copy link
Copy Markdown
Member

Summary

Implements the Vonage Reports API client for the Java Server SDK.

New ReportsClient with 5 methods:

  • getRecords(RecordsFilter)GET /v2/reports/records (synchronous records retrieval with query params)
  • createReport(AsyncReportRequest)POST /v2/reports (create asynchronous report)
  • getReport(String reportId)GET /v2/reports/{reportId} (get async report status)
  • cancelReport(String reportId)DELETE /v2/reports/{reportId} (cancel async report)
  • downloadReport(String fileId)GET /v3/media/{file_id} (download report ZIP as bytes)

New model classes:

  • Product — enum of 18 product types (VOICE-CALL, SMS, MESSAGES, etc.)
  • ReportStatus — enum: PENDING, PROCESSING, SUCCESS, ABORTED, FAILED, TRUNCATED
  • AsyncReportRequest — POST body with all optional product-specific fields, builder pattern
  • RecordsFilter — GET query params extending AbstractQueryParamsRequest, builder pattern
  • ReportResponse — async operation response with convenience getDownloadUrl()
  • RecordsResponse — sync response with List<Map<String, Object>> records
  • ReportsResponseException — extends VonageApiResponseException

Test coverage:

  • 36 unit tests covering all 5 client methods, request builders, response deserialization, enums, and error cases
  • Full test suite (1486 tests) passes

Jira Ticket

https://jira.vonage.com/browse/DEVX-11247

- Add ReportsClient with 5 endpoint methods: getRecords, createReport,
  getReport, cancelReport, downloadReport
- Add AsyncReportRequest (POST body), RecordsFilter (GET query params),
  ReportResponse, RecordsResponse, Product, ReportStatus, ReportsResponseException
- Wire ReportsClient into VonageClient
- Add 36 unit tests (all passing)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 26, 2026

Codecov Report

❌ Patch coverage is 92.72727% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.72%. Comparing base (e1f7392) to head (c83692e).

Files with missing lines Patch % Lines
.../java/com/vonage/client/reports/RecordsFilter.java 85.24% 27 Missing ⚠️
...onage/client/reports/ReportsResponseException.java 25.00% 3 Missing ⚠️
...java/com/vonage/client/reports/ReportResponse.java 95.65% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #623      +/-   ##
============================================
- Coverage     99.05%   98.72%   -0.33%     
- Complexity     3643     3769     +126     
============================================
  Files           548      556       +8     
  Lines          8051     8491     +440     
  Branches        444      452       +8     
============================================
+ Hits           7975     8383     +408     
- Misses           56       86      +30     
- Partials         20       22       +2     

☔ 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.

Copy link
Copy Markdown
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 first-class support for the Vonage Reports API to the Java SDK, including a new ReportsClient, request/response models, and integration via VonageClient.

Changes:

  • Introduces ReportsClient with synchronous records retrieval, async report lifecycle (create/status/cancel), and report download.
  • Adds Reports API models (Product, ReportStatus, AsyncReportRequest, RecordsFilter, ReportResponse, RecordsResponse) and ReportsResponseException.
  • Adds unit tests for the new client/models and updates VonageClient + CHANGELOG.

Reviewed changes

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

Show a summary per file
File Description
src/test/java/com/vonage/client/reports/ReportsClientTest.java New unit tests for Reports client, enums, request builders, and response parsing.
src/main/java/com/vonage/client/VonageClient.java Wires ReportsClient into the main SDK entrypoint via a new field + getter.
src/main/java/com/vonage/client/reports/ReportStatus.java Adds enum for report processing status with Jackson (de)serialization.
src/main/java/com/vonage/client/reports/ReportsResponseException.java Adds Reports-specific API error exception type.
src/main/java/com/vonage/client/reports/ReportsClient.java Implements Reports API endpoints (records, async reports, cancellation, download).
src/main/java/com/vonage/client/reports/ReportResponse.java Model for async report responses including HAL links and download URL helper.
src/main/java/com/vonage/client/reports/RecordsResponse.java Model for synchronous record retrieval responses with raw record maps.
src/main/java/com/vonage/client/reports/RecordsFilter.java Query-params request builder for synchronous records retrieval filters.
src/main/java/com/vonage/client/reports/Product.java Adds product enum and string mapping for Reports API.
src/main/java/com/vonage/client/reports/package-info.java Package-level documentation for the Reports API module.
src/main/java/com/vonage/client/reports/AsyncReportRequest.java JSON body builder for async report creation.
CHANGELOG.md Notes new Reports API support under Unreleased.

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

package com.vonage.client.reports;

import com.vonage.client.AbstractClientTest;
import com.vonage.client.TestUtils;
Comment on lines +523 to +528
public void testDownloadReport() throws Exception {
byte[] zipData = new byte[]{0x50, 0x4B, 0x03, 0x04}; // PK (zip magic bytes)
stubResponse(200, new String(zipData));
var result = client.downloadReport(FILE_ID);
assertNotNull(result);
}
Comment on lines +23 to +30
* Query parameters for synchronously retrieving report records ({@code GET /v2/reports/records}).
* <p>
* Build using {@link #builder(Product, String)}, providing the required {@code product} and
* {@code account_id}. Use either date-based queries ({@link Builder#dateStart}/{@link Builder#dateEnd})
* or ID-based queries ({@link Builder#id}) — when using ID queries, only {@code product},
* {@code account_id}, {@code direction}, {@code id}, {@code includeMessage} and
* {@code showConcatenated} are allowed.
* </p>
Comment on lines +112 to +118
* Create an asynchronous report generation request.
* <p>
* The report will be processed in the background. Use the returned {@code request_id} to poll
* for status with {@link #getReport(String)}, and once the status is {@link ReportStatus#SUCCESS},
* use the download URL from {@link ReportResponse#getDownloadUrl()} with
* {@link #downloadReport(String)} to retrieve the data.
* </p>
Comment on lines +187 to +190
* The file ID is obtained from {@link ReportResponse#getDownloadUrl()}.
* </p>
*
* @param fileId The UUID of the file to download (from the report's {@code download_report} link).
dragonmantank and others added 2 commits May 26, 2026 13:18
- downloadReport now accepts full download URL (from getDownloadUrl())
  instead of a bare file ID, matching VoiceClient#downloadRecordingRaw
  pattern; validates URL is from nexmo.com/vonage.com
- Update getDownloadUrl() Javadoc to clarify it returns full absolute URL
- Relax RecordsFilter Javadoc to note id-based constraints are API
  behaviour, not SDK-enforced
- Remove unused TestUtils import in ReportsClientTest
- Fix testDownloadReport to use ASCII payload with assertArrayEquals
- Add testDownloadReportInvalidHost test case

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Revert to constructing the download URL internally from the file ID
to prevent open-redirect/SSRF risks. Add ReportResponse#getFileId()
as a convenience helper that extracts the UUID from the download_report
HAL link, so callers can easily chain getFileId() into downloadReport().

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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