public function perform($id, Request $request) { $requestPayload = json_decode($request->getContent(), true); try { $payload = $this->service->updateEmailAddress(CustomerID::fromNative($id), EmailAddress::fromNative($requestPayload['emailAddress'])); return $this->responseHandler->dispatch(SuccessResponse::getResponse(), $payload, $request); } catch (\Exception $exception) { return $this->responseHandler->dispatch(WarningResponse::getResponse(), ['message' => $exception->getMessage()], $request); } }
public function register(ParameterBag $payload) { $this->mediator->execute(new RegisterCustomerCommand($customerID = CustomerID::generate(), $payload->get('firstName'), $payload->get('lastNames'), $payload->get('username'), EmailAddress::fromNative($payload->get('emailAddress')))); return ['customerID' => (string) $customerID, 'name' => $payload->get('firstName') . ' ' . $payload->get('lastNames')]; }