From 613270ec00c987869908803b6e6a483f6e40e43d Mon Sep 17 00:00:00 2001 From: Daniel Subiabre Date: Wed, 10 Sep 2025 06:41:55 +0200 Subject: [PATCH] Update RewardClaim creation process --- .../Project/RewardClaimApiResource.php | 7 +++-- src/Dto/RewardClaimCreationDto.php | 30 +++++++++++++++++++ .../Project/RewardClaimStateProcessor.php | 5 ++-- 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 src/Dto/RewardClaimCreationDto.php diff --git a/src/ApiResource/Project/RewardClaimApiResource.php b/src/ApiResource/Project/RewardClaimApiResource.php index 6ddfd97..704f5be 100644 --- a/src/ApiResource/Project/RewardClaimApiResource.php +++ b/src/ApiResource/Project/RewardClaimApiResource.php @@ -6,11 +6,11 @@ use ApiPlatform\Doctrine\Orm\State\Options; use ApiPlatform\Metadata as API; use App\ApiResource\Gateway\ChargeApiResource; use App\ApiResource\User\UserApiResource; +use App\Dto\RewardClaimCreationDto; use App\Entity\Project\RewardClaim; use App\State\ApiResourceStateProvider; use App\State\Project\RewardClaimStateProcessor; use App\Validator\AvailableRewardUnits; -use App\Validator\EnoughRewardCharge; use Symfony\Component\Validator\Constraints as Assert; /** @@ -22,7 +22,10 @@ use Symfony\Component\Validator\Constraints as Assert; provider: ApiResourceStateProvider::class, processor: RewardClaimStateProcessor::class )] -#[EnoughRewardCharge()] +#[API\GetCollection()] +#[API\Post(input: RewardClaimCreationDto::class)] +#[API\Get()] +#[API\Delete()] class RewardClaimApiResource { #[API\ApiProperty(identifier: true, writable: false)] diff --git a/src/Dto/RewardClaimCreationDto.php b/src/Dto/RewardClaimCreationDto.php new file mode 100644 index 0000000..b6f5251 --- /dev/null +++ b/src/Dto/RewardClaimCreationDto.php @@ -0,0 +1,30 @@ +autoMapper->map($data, RewardClaim::class); - if (!$claim->getId()) { + if ($data instanceof RewardClaimCreationDto) { $owner = $this->authService->getUser(); if (!$owner) {