package pposRequest

import (
	"errors"
	"log"
	"net/url"
	"time"
)

//清理app缓存
func (that *PPOSClient) NewPubConfigClearAppRedisRequest() *PubConfigClearAppRedisRequest {
	return &PubConfigClearAppRedisRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/pub/config/clearAppRedis",
		},
		bT: time.Now(),
	}
}

//
type PubConfigClearAppRedisRequest struct {
	Request
	publicParamsSlice []string  //必传参数名
	bT                time.Time //耗时时间
}

//Params ...
func (that *PubConfigClearAppRedisRequest) Params() (url.Values, error) {
	that.initParams()
	_params := that.params
	//
	for _, _v := range that.publicParamsSlice {
		if _params.Get(_v) == "" {
			return nil, errors.New(that.apiAddress + "缺少参数:" + _v)
		}
	}
	return _params, nil
}

//Do ...
func (that *PubConfigClearAppRedisRequest) Do() (bool, error) {
	//返回data
	_, _err := that.Client.GetData(that.apiAddress, that)
	log.Println(that.apiAddress+" 耗时: ", time.Since(that.bT))
	if _err != nil {
		return false, _err
	}
	return true, nil
}
