/**
 * 核心服务接口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) NewCfgWxPublicGetByCp() *CfgWxPublicGetByCpRequest {
	return &CfgWxPublicGetByCpRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/wxMp/public/getByCp",
		},
	}
}

type CfgWxPublicGetByCpResponse struct {
	MpId          int64  `json:"mp_id"`           //ID
	CompanyId     int64  `json:"company_id"`      //公司ID
	MpTitle       string `json:"mp_title"`        //公众号名称
	Status        int64  `json:"status"`          //授权状态
	MpAccount     string `json:"mp_account"`      //登录账号标识
	MpAppId       string `json:"mp_app_id"`       //开发者ID
	MpAppSecret   string `json:"mp_app_secret"`   //开发者密码
	MpAesKey      string `json:"mp_aes_key"`      //信息加密密钥
	MpBusinessId  string `json:"mp_business_id"`  //商户号ID
	MpBusinessKey string `json:"mp_business_key"` //商户号Key
	MpDevToken    string `json:"mp_dev_token"`    //开发者token
	SubMchId      string `json:"sub_mch_id"`      //子商户ID
	MiniAppId     string `json:"mini_app_id"`     //小程序 - appID
	MiniAppSecret string `json:"mini_app_secret"` //小程序 - 应用密钥
}

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

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

//Do ...
func (that *CfgWxPublicGetByCpRequest) Do() (*CfgWxPublicGetByCpResponse, 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(CfgWxPublicGetByCpResponse)
	if _err := that.ParseResponeMp(_rs, _sliceData); _err != nil {
		return nil, errors.New(that.apiAddress + "请求响应格式化异常:" + _err.Error())
	}
	//
	return _rs, nil
}
