package pposRequest

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

//平台公司用户获取授权信息
func (that *PPOSClient) NewplatformCompanyAuthDataRequest() *platformCompanyAuthDataRequest {
	return &platformCompanyAuthDataRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/platform/plfCompany/getAuthData",
			publicParamsSlice: []string{
				"company_id",
				"account_info",
			},
		}}
}

type platformCompanyAuthDataRequest struct {
	Request
}

func (that *platformCompanyAuthDataRequest) SetOrganType(value int64) *platformCompanyAuthDataRequest {
	that.initParams()
	that.params.Set("organ_type", utils.ToString(value))
	return that
}

func (that *platformCompanyAuthDataRequest) SetAccountInfo(value string) *platformCompanyAuthDataRequest {
	that.initParams()
	that.params.Set("account_info", value)
	return that
}

//Params ...
func (that *platformCompanyAuthDataRequest) 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 *platformCompanyAuthDataRequest) Do() (interface{}, error) {
	//返回data
	_data, _err := that.Client.GetData(that.apiAddress, that)
	if _err != nil {
		return nil, _err
	}
	return _data, nil
}
