*/ final class UpdateCustomer implements Action { public function __construct( private readonly AppCustomerAuthService $authService, private readonly CrmService $crmService ) { } #[\Override] public function __invoke(ActionInput $input): UpdateCustomerOutput { Assert::isInstanceOf($input, UnsubscribeFromNewsletterInput::class); $customer = $this->authService->getCustomerAsMandatory(); try { $result = $this->crmService->updateCustomerInfos( $customer, [ 'firstname' => $input->firstname, 'lastname' => $input->lastname, 'birth_date' => $input->birthDate, 'phone' => $input->phone, 'address' => $input->address, 'postcode' => $input->postcode, 'city' => $input->city, 'opt_in' => $input->optIn, ] ); return new UpdateCustomerOutput($result); } catch (\Throwable $e) { report($e); return new UpdateCustomerOutput(false); } } }