/**
 * 核心服务接口sdk（golang版）
 *
 * @desc 啪啪运动 核心服务接口sdk
 * ---------------------------------------------------------------------
 * @author		unphp <unphp@qq.com>
 * @date		2018-12-18
 * @copyright	core-utils
 * ---------------------------------------------------------------------
 */

package pposRequest

import (
	"errors"
	"net/url"
)

//NewCfgTradeGetByIDs 获取配置
func (that *PPOSClient) NewCfgUmsPayGetByCp() *CfgUmsPayGetByCpRequest {
	return &CfgUmsPayGetByCpRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/cfg/umsPay/getCfg",
		},
	}
}

type CfgUmsPayGetByCpResponse struct {
	CompanyId  int64  `json:"company_id"`  //公司ID
	Status     int64  `json:"status"`      //授权状态
	AppId      string `json:"app_id"`      //appId
	AppKey     string `json:"app_key"`     //密钥
	InstMid    string `json:"inst_mid"`    //机构商户号
	MsgSrc     string `json:"msg_src"`     //消息来源
	MsgSrcId   string `json:"msg_src_id"`  //来源编号
	Mid        string `json:"mid"`         //商户号
	Tid        string `json:"tid"`         //终端号
	MiniAppId  string `json:"mini_app_id"` //小程序appid
	EncryptKey string `json:"encrypt_key"` //加密key
	ApiType    string `json:"api_type"`    //API类型：默认网付、开放平台：api-mop
}

//CfgWxPublicGetByCpRequest 业务类别
type CfgUmsPayGetByCpRequest struct {
	Request
}

func (that *CfgUmsPayGetByCpRequest) SetPayType(value string) *CfgUmsPayGetByCpRequest {
	that.initParams()
	that.params.Set("pay_type", value)
	return that
}

//Params ...
func (that *CfgUmsPayGetByCpRequest) Params() (url.Values, error) {
	that.initParams()
	_params := that.params
	return _params, nil
}

//Do ...
func (that *CfgUmsPayGetByCpRequest) Do() (*CfgUmsPayGetByCpResponse, error) {
	//
	_data, _err := that.Client.GetData(that.apiAddress, that)
	if _err != nil {
		return nil, _err
	}
	//
	_sliceData, _ok := _data.(map[string]interface{})
	if !_ok {
		return nil, errors.New(that.apiAddress + "请求响应格式不正确")
	}
	_rs := new(CfgUmsPayGetByCpResponse)
	if _err := that.ParseResponeMp(_rs, _sliceData, false); _err != nil {
		return nil, errors.New(that.apiAddress + "请求响应格式化异常:" + _err.Error())
	}
	//
	return _rs, nil
}
