8
0
gaore-common-sdk-go/services/big-data/token.go
2026-06-08 18:19:20 +08:00

57 lines
1.6 KiB
Go

package big_data
import (
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
)
// GetTokenParam 获取 token 参数
type GetTokenParam struct {
AppKey string `json:"app_key"`
AppSecret string `json:"app_secret"`
ExpiresIn int64 `json:"expires_in"`
XDebug string `json:"x_debug"` // 测试环境调试头,正式调用可留空
}
// GetTokenRequest 获取 token 请求
type GetTokenRequest struct {
*requests.JsonRequest
AppKey string `position:"Json" field:"app_key"`
AppSecret string `position:"Json" field:"app_secret"`
ExpiresIn int64 `position:"Json" field:"expires_in"`
XDebug string `position:"Header" field:"x-debug"`
}
// GetTokenResponse 获取 token 响应
type GetTokenResponse struct {
*responses.BaseResponse
Code int `json:"code"`
Message string `json:"message"`
Data struct {
Token string `json:"token"`
ExpiresIn int64 `json:"expires_in"`
} `json:"data"`
}
// CreateGetTokenRequest 创建获取 token 请求
func CreateGetTokenRequest(param GetTokenParam) *GetTokenRequest {
req := &GetTokenRequest{
JsonRequest: &requests.JsonRequest{},
AppKey: param.AppKey,
AppSecret: param.AppSecret,
ExpiresIn: param.ExpiresIn,
XDebug: param.XDebug,
}
req.InitWithApiInfo(HOST, VERSION, "/api/internal/v1/token")
req.Method = requests.POST
req.Scheme = requests.HTTPS
return req
}
// CreateGetTokenResponse 创建获取 token 响应
func CreateGetTokenResponse() *GetTokenResponse {
return &GetTokenResponse{
BaseResponse: &responses.BaseResponse{},
}
}