Skip to content

Add carrier delete, bulk delete and bulk status endpoints - #448

Open
luigimassa wants to merge 1 commit into
PrestaShop:devfrom
bwlab:feature/carrier-delete-bulk-status
Open

luigimassa wants to merge 1 commit into
PrestaShop:devfrom
bwlab:feature/carrier-delete-bulk-status

Conversation

@luigimassa

@luigimassa luigimassa commented Oct 20, 2026 •

Copy link
Copy Markdown
Questions Answers
Description? Add carrier delete, bulk delete and bulk status endpoints
Type? new feature
BC breaks? no
Deprecations? no
Fixed ticket? N/A
Sponsor company @luigimassa bwlab.it
How to test? CarrierStatusAndDeleteEndpointTest (CI)

Replaces #147, #148, #159 and #160. Since they were opened, dev gained the carrier GET / create / update / ranges / list endpoints, so this PR only adds what is still missing, rebased on the current dev and following the review of #160:

  • DELETE /carriers/{carrierId} (DeleteCarrierCommand)
  • PUT /carriers/bulk-update-status with carrierIds + enabled (BulkToggleCarrierStatusCommand)
  • DELETE /carriers/bulk-delete with carrierIds (BulkDeleteCarrierCommand)

Both bulk operations share one BulkCarriers resource, like BulkCountries. The ids are validated as positive integers, so [0] or ["a"] answer 422 before the command runs; empty carrierIds are rejected too. Unknown carriers answer 404.

The single carrier toggle endpoints of the previous PRs were dropped: the existing carrier update already sets enabled and free and returns the carrier.

Tests compare whole objects and cover the protected endpoints and the invalid payloads. Checked locally on PrestaShop 9.2.0: all Carrier* integration tests, PHPStan (phpstan-9.2.x.neon), PHP-CS-Fixer and Rector.

🤖 Generated with Claude Code

@ps-jarvis

Copy link
Copy Markdown

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!

@LameuleFR LameuleFR left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#302 adds the same bulk delete; one of the two should be closed.

* @var int[]
*/
#[ApiProperty(openapiContext: ['type' => 'array', 'items' => ['type' => 'integer'], 'example' => [1, 3]])]
#[Assert\NotBlank]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you merge BulkDeleteCarriers and BulkUpdateStatusCarriers into one BulkCarriers class, like BulkCountries, and validate the ids with Assert\All([new Assert\Type('integer'), new Assert\Positive()])? With NotBlank alone, [0] or ["a"] reaches the command.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: one BulkCarriers class for both operations, like BulkCountries. The ids are validated with Assert\All([new Assert\Type('integer'), new Assert\Positive()]), so [0] and ["a"] answer 422 before the command runs (both covered by the test). I also added the OpenAPI summary and description of each operation.

- DELETE /carriers/{carrierId}
- PUT /carriers/bulk-update-status
- DELETE /carriers/bulk-delete

Both bulk operations share one BulkCarriers resource, like BulkCountries. The carrier ids are
validated as positive integers before the command runs (422), unknown ones answer 404.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@luigimassa
luigimassa force-pushed the feature/carrier-delete-bulk-status branch from fd47033 to 58c7557 Compare October 29, 2026 13:21
@luigimassa

Copy link
Copy Markdown
Author

About #302: I asked there whether it can be closed in favour of this one, since this PR also covers the single delete and the bulk status.

@jolelievre

Copy link
Copy Markdown
Contributor

PrestaShop/PrestaShop#43369 (9.2.1) reads the item type of an array from its @var int[] / @var Foo[] docblock, and documents the request body of a DELETE with allowEmptyBody: false, so the hand-written openapiContext can shrink. Once it is merged:

  • The openapiContext type and items can go (the @var docblock is there) in BulkCarriers.php:81.

On older cores the arrays are documented without item type, the behaviour is the same. Keep the example in openapiContext when there is one (#[ApiProperty(openapiContext: ['example' => [1, 3]])]).

@luigimassa

Copy link
Copy Markdown
Author

Thanks @jolelievre! I'll drop the openapiContext type and items (keeping the example) once PrestaShop/PrestaShop#43369 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

4 participants