-
Notifications
You must be signed in to change notification settings - Fork 40
/
assets_get.go
83 lines (76 loc) · 2.57 KB
/
assets_get.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package eventmanager
import (
"encoding/json"
"strconv"
"github.com/bububa/oceanengine/marketing-api/enum"
"github.com/bububa/oceanengine/marketing-api/model"
"github.com/bububa/oceanengine/marketing-api/util"
)
// AssetsGetRequest 获取已创建资产列表 API Request
type AssetsGetRequest struct {
// AdvertiserID 广告主 id
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// AssetType 资产类型,允许值:THIRD_EXTERNAL:三方落地页
AssetType enum.AssetType `json:"asset_type,omitempty"`
// Filtering 过滤条件
Filtering *AssetsGetFiltering `json:"filtering,omitempty"`
// SortType 排序方式,允许值:ASC:升序 DESC:降序
// 默认值ASC
SortType enum.OrderType `json:"sort_type,omitempty"`
// Page 页码,默认值1
Page int `json:"page,omitempty"`
// PageSize 页面大小,默认值10,最大30
PageSize int `json:"page_size,omitempty"`
}
// AssetsGetFiltering 过滤条件
type AssetsGetFiltering struct {
// LandingPage 三方落地页数据
LandingPage *AssetBaseInfo `json:"landing_page,omitempty"`
// QuickApp 快应用数据
QuickApp *QuickApp `json:"quick_app,omitempty"`
// App 应用数据
App *App `json:"app,omitempty"`
// MiniProgram 字节小程序快应用资产
MiniProgram *AssetBaseInfo `json:"mini_program,omitempty"`
}
// Encode implement GetRequest interface
func (r AssetsGetRequest) Encode() string {
values := util.GetUrlValues()
values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10))
values.Set("asset_type", string(r.AssetType))
if r.Page > 0 {
values.Set("page", strconv.Itoa(r.Page))
}
if r.PageSize > 0 {
values.Set("page_size", strconv.Itoa(r.PageSize))
}
if r.Filtering != nil {
filtering, _ := json.Marshal(r.Filtering)
values.Set("filtering", string(filtering))
}
if r.SortType != "" {
values.Set("sort_type", string(r.SortType))
}
ret := values.Encode()
util.PutUrlValues(values)
return ret
}
// AssetsGetResponse 获取已创建资产列表 API Response
type AssetsGetResponse struct {
model.BaseResponse
// Data json返回值
Data *AssetsGetResponseData `json:"data,omitempty"`
}
// AssetsGetResponseData json返回值
type AssetsGetResponseData struct {
// LandingPages 三方数据集合
LandingPages []LandingPage `json:"landing_pages,omitempty"`
// QuickApp 快应用数据
QuickApp []QuickApp `json:"quick_app,omitempty"`
// App 应用数据`
App []App `json:"app,omitempty"`
// MiniProgram 字节小程序快应用资产
MiniProgram []MiniProgram `json:"mini_program,omitempty"`
// PageInfo 分页信息
PageInfo *model.PageInfo `json:"page_info,omitempty"`
}