package we_http

import (
	"fmt"
)

// CommonError 微信返回错误信息
type CommonError struct {
	ErrCode int    `json:"errcode"` // 	错误码
	ErrMSG  string `json:"errmsg"`  // 	错误描述
}

// CommonResult 微信返回错误信息
type CommonResult struct {
	ResultCode int    `json:"resultcode"` // 	错误码
	ResultMsg  string `json:"resultmsg"`  // 	错误描述
}

// GetResponseError 获取微信服务器错返回误信息
func (err CommonResult) GetResponseError() error {

	if err.ResultCode != 0 {
		return fmt.Errorf("wechat server error: code[%d] msg[%s]", err.ResultCode, err.ResultMsg)
	}

	return nil
}

// LoginResponse 返回给用户的数据
type LoginResponse struct {
	OpenID     string `json:"openid"`
	SessionKey string `json:"session_key"`
	// 用户在开放平台的唯一标识符
	// 只在满足一定条件的情况下返回
	UnionID string `json:"unionid"`
}

// Response 请求微信返回基础数据
type BaseResponse struct {
	Errcode int    `json:"errcode"`
	Errmsg  string `json:"errmsg"`
}