ldc-cocotte/app/Cqs/Queries/Crm/GetCrmCustomerQuery.php
Jérémy Munsch d0efb0f527
refactor: update namespaces for actions and queries
Refactored the codebase to change the namespaces of various actions and queries from `App\Actions` to `App\Cqs\Actions` and `App\Queries` to `App\Cqs\Queries`. This restructuring improves organization and clarity in the codebase.
2026-11-10 15:13:26 +01:00

39 lines
1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Cqs\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\Cqs\Queries\Crm\GetCrmCustomerQueryInput, \App\Cqs\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);
}
}