-
Notifications
You must be signed in to change notification settings - Fork 41
/
promotion_get.go
138 lines (130 loc) · 4.76 KB
/
promotion_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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package v3
import (
"encoding/json"
"strconv"
"time"
"github.com/bububa/oceanengine/marketing-api/enum"
"github.com/bububa/oceanengine/marketing-api/model"
"github.com/bububa/oceanengine/marketing-api/util"
)
// PromotionGetRequest 广告数据报表 API Request
type PromotionGetRequest struct {
// AdvertiserID 广告主ID
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// StartDate 起始日期,格式YYYY-MM-DD,只支持查询2016-10-26及以后的日期
StartDate time.Time `json:"start_date,omitempty"`
// EndDate 结束日期,格式YYYY-MM-DD,只支持查询2016-10-26及以后的日期,时间跨度不能超过30天
EndDate time.Time `json:"end_date,omitempty"`
// Fields 指定需要的指标名称
Fields []string `json:"fields,omitempty"`
// GroupBy 分组条件默认为 STAT_GROUP_BY_FIELD_STAT_TIME
GroupBy []enum.StatGroupBy `json:"group_by,omitempty"`
// TimeGranularity 时间粒度, 默认值: STAT_TIME_GRANULARITY_DAILY
TimeGranularity enum.StatTimeGranularity `json:"time_granularity,omitempty"`
// OrderField 排序字段,所有的统计指标均可参与排序
OrderField string `json:"order_field,omitempty"`
// OrderType 排序方式;默认值: DESC;允许值: ASC, DESC
OrderType enum.OrderType `json:"order_type,omitempty"`
// Page 页码;默认值: 1
Page int `json:"page,omitempty"`
// PageSize 页面大小,即每页展示的数据量;默认值: 20;取值范围: 1-1000
PageSize int `json:"page_size,omitempty"`
// Filtering 过滤字段,json格式,支持字段如下
Filtering *PromotionGetFilter `json:"filtering,omitempty"`
}
// PromotionGetFilter 数据报表过滤条件
type PromotionGetFilter struct {
// PromotionID 广告ID,按照promotion_id过滤,最多支持100个
PromotionID []uint64 `json:"promotion_id,omitempty"`
// LandingType 推广目的,允许值:APP
LandingType []enum.LandingType `json:"landing_type,omitempty"`
// ExternalAction 转化目标,允许值:AD_CONVERT_TYPE_NOTIFY_DOWNLOAD
// AD_CONVERT_TYPE_DOWNLOAD_FINISH
// AD_CONVERT_TYPE_INSTALL_FINISH
// AD_CONVERT_TYPE_ACTIVE
// AD_CONVERT_TYPE_ACTIVE_REGISTER
// AD_CONVERT_TYPE_GAME_ADDICTION
// AD_CONVERT_TYPE_PAY
ExternalAction []enum.AdConvertType `json:"external_action,omitempty"`
// AppCode 首选位置,西瓜视频[1]
// 抖音火山版:[3]
// 抖音短视频[4]
// 今日头条:[8]
// 番茄小说:[26]
// 穿山甲:[9]
// Ohayoo精品游戏:[27]
AppCode []int `json:"app_code,omitempty"`
// Platform 平台,允许值:ANDROID 安卓、IOS 苹果、OTHER 其他
Platform []enum.AudiencePlatform
// PackageName 应用包名
PackageName []string `json:"package_name,omitempty"`
// DeliveryMode 投放模式筛选。允许值: MANUAL 手动、PROCEDURAL 自动
DeliveryMode []string `json:"delivery_mode,omitempty"`
}
// Encode implement GetRequest interface
func (r PromotionGetRequest) Encode() string {
values := util.GetUrlValues()
values.Set("start_date", r.StartDate.Format("2006-01-02"))
values.Set("end_date", r.EndDate.Format("2006-01-02"))
if r.AdvertiserID > 0 {
values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10))
}
if len(r.Fields) > 0 {
fields, _ := json.Marshal(r.Fields)
values.Set("fields", string(fields))
}
if r.GroupBy != nil {
groupBy, _ := json.Marshal(r.GroupBy)
values.Set("group_by", string(groupBy))
}
if r.TimeGranularity != "" {
values.Set("time_granularity", string(r.TimeGranularity))
}
if r.OrderField != "" {
values.Set("order_field", r.OrderField)
}
if r.OrderType != "" {
values.Set("order_type", string(r.OrderType))
}
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))
}
ret := values.Encode()
util.PutUrlValues(values)
return ret
}
// PromotionGetResponse 广告数据报表 API Response
type PromotionGetResponse struct {
model.BaseResponse
// Data json返回值
Data *PromotionGetResult `json:"data,omitempty"`
}
// PromotionGetResult 返回值
type PromotionGetResult struct {
// List 数据列表
List []PromotionGetListItem `json:"list,omitempty"`
// PageInfo 分页信息
PageInfo *model.PageInfo `json:"page_info,omitempty"`
}
// PromotionGetListItem 数据详情
type PromotionGetListItem struct {
// ProjectID 项目ID
ProjectID uint64 `json:"project_id,omitempty"`
// ProjectName 项目名称
ProjectName string `json:"project_name,omitempty"`
// PromotionID 广告ID
PromotionID uint64 `json:"promotion_id,omitempty"`
// PromotionName 广告名称
PromotionName string `json:"promotion_name,omitempty"`
// StatDatetime 数据时间
StatDatetime string `json:"stat_datetime,omitempty"`
// Data
Data []Stat `json:"data,omitempty"`
}