package ppos

import (
	"PPOSUtils/utils"
)

//NewJwtWxOpen 令牌：账号/账号类型
func NewJwtWxOpen() *wtWxOpen {
	return &wtWxOpen{}
}

//JwtAccount
type wtWxOpen struct {
	JwtBase
}

func (that *wtWxOpen) init() {
	if that.paramsMp == nil {
		that.JwtBase.init()
		that.paramsSlice = append(that.paramsSlice, "account_type")
	}
}

func (that *wtWxOpen) SetAccountType(accountType interface{}) {
	that.init()
	that.paramsMp.Set("account_type", accountType)
}

//生成应用令牌
func (that *wtWxOpen) CreateJwt(params ...utils.Mp) (string, error) {
	//
	that.init()
	_jwtString, _err := that.JwtBase.CreateJwt(params...)
	if _err != nil {
		return "", _err
	}
	return _jwtString, nil
}

func (that *wtWxOpen) ParseParams() (utils.Mp, error) {
	//
	that.init()
	if _, _err := that.JwtBase.ParseParams(); _err != nil {
		return nil, _err
	}
	return that.paramsMp, nil
}
