Skip to content

Commit

Permalink
Merge branch 'release/v1.8.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa committed Jun 21, 2024
2 parents f40f6f5 + 7353996 commit 5edc8c7
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 21 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- 生成授权链接 [ Url(clt *core.SDKClient, req *oauth.UrlRequest) string ]
- 获取AccessToken [ AccessToken(clt *core.SDKClient, authCode String) (*oauth.AccessTokenResponse, error) ]
- 刷新Token [ RefreshToken(clt *core.SDKClient, refreshToken string) (*oauth.AccessTokenResponse, error)]
- 拉取token下授权广告账户接口 [ ApprovalList(clt *core.SDKClient, accessToken string) ([]uint64, error) ]
- 账号服务
- 广告主 (api/advertiser)
- 获取广告主信息 [ Info(clt *core.SDKClient, accessToken string, advertiserID int64) (*advertiser.Info, error) ]
Expand Down
21 changes: 21 additions & 0 deletions api/oauth/approval_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package oauth

import (
"github.com/bububa/kwai-marketing-api/core"
"github.com/bububa/kwai-marketing-api/model/oauth"
)

// ApprovalList 拉取token下授权广告账户接口
func ApprovalList(clt *core.SDKClient, accessToken string) ([]uint64, error) {
req := &oauth.ApprovalListRequest{
AppID: clt.AppID(),
Secret: clt.Secret(),
AccessToken: accessToken,
}
var resp oauth.ApprovalListResponse
err := clt.Post("", req, &resp)
if err != nil {
return nil, err
}
return resp.Details, nil
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
package oauth

import "encoding/json"

// AccessTokenRequest 获取AccessToken APIRequest
type AccessTokenRequest struct {
// AppID 申请应用后快手返回的 app_id
AppID uint64 `json:"app_id,omitempty"`
// Secret 申请应用后快手返回的 secret
Secret string `json:"secret,omitempty"`
// AuthCode 授权时返回的 auth_code
AuthCode string `json:"auth_code,omitempty"`
}

// Url implement PostRequest interface
func (r AccessTokenRequest) Url() string {
return "oauth2/authorize/access_token"
}

// Encode implement PostRequest interface
func (r AccessTokenRequest) Encode() []byte {
buf, _ := json.Marshal(r)
return buf
}

// AccessTokenResponse 获取AccessToken APIResponse
type AccessTokenResponse struct {
// AccessToken 用于验证权限的token
Expand Down
21 changes: 0 additions & 21 deletions model/oauth/access_token_request.go

This file was deleted.

34 changes: 34 additions & 0 deletions model/oauth/approval_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package oauth

import "encoding/json"

// ApprovalListRequest 拉取token下授权广告账户接口 API Request
type ApprovalListRequest struct {
// AppID 申请应用后快手返回的 app_id
AppID uint64 `json:"app_id,omitempty"`
// Secret 申请应用后快手返回的 secret
Secret string `json:"secret,omitempty"`
// AccessToken 查询的 access_token
AccessToken string `json:"access_token,omitempty"`
// PageNo 分页页码,必填
PageNo int `json:"page_no,omitempty"`
// PageSize 分页每页展示条数,必填,最大值为1000
PageSize int `json:"page_size,omitempty"`
}

// Url implement PostRequest interface
func (r ApprovalListRequest) Url() string {
return "oauth2/authorize/approval/list"
}

// Encode implement PostRequest interface
func (r ApprovalListRequest) Encode() []byte {
buf, _ := json.Marshal(r)
return buf
}

// ApprovalListResponse 拉取token下授权广告账户接口 API Response
type ApprovalListResponse struct {
// Details 查询获得的广告主 ID
Details []uint64 `json:"details,omitempty"`
}

0 comments on commit 5edc8c7

Please sign in to comment.