Skip to content

feat!: Namespace refactor, PHP 8.3, webhook DTOs & improved error handling#3

Merged
yannelli merged 37 commits intomainfrom
mar2026-updates
Mar 13, 2026
Merged

feat!: Namespace refactor, PHP 8.3, webhook DTOs & improved error handling#3
yannelli merged 37 commits intomainfrom
mar2026-updates

Conversation

@yannelli
Copy link
Copy Markdown
Collaborator

⚠️ Breaking Changes

  • Namespace Change: Nextvisit\ClaimMDWrapper has been renamed to Nextvisit\ClaimMD. All imports must be updated
    accordingly.
  • PHP Version Requirement: Minimum PHP version bumped from 8.2 to 8.3.

Description

Enhancements and New Features

  • Added detailed documentation for webhook integration, including usage examples (enroll and appeal events) and
    WebhookPayloadDTO utility.
  • Introduced WebhookEventDTO, WebhookEnrollEventDTO, and WebhookAppealEventDTO for managing and validating webhook
    payloads.
  • Implemented custom exceptions for improved error handling in multiple request classes (ClaimRequest, FileRequest,
    ProviderRequest, and more).
  • Expanded exception handling to include ClaimMD-specific errors for Client and Claim.MD SDK requests.

Bug Fixes

  • Improved validation safeguards (e.g., empty array check and date validation) across DTOs and request implementations.
  • Enhanced error messaging for validation failures.

Refactoring

  • Transitioned namespaces, removing "Wrapper" suffix across DTOs, requests, and configuration files.
  • Updated test configurations and Pest namespaces to align with the new structure.
  • Enforced stricter type declarations and improved docblock consistency for better code maintainability.

Checklist

  • Tests added/updated.
  • Documentation updated where necessary.
  • Verified compatibility with PHP 8.3.
  • Code reviewed and approved.

yannelli added 30 commits March 13, 2026 13:15
… improve docblock consistency

Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
…ffix

Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Extend error handling for Client requests by adding specific exceptions for 4xx and 5xx responses, and handling non-JSON responses. Includes corresponding unit tests for improved coverage.

Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Refine validation for dates, phone numbers, and state codes. Ensure more precise argument exceptions and consistent error messaging.

Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Introduce a new Data Transfer Object (WebhookEventDTO) for webhook payload events, including validation logic, array conversion, and unit tests for full coverage.

Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Introduce WebhookPayloadDTO for managing webhook payloads, including validation, JSON handling, and array conversion. Added comprehensive unit tests for coverage.

Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Introduce WebhookEnrollEventDTO for managing enrollment event data in webhook payloads. Includes validation logic, array serialization, and comprehensive unit tests for full coverage.

Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Introduce WebhookAppealEventDTO for managing appeal event data in webhook payloads. Includes validation logic, array serialization, and comprehensive unit tests for full coverage.

Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Include documentation for parsing webhook payloads, accessing event data, and utilizing `WebhookPayloadDTO`. Add examples for enroll and appeal events.

Signed-off-by: Ryan Yannelli <ryanyannelli@gmail.com>
Copilot AI review requested due to automatic review settings March 13, 2026 18:07
@yannelli yannelli self-assigned this Mar 13, 2026
@yannelli yannelli added the enhancement New feature or request label Mar 13, 2026
@yannelli yannelli merged commit eb4e269 into main Mar 13, 2026
5 checks passed
Copy link
Copy Markdown

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

This PR delivers a breaking namespace rename (Nextvisit\ClaimMDWrapperNextvisit\ClaimMD), raises the minimum PHP version to 8.3, and expands the SDK with webhook DTOs and more structured HTTP error handling via custom exceptions.

Changes:

  • Renamed namespaces across src/ and tests/, updated Composer PSR-4 autoloading, and bumped PHP requirement to >=8.3.
  • Added webhook DTOs (WebhookPayloadDTO, WebhookEventDTO, enroll/appeal event DTOs) with serialization + validation and corresponding unit tests.
  • Implemented richer client-side error handling with new exception types for common HTTP failure modes and added client tests.

Reviewed changes

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

Show a summary per file
File Description
tests/Unit/Requests/ResponseRequestTest.php Updates imports to new Nextvisit\ClaimMD namespace.
tests/Unit/Requests/ProviderRequestTest.php Updates imports to new namespace.
tests/Unit/Requests/PayerRequestTest.php Updates imports to new namespace.
tests/Unit/Requests/FileRequestTest.php Updates imports to new namespace.
tests/Unit/Requests/EligibilityRequestTest.php Updates imports to new namespace.
tests/Unit/Requests/ERARequestTest.php Updates imports to new namespace.
tests/Unit/Requests/ClaimRequestTest.php Updates imports to new namespace.
tests/Unit/DTO/WebhookPayloadDTOTest.php Adds unit tests for webhook payload DTO parsing/validation/serialization.
tests/Unit/DTO/WebhookEventDTOTest.php Adds unit tests for webhook event DTO parsing/validation/serialization.
tests/Unit/DTO/WebhookEnrollEventDTOTest.php Adds unit tests for webhook enroll event DTO parsing/validation/serialization.
tests/Unit/DTO/WebhookAppealEventDTOTest.php Adds unit tests for webhook appeal event DTO parsing/validation/serialization.
tests/Unit/DTO/ProviderEnrollmentDTOTest.php Updates import namespace for DTO tests.
tests/Unit/DTO/EligibilityDTOTest.php Updates import namespace for DTO tests.
tests/Unit/DTO/ERADTOTest.php Updates import namespace and adjusts expected validation message.
tests/Unit/DTO/ClaimAppealDTOTest.php Updates import namespace for DTO tests.
tests/Unit/ConfigTest.php Updates import namespace for config tests.
tests/Unit/ClientTest.php Updates imports and adds coverage for new exception mapping/error handling paths.
tests/TestCase.php Updates test namespace to Nextvisit\ClaimMD\Tests.
tests/Pest.php Updates Pest bootstrap to use new TestCase namespace.
src/Requests/ResponseRequest.php Renames namespace, types endpoint const, and documents new exception behavior.
src/Requests/ProviderRequest.php Renames namespace, types endpoint const, and documents new exception behavior.
src/Requests/PayerRequest.php Renames namespace, types endpoint const, and documents new exception behavior.
src/Requests/FileRequest.php Renames namespace, adds upload date calendar validation, and tightens typing.
src/Requests/EligibilityRequest.php Renames namespace, uses Utils::streamFor for multipart, and updates docs.
src/Requests/ERARequest.php Renames namespace, types endpoint consts, and changes getList() default argument semantics.
src/Requests/ClaimRequest.php Renames namespace, types endpoint consts, and updates docs for new exceptions.
src/Exceptions/ServerException.php Adds 5xx-specific API exception type.
src/Exceptions/RateLimitException.php Adds 429-specific API exception type with Retry-After support.
src/Exceptions/NotFoundException.php Adds 404-specific API exception type.
src/Exceptions/InvalidResponseException.php Adds exception for non-JSON/undecodable responses.
src/Exceptions/ClaimMDException.php Introduces base SDK exception type.
src/Exceptions/AuthenticationException.php Adds 401-specific API exception type.
src/Exceptions/ApiException.php Adds generic HTTP error exception with status + decoded body.
src/DTO/WebhookPayloadDTO.php Adds webhook payload DTO with toArray(), fromArray(), fromJsonString().
src/DTO/WebhookEventDTO.php Adds webhook event DTO with validation and (de)serialization helpers.
src/DTO/WebhookEnrollEventDTO.php Adds webhook enroll event DTO with validation + mapping.
src/DTO/WebhookAppealEventDTO.php Adds webhook appeal event DTO with validation + mapping.
src/DTO/ProviderEnrollmentDTO.php Renames namespace and adjusts situational validation logic/comment.
src/DTO/EligibilityDTO.php Renames namespace and adds calendar-date validation + strict in_array.
src/DTO/ERADTO.php Renames namespace and improves date error messaging based on allowed values.
src/DTO/ClaimAppealDTO.php Renames namespace and standardizes InvalidArgumentException usage/import.
src/Config.php Renames namespace to Nextvisit\ClaimMD.
src/Client.php Renames namespace, disables Guzzle http_errors, and adds structured error-to-exception mapping.
composer.json Bumps PHP requirement to 8.3 and updates PSR-4 autoload namespaces.
README.md Updates documentation examples to the new namespace and adds webhook docs.
CLAUDE.md Adds repository guidance docs (commands, architecture, testing notes).

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

?\Throwable $previous = null
): never {
$responseBody = json_decode($rawBody, true);

Comment on lines +98 to +102
$events = array_map(
fn(array $eventData) => WebhookEventDTO::fromArray($eventData),
$data['events'] ?? []
);

// Assuming provider is an individual if provNameFirst is provided
if ($this->provNameLast && empty($this->provNameFirst)) {
if (empty($this->provNameFirst)) {
throw new InvalidArgumentException('provNameFirst is required when provNpi is not provided and the provider is an individual.');
- [**List Received ERAs**](#get-eras-list): Get a list of all ERAs that have been received.
- [**Get ERA 835**](#get-an-era-835): Get a specific ERA in the 835 format.
- [**Get ERA PDF**](#get-an-era-pdf): Get a specific ERA in the PDF format.
- [**Get ERA PDF**](#get-an-era-pdf): Get a specific ERA in the JSON format.
@yannelli yannelli deleted the mar2026-updates branch March 13, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants