internalAddressService = $internalAddressService; $this->uid = $userId; } /** * @NoAdminRequired * * @param string $address * @param string $type * @return JsonResponse */ #[TrapError] public function setAddress(string $address, string $type): JsonResponse { $address = $this->internalAddressService->add( $this->uid, $address, $type )->jsonSerialize(); return JsonResponse::success($address, Http::STATUS_CREATED); } /** * @NoAdminRequired * * @param string $address * @param string $type * @return JsonResponse */ #[TrapError] public function removeAddress(string $address, string $type): JsonResponse { if ($this->uid === null) { return JsonResponse::error('User not found', Http::STATUS_UNAUTHORIZED); } $this->internalAddressService->add( $this->uid, $address, $type, false ); return JsonResponse::success(); } /** * @NoAdminRequired * * @return JsonResponse */ #[TrapError] public function list(): JsonResponse { if ($this->uid === null) { return JsonResponse::error('User not found', Http::STATUS_UNAUTHORIZED); } $list = $this->internalAddressService->getInternalAddresses( $this->uid ); return JsonResponse::success($list); } }