/**
 * 核心服务接口sdk（golang版）
 *
 * @desc 啪啪运动 核心服务接口sdk
 * ---------------------------------------------------------------------
 * @author		tang <unphp@qq.com>
 * @date		2021-06-02
 * @copyright	core-utils
 * ---------------------------------------------------------------------
 */
package cooper

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

//NewPayCfgPayGetByTAppIdRequest ...账户管理 - 支付账户 - 详情
func (that *CooperClient) NewPayCfgPayGetByTAppIdRequest() *PayCfgPayGetByTAppIdRequest {
	return &PayCfgPayGetByTAppIdRequest{
		Request: Request{
			Client:            that,
			publicParamsSlice: []string{
				//...
			},
			apiAddress: "/pay/cfgPayGetByTAppId",
		},
	}
}

//PayCfgPayGetByTAppIdRequest
type PayCfgPayGetByTAppIdRequest struct {
	Request
}

func (that *PayCfgPayGetByTAppIdRequest) SetTTypeId(value int64) *PayCfgPayGetByTAppIdRequest {
	that.initParams()
	that.params.Set("t_type_id", utils.ToString(value)) //账户id
	return that
}

func (that *PayCfgPayGetByTAppIdRequest) SetTAppId(value string) *PayCfgPayGetByTAppIdRequest {
	that.initParams()
	that.params.Set("t_app_id", utils.ToString(value)) //账户id
	return that
}

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

//Do ...
func (that *PayCfgPayGetByTAppIdRequest) Do() (*PayCfgPayGetResponse, error) {
	//返回data
	_data, _err := that.Client.Post(that.apiAddress, that)
	if _err != nil {
		return nil, _err
	}
	//
	_str, _err := json.Marshal(_data)
	if _err != nil {
		return nil, errors.New(that.apiAddress + _err.Error())
	}
	//返回结果
	_rs := new(PayCfgPayGetResponse)
	_err = json.Unmarshal(_str, &_rs)
	if _err != nil {
		return nil, errors.New(that.apiAddress + _err.Error())
	}
	return _rs, nil
}
