ldc-boutique-cnc-sable/app/Queries/Crm/GetCrmCustomerQuery.php
Jérémy Munsch 5037154108
feat(crm): implement customer update functionality
Adds UpdateCustomer action, input, and output classes to handle customer information updates.
Integrates with existing services and updates the CustomerController to utilize the new action.
2026-10-27 09:58:34 +01:00

39 lines
1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Queries\Crm;
use App\Contracts\Query;
use App\Contracts\QueryInput;
use App\Services\CrmService;
use Infrastructure\Adapters\Services\AppCustomerAuthService;
use Webmozart\Assert\Assert;
/**
* @implements \App\Contracts\Query<\App\Queries\Crm\GetCrmCustomerQueryInput, \App\Queries\Crm\GetCrmCustomerQueryOutput>
*/
final readonly class GetCrmCustomerQuery implements Query
{
public function __construct(
private CrmService $crmService,
private AppCustomerAuthService $authService,
) {
}
public function __invoke(QueryInput $input): GetCrmCustomerQueryOutput
{
Assert::isAOf(
$input,
GetCrmCustomerQueryInput::class,
);
$hashcode = $input->fromHashcodeOrAuthenticatedUserHashcode ?? $this->authService->getCustomerAsMandatory()->hashcode;
$crmCustomer = $this->crmService->getCustomerFromHashCode(
$hashcode
);
return new GetCrmCustomerQueryOutput($crmCustomer);
}
}