protected function encodeStatus(StatusResponse $action_result, ResponseInterface $response)
    {
        $response = $response->withStatus($action_result->getHttpCode(), $action_result->getMessage());

        if ($action_result->getHttpCode() >= 400) {
            $response = $response->write(json_encode(['message' => $action_result->getMessage()]));
        }

        return $response;
    }