2 Star 0 Fork 0

hansdq / dyQcSDk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
create_token_request.go 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
Hansdq 提交于 2022-12-25 20:15 . add sdk
package doudian_sdk
import (
"encoding/json"
)
type CreateTokenRequest struct {
BaseDoudianOpApiRequest
param *CreateTokenParam
}
func (r *CreateTokenRequest) GetParamObject() interface{}{
return r.param
}
func(r *CreateTokenRequest) GetParams() *CreateTokenParam {
return r.param
}
func (r *CreateTokenRequest) Execute(accessToken *AccessToken) (*CreateTokenResponse, error) {
responseJson, err := r.GetClient().Request(r, accessToken)
if err != nil {
return nil, err
}
response := &CreateTokenResponse{}
_ = json.Unmarshal([]byte(responseJson), response)
return response, nil
}
func (r *CreateTokenRequest) GetUrlPath() string {
return "token/create"
}
func NewCreateTokenRequest() *CreateTokenRequest {
request := &CreateTokenRequest{
param: &CreateTokenParam{},
}
request.SetConfig(GlobalConfig)
request.SetClient(DefaultDoudianOpApiClient)
return request
}
type CreateTokenResponse struct {
BaseDoudianOpApiResponse
Data CreateTokenData `json:"data"`
}
type CreateTokenParam struct {
Code string `json:"code"`
GrantType string `json:"grant_type"`
ShopId int64 `json:"shop_id"`
}
type CreateTokenData struct {
//用于调用API的access_token
//过期时间为expires_in值
//可通过refresh_token刷新获取新的access_token,过期时间仍为expires_in值
AccessToken string `json:"access_token"`
//access_token接口调用凭证超时时间,单位(秒),默认有效期:7天
ExpiresIn int64 `json:"expires_in"`
//授权作用域,使用逗号,分隔。预留字段
Scope string `json:"scope"`
//店铺ID
ShopId string `json:"shop_id"`
//店铺名称
ShopName string `json:"shop_name"`
//用于刷新access_token的刷新令牌(有效期:14 天)
RefreshToken string `json:"refresh_token"`
//授权主体id
AuthorityId string `json:"authority_id"`
}
Go
1
https://gitee.com/hansdq/dy-qc-sdk.git
git@gitee.com:hansdq/dy-qc-sdk.git
hansdq
dy-qc-sdk
dyQcSDk
v1.0.8

搜索帮助