public static function setApiVersion($version)
    {
        if (! in_array($version, [1,2])) {
            throw new \Exception(sprintf("The %d version is not supported", $version));
        }
        self::$apiVersion = $version;
        
        // Refresh services if version is changed and base url is defined
        if (self::$url) {
            self::initServices();
        }
    }