protected function canRetry(RequestException $exception)
    {
        if ($exception instanceof NetworkException) {
            if ($exception->getCode() === 0 || $exception->getCode() >= 500) {
                return true;
            }
        } elseif ($exception instanceof ApiException) {
            return in_array($exception->getCode(), [
                ApiException::AUTHENTICATION_TEMPORARILY_UNAVAILABLE,
                ApiException::SERVER_TEMPORARILY_UNAVAILABLE,
                ApiException::INITIALIZATION_ERROR,
                ApiException::OPERATION_ERROR,
                ApiException::EXCEEDED_LIMIT_CONCURRENT_REQUESTS,
                ApiException::TEMPORARILY_UNAVAILABLE,
            ]);
        }

        return false;
    }