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

package pposRequest

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

//new...
func (that *PPOSClient) NewSyncPlatformStadiumInfo() *SyncPlatformStadiumInfoRequest {
	return &SyncPlatformStadiumInfoRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/platform/plfStadium/getOrganVenueInfo",
		},
	}
}

//Request...
type SyncPlatformStadiumInfoRequest struct {
	Request
}

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

type SyncPlatformStadiumInfoResponse struct {
	CompanyId  int64  `json:"company_id"`
	BusinessId int64  `json:"business_id"`
	StadiumId  int64  `json:"stadium_id"`
	OrganName  string `json:"organ_name"`
	OrganNo    string `json:"organ_no"`
	VenueCode  string `json:"venue_code"`
	Vname      string `json:"vname"`
}

//Do ...
func (that *SyncPlatformStadiumInfoRequest) Do() (*SyncPlatformStadiumInfoResponse, error) {
	_rs := new(SyncPlatformStadiumInfoResponse)
	_data, _err := that.Client.GetData(that.apiAddress, that)
	if _err != nil {
		return _rs, _err
	}
	_sliceData, _ok := _data.(map[string]interface{})
	if !_ok {
		return _rs, errors.New(that.apiAddress + "请求响应格式不正确")
	}
	_str, _err := json.Marshal(_sliceData)
	if _err != nil {
		return _rs, errors.New(that.apiAddress + _err.Error())
	}
	_err = json.Unmarshal(_str, &_rs)
	if _err != nil {
		return _rs, errors.New(that.apiAddress + _err.Error())
	}
	return _rs, nil
}
