Skip to content

Commit

Permalink
Merge pull request #49 from flowerbin/main
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa authored Aug 12, 2024
2 parents 7574a03 + b4c1cd5 commit adf5bbb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 4 additions & 2 deletions api/oauth/approval_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import (
)

// ApprovalList 拉取token下授权广告账户接口
func ApprovalList(clt *core.SDKClient, accessToken string) ([]uint64, error) {
func ApprovalList(clt *core.SDKClient, accessToken string, pageNo int, pageSize int) ([]uint64, error) {
req := &oauth.ApprovalListRequest{
AppID: clt.AppID(),
Secret: clt.Secret(),
AccessToken: accessToken,
PageNo: pageNo,
PageSize: pageSize,
}
var resp oauth.ApprovalListResponse
err := clt.Post("", req, &resp)
if err != nil {
return nil, err
}
return resp.Details, nil
return resp.Data.Details, nil
}
18 changes: 16 additions & 2 deletions model/oauth/approval_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ func (r ApprovalListRequest) Encode() []byte {

// ApprovalListResponse 拉取token下授权广告账户接口 API Response
type ApprovalListResponse struct {
// Details 查询获得的广告主 ID
Details []uint64 `json:"details,omitempty"`
Message string `json:"message,omitempty"` // 返回信息
Data struct {
// Details 查询获得的广告主 ID
Details []uint64 `json:"details,omitempty"`
} `json:"data,omitempty"` // JSON返回值
Code int `json:"code,omitempty"` // 返回码
}

// IsError detect if the response is an error
func (r *ApprovalListResponse) IsError() bool {
return r.Code != 1
}

// Error implement error interface
func (r *ApprovalListResponse) Error() string {
return r.Message
}

0 comments on commit adf5bbb

Please sign in to comment.