package pposRequest

import (
	"PPOSUtils/utils"
	"errors"
	"net/url"
)

//NewGetCustomerTypeIsUseRequest 判断客户类型是否被使用
func (that *PPOSClient) NewGetCustomerTypeIsUseRequest() *GetCustomerTypeIsUseRequest {
	return &GetCustomerTypeIsUseRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/member/member/getCustomerTypeIsUse",
			publicParamsSlice: []string{
				"customer_type_id",
			},
		},
	}
}

//
type GetCustomerTypeIsUseRequest struct {
	Request
	publicParamsSlice []string //必传参数名
}

func (that *GetCustomerTypeIsUseRequest) SetCustomerTypeId(value int64) *GetCustomerTypeIsUseRequest {
	that.initParams()
	that.params.Set("customer_type_id", utils.ToString(value))
	return that
}

//Params ...
func (that *GetCustomerTypeIsUseRequest) 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 *GetCustomerTypeIsUseRequest) Do() (bool, error) {
	//返回data
	_data, _err := that.Client.GetData(that.apiAddress, that)
	if _err != nil {
		return false, _err
	}
	_rs, _ok := _data.(bool)
	if !_ok {
		return false, errors.New(that.apiAddress + "请求响应格式不正确,错误代码01")
	}
	//返回结果
	return _rs, nil
}
