public function getEndpoint($name = self::DEFAULT_ENDPOINT): Endpoint
    {
        $endpoints = $this->endpointsConfig;
        unset($endpoints[self::DEFAULT_ENDPOINT]);
        $endpointsNames = array_keys($endpoints);
        if (self::DEFAULT_ENDPOINT !== $name && !\in_array($name, $endpointsNames)) {
            throw new EndpointNotValidException($name, $endpointsNames);
        }

        //use first static cache
        if (isset(self::$endpoints[$name])) {
            return self::$endpoints[$name];
        }

        //use file cache
        self::$endpoints[$name] = $this->loadCache($name);

        //retry after load from file
        if (isset(self::$endpoints[$name]) && self::$endpoints[$name] instanceof Endpoint) {
            return self::$endpoints[$name];
        }

        $this->initialize($name);

        return self::$endpoints[$name];
    }