package conv

import (
	"gadmin/utility"
	"github.com/sirupsen/logrus"
)

var Server = new(cServer)

type cServer struct {
	version string
}

func (j *cServer) Extract(version string) {
	logrus.Info("cServer Extract...")
	j.setVersion(version).save()
}

func (j *cServer) setVersion(version string) *cServer {
	j.version = version
	return j
}

func (j *cServer) save() {
	// 下载的文件列表
	downs := []string{"Server_WX.json"}
	for _, fileName := range downs {

		// 保存文件
		url := utility.PullJsonAddr(j.version, fileName)
		dstFileName := utility.LocalJsonPath(j.version, fileName)
		if err := HttpRequestToFile(url, dstFileName); err != nil {
			logrus.Info("HttpRequestToFile err:%+v", err)
			return
		}
	}
}
