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

package pposRequest

import (
	"errors"
	"net/url"
)

//NewSscardGetByIDs 获取配置
func (that *PPOSClient) NewSscardGetByCp() *CfgSscardGetByCpRequest {
	return &CfgSscardGetByCpRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/cfg/cfgSscardByCompany/get",
		},
	}
}

type CfgSscardGetByCpResponse struct {
	CompanyId   int64  `json:"company_id"`           //公司ID
	ClientId    string `json:"client_id"`       //客户端id
	ClientSecret  string `json:"client_secret"`      //客户端秘钥
	YktPublicKey   string `json:"ykt_public_key"`        //平台公钥
	PublicKey   string `json:"public_key"`        //接入系统公钥
	PrivateKey   string `json:"private_key"`        //接入系统私钥
	SceneCode   string `json:"scene_code"`        //应用场景编码
	Remark      string `json:"remark"`              //备注
}

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

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

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