feat!: Namespace refactor, PHP 8.3, webhook DTOs & improved error handling#3
Merged
feat!: Namespace refactor, PHP 8.3, webhook DTOs & improved error handling#3
Conversation
… 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>
There was a problem hiding this comment.
Pull request overview
This PR delivers a breaking namespace rename (Nextvisit\ClaimMDWrapper → Nextvisit\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/andtests/, 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nextvisit\ClaimMDWrapperhas been renamed toNextvisit\ClaimMD. All imports must be updatedaccordingly.
8.2to8.3.Description
Enhancements and New Features
enrollandappealevents) andWebhookPayloadDTOutility.WebhookEventDTO,WebhookEnrollEventDTO, andWebhookAppealEventDTOfor managing and validating webhookpayloads.
ClaimRequest,FileRequest,ProviderRequest, and more).Bug Fixes
Refactoring
Checklist