package hook

import (
	"github.com/imroc/req/v3"
	"time"
)

type Hook struct {
	ServerIp  string
	AdminPort string
	WxPort    string
	Client    *req.Client
}

func NewHook(serverIp string, adminPort string, WxPort string) *Hook {

	client := req.C().DevMode()
	client.SetCommonRetryCount(2).
		SetCommonRetryBackoffInterval(1*time.Second, 5*time.Second).
		SetCommonRetryFixedInterval(2 * time.Second).SetTimeout(30 * time.Second)

	return &Hook{
		ServerIp:  serverIp,
		AdminPort: adminPort,
		WxPort:    WxPort,
		Client:    req.C().DevMode(),
	}
}

func (h *Hook) setServerIp(ip string) *Hook {
	h.ServerIp = ip
	return h
}

func (h *Hook) setAdminPort(port string) *Hook {
	h.AdminPort = port
	return h
}

func (h *Hook) setWxPort(port string) *Hook {
	h.WxPort = port
	return h
}