-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package tools | ||
|
||
import ( | ||
"github.com/bububa/oceanengine/marketing-api/core" | ||
"github.com/bububa/oceanengine/marketing-api/model/tools" | ||
) | ||
|
||
// AwemeAuthList 获取抖音授权关系 | ||
// 可以获取账户下抖音号授权关系以及授权视频 | ||
func AwemeAuthList(clt *core.SDKClient, accessToken string, req *tools.AwemeAuthListRequest) (*tools.AwemeAuthListData, error) { | ||
var resp tools.AwemeAuthListResponse | ||
if err := clt.Get("2/tools/aweme_auth_list/", req, &resp, accessToken); err != nil { | ||
return nil, err | ||
} | ||
return resp.Data, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package enum | ||
|
||
// AwemeAuthStatus 授权状态 | ||
type AwemeAuthStatus string | ||
|
||
const ( | ||
// AwemeAuthStatus_AUTHRIZED 授权中 | ||
AwemeAuthStatus_AUTHRIZED AwemeAuthStatus = "AUTHRIZED" | ||
// AwemeAuthStatus_AUTHRIZING 待授权确认 | ||
AwemeAuthStatus_AUTHRIZING AwemeAuthStatus = "AUTHRIZING" | ||
// AwemeAuthStatus_INVALID 授权失效 | ||
AwemeAuthStatus_INVALID AwemeAuthStatus = "INVALID" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package enum | ||
|
||
type AwemeAuthSubStatus string | ||
|
||
const ( | ||
// AwemeAuthSubStatus_INVALID_CANCEL 主动操作解除授权 | ||
AwemeAuthSubStatus_INVALID_CANCEL AwemeAuthSubStatus = "INVALID_CANCEL" | ||
// AwemeAuthSubStatus_INVALID_EXPIRED 授权期限已到 | ||
AwemeAuthSubStatus_INVALID_EXPIRED AwemeAuthSubStatus = "INVALID_EXPIRED" | ||
// AwemeAuthSubStatus_INVALID_REJECT C端拒绝授权 | ||
AwemeAuthSubStatus_INVALID_REJECT AwemeAuthSubStatus = "INVALID_REJECT" | ||
// AwemeAuthSubStatus_INVALID_TIME_OUT 超时未确认 | ||
AwemeAuthSubStatus_INVALID_TIME_OUT AwemeAuthSubStatus = "INVALID_TIME_OUT" | ||
// AwemeAuthSubStatus_RENEWING 续期待确认 | ||
AwemeAuthSubStatus_RENEWING AwemeAuthSubStatus = "RENEWING" | ||
// AwemeAuthSubStatus_RENEW_FAIL 续期申请失效 | ||
AwemeAuthSubStatus_RENEW_FAIL AwemeAuthSubStatus = "RENEW_FAIL" | ||
// AwemeAuthSubStatus_RENEW_SUCCESS 续期成功 | ||
AwemeAuthSubStatus_RENEW_SUCCESS AwemeAuthSubStatus = "RENEW_SUCCESS" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package enum | ||
|
||
// AwemeAuthType 授权类型 | ||
type AwemeAuthType string | ||
|
||
const ( | ||
// AwemeAuthType_AWEME_ACCOUNT 抖音号授权 | ||
AwemeAuthType_AWEME_ACCOUNT AwemeAuthType = "AWEME_ACCOUNT" | ||
// AwemeAuthType_VIDEO_ITEM 单视频授权 | ||
AwemeAuthType_VIDEO_ITEM AwemeAuthType = "VIDEO_ITEM" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package tools | ||
|
||
import ( | ||
"encoding/json" | ||
"net/url" | ||
"strconv" | ||
|
||
"github.com/bububa/oceanengine/marketing-api/enum" | ||
"github.com/bububa/oceanengine/marketing-api/model" | ||
) | ||
|
||
// AwemeAuthListRequest 获取抖音授权关系 | ||
type AwemeAuthListRequest struct { | ||
// AdvertiserID 广告主ID | ||
AdvertiserID uint64 `json:"advertiser_id,omitempty"` | ||
// Filtering 筛选条件 | ||
Filtering *AwemeAuthListFilter `json:"filtering,omitempty"` | ||
// Page 页码 | ||
Page int `json:"page,omitempty"` | ||
// PageSize 页面大小 | ||
PageSize int `json:"page_size,omitempty"` | ||
} | ||
|
||
// AwemeAuthListFilter 筛选条件 | ||
type AwemeAuthListFilter struct { | ||
// AuthType 授权类型,可选值: | ||
// AWEME_ACCOUNT: 抖音号授权、VIDEO_ITEM: 单视频授权 | ||
AuthType []enum.AwemeAuthType `json:"auth_type,omitempty"` | ||
// AuthStatus 授权状态, 可选值: | ||
// AUTHRIZED: 授权中、AUTHRIZING: 待授权确认、INVALID: 授权失效 | ||
AuthStatus []enum.AwemeAuthStatus `json:"auth_status,omitempty"` | ||
} | ||
|
||
// Encode implement GetRequest interface | ||
func (r AwemeAuthListRequest) Encode() string { | ||
values := &url.Values{} | ||
values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10)) | ||
if r.Filtering != nil { | ||
buf, _ := json.Marshal(r.Filtering) | ||
values.Set("filtering", string(buf)) | ||
} | ||
if r.Page > 1 { | ||
values.Set("page", strconv.Itoa(r.Page)) | ||
} | ||
if r.PageSize > 0 { | ||
values.Set("page_size", strconv.Itoa(r.PageSize)) | ||
} | ||
return values.Encode() | ||
} | ||
|
||
// AwemeAuthListResponse 获取抖音授权关系 | ||
type AwemeAuthListResponse struct { | ||
model.BaseResponse | ||
// Data json返回值 | ||
Data *AwemeAuthListData `json:"data,omitempty"` | ||
} | ||
|
||
// AwemeAuthListData . | ||
type AwemeAuthListData struct { | ||
// List . | ||
List []AwemeAuthItem `json:"list,omitempty"` | ||
// PageInfo . | ||
PageInfo *model.PageInfo `json:"page_info,omitempty"` | ||
} | ||
|
||
type AwemeAuthItem struct { | ||
// AuthType 授权类型 | ||
AuthType enum.AwemeAuthType `json:"auth_type,omitempty"` | ||
// AwemeID 抖音号 | ||
AwemeID string `json:"aweme_id,omitempty"` | ||
// AwemeName 抖音账号名称 | ||
AwemeName string `json:"aweme_name,omitempty"` | ||
// AuthStatus 授权状态 | ||
AuthStatus enum.AwemeAuthStatus `json:"auth_status,omitempty"` | ||
// SubStatus 授权子状态,返回值 | ||
// INVALID_CANCEL: 主动操作解除授权、INVALID_EXPIRED: 授权期限已到、INVALID_REJECT: C端拒绝授权、INVALID_TIME_OUT: 超时未确认、RENEWING: 续期待确认、RENEW_FAIL: 续期申请失效、RENEW_SUCCESS: 续期成功 | ||
SubStatus enum.AwemeAuthSubStatus `json:"sub_status,omitempty"` | ||
// StartTime 授权开始时间,格式为yyyy-MM-dd HH:mm:ss | ||
StartTime string `json:"start_time,omitempty"` | ||
// EndTime 授权结束时间,格式为yyyy-MM-dd HH:mm:ss | ||
EndTime string `json:"end_time,omitempty"` | ||
// VideoInfo 授权视频信息,若为单视频授权会返回 | ||
VideoInfo *AwemeAuthVideo `json:"video_info,omitempty"` | ||
} | ||
|
||
// AwemeAuthVideo 授权视频信息,若为单视频授权会返回 | ||
type AwemeAuthVideo struct { | ||
// ItemID 抖音视频ID | ||
ItemID uint64 `json:"item_id,omitempty"` | ||
// ImageMode 素材类型 | ||
ImageMode enum.ImageMode `json:"image_mode,omitempty"` | ||
// VideoID 视频ID | ||
VideoID string `json:"video_id,omitempty"` | ||
// Title 视频名称 | ||
Title string `json:"title,omitempty"` | ||
// AwemePlayURL 视频播放链接 | ||
AwemePlayURL string `json:"aweme_play_url,omitempty"` | ||
// Duration 视频时长,单位为秒 | ||
Duration float64 `json:"duration,omitempty"` | ||
// VideoCoverID 视频封面ID | ||
VideoCoverID string `json:"video_cover_id,omitempty"` | ||
// VideoCoverURL 视频封面链接 | ||
VideoCoverURL string `json:"video_cover_url,omitempty"` | ||
} |