v4 modernization: preserve API error shape and expand critical tests#44
Merged
v4 modernization: preserve API error shape and expand critical tests#44
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Modernizes the Facturapi PHP SDK to v4 by switching to a PSR-18/Guzzle-based HTTP layer, preserving full API error payloads via a new FacturapiException, expanding test coverage, and refreshing documentation and examples.
Changes:
- Replaced cURL transport with a PSR-18 HTTP client flow in
BaseClient, adding richer error metadata on failures. - Introduced
FacturapiException(with compatibility alias forFacturapi_Exception) and expanded error-handling tests for JSON/non-JSON bodies. - Added/expanded resource method modernizations (camelCase + deprecated snake_case aliases) and updated READMEs, example, PHPUnit config, and Composer constraints.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/bootstrap.php | Adds PHPUnit bootstrap and Support autoloading. |
| tests/Support/FakeHttpClient.php | PSR-18 fake client used by new tests. |
| tests/Resources/WebhooksTest.php | Covers local webhook signature verification and API fallback. |
| tests/Resources/OrganizationsMultipartTest.php | Covers multipart request building and file-open failures. |
| tests/Resources/InvoicesTest.php | Verifies download PDF path + headers. |
| tests/Resources/InvoiceReceiptCreationTest.php | Verifies create/cancel request building (JSON + query params). |
| tests/Http/ErrorHandlingTest.php | Verifies API error shape preservation and metadata accessors. |
| tests/Http/ErrorHandlingNonJsonEdgeCasesTest.php | Adds coverage for invalid/empty/plain-text error bodies. |
| src/Http/BaseClient.php | New PSR-18 request execution, error extraction, config normalization, multipart building. |
| src/Facturapi.php | Updates SDK constructor/config and resource wiring. |
| src/Exceptions/Facturapi_Exception.php | Keeps deprecated compatibility alias to FacturapiException. |
| src/Exceptions/FacturapiException.php | New exception carrying error payload/status/raw body. |
| src/Resources/Webhooks.php | Modernizes methods and adds local signature verification logic. |
| src/Resources/Tools.php | Modernizes request building and exception handling. |
| src/Resources/Retentions.php | Adds camelCase methods + deprecated snake_case wrappers. |
| src/Resources/Receipts.php | Adds camelCase methods + deprecated snake_case wrappers. |
| src/Resources/Products.php | Modernizes resource methods and exception handling. |
| src/Resources/Organizations.php | Modernizes methods, improves query building, adds deprecation wrapper for typo’d method. |
| src/Resources/Invoices.php | Adds camelCase methods + deprecated snake_case wrappers. |
| src/Resources/Customers.php | Modernizes methods and exception handling. |
| src/Resources/ComercioExteriorCatalogs.php | Adds Comercio Exterior catalogs resource support. |
| src/Resources/Catalogs.php | Modernizes query building and exception handling. |
| src/Resources/CartaPorteCatalogs.php | Modernizes query building and exception handling. |
| phpunit.xml | Adds PHPUnit configuration and bootstrap. |
| example.php | Switches example to Composer autoload and env-based API key. |
| composer.json | Bumps PHP to >=8.2, adds Guzzle + PSR HTTP client, moves to PSR-4 autoload. |
| VERSION | Bumps to 4.0.0 and documents breaking changes/migration notes. |
| README.md | Updates English docs for v4 config, usage, and error handling. |
| README.es.md | Adds Spanish docs mirroring the updated guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 31 out of 31 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
raul-facturapi
approved these changes
Mar 30, 2026
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.
Summary
FacturapiExceptiongetErrorData(),getResponseData(),getStatusCode(), andgetRawBody()Validation
./vendor/bin/phpunit --configuration phpunit.xmlOK (16 tests, 70 assertions)