Add delete carrier endpoint#160
Open
luigimassa wants to merge 19 commits into
Open
Conversation
| Questions | Answers | ------------- | ------------------------------------------- | Description? | Add GetRequiredFieldsForAddress CQRS endpoint | Type? | new feature | BC breaks? | no | Deprecations? | no | Fixed ticket? | N/A | Sponsor company | @PrestaShopCorp | How to test? | Ask a dev
Expose ToggleCarrierStatusCommand and ToggleCarrierIsFreeCommand via
PUT /carriers/{carrierId}/toggle-status and
PUT /carriers/{carrierId}/toggle-is-free endpoints with carrier_write scope.
Add integration tests for both toggle endpoints.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add BulkCarriers API resource with PUT /carriers/bulk-set-status endpoint that maps to BulkToggleCarrierStatusCommand, following the same pattern used for taxes and zones bulk status toggle. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without this constraint, passing carrierId=0 causes a CarrierConstraintException thrown during command construction (before the command bus), which bypasses the exceptionToStatus mapping and returns 500 instead of a proper error. The Assert\All([Assert\Positive()]) constraint catches invalid IDs during Symfony validation phase and returns a 400 Bad Request with details. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nd instantiation CQRSCommand/CQRSUpdate automatically sets input to the CQRS command class, causing CQRSApiNormalizer to instantiate BulkToggleCarrierStatusCommand directly during the DeserializeListener phase. This bypasses the DTO and passes raw string values from JSON to the command constructor, where (int) cast on non-numeric strings produces 0, triggering CarrierConstraintException. Setting input: BulkCarriers::class forces the deserialization to use the DTO class, letting the CommandProcessor handle command instantiation with proper type handling. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rmalizer flow Removing input: BulkCarriers::class lets CQRSCommand auto-set input to BulkToggleCarrierStatusCommand, so CQRSApiNormalizer validates BulkCarriers constraints (Assert\Positive on carrierIds) before applying CQRSCommandMapping ([enabled] -> [expectedStatus]) and instantiating the command. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Non-numeric values (e.g. strings) in carrierIds array were bypassing Assert\Positive and causing CarrierConstraintException during command instantiation, resulting in HTTP 500 instead of 422. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ping Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hello @luigimassa! This is your first pull request on ps_apiresources repository of the PrestaShop project. Thank you, and welcome to this Open Source community! |
tleon
requested changes
Mar 23, 2026
This was referenced Mar 23, 2026
Replace individual property assertions with a single assertEquals on the entire carrier array, following the project test conventions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use property names instead of getter method names in QUERY_MAPPING, and only map properties where names differ between QueryResult and API. Remove TODO.md as it should not be committed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
@luigimassa CI is red, could you have a look please? |
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.
CQRSDeleteoperation onCarrierresource mapped toDeleteCarrierCommand,CarrierConstraintException→ 422 to exception status mapping,filtersMappingforcarrierIdandisFreeonCarrierListDELETE /carriers/{carrierId}with a valid carrier ID and verify 204 response; SendDELETE /carriers/{carrierId}with a non-existent ID and verify 404 response; SendDELETE /carriers/{carrierId}with an invalid ID and verify 422 response;