-
Notifications
You must be signed in to change notification settings - Fork 42
/
select.go
61 lines (55 loc) · 1.7 KB
/
select.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
package adconvert
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"
)
// SelectRequest 转化目标列表 API Request
type SelectRequest struct {
// AdvertiserID 广告主ID
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// ConvertIDs 指定需要查询的转化目标ID,如不填写默认返回所有的转化目标ID
ConvertIDs []uint64 `json:"convert_id,omitempty"`
// OptStatus 转化工具操作状态
OptStatus enum.AdConvertOptStatus `json:"opt_status,omitempty"`
// Page 页数
Page int `json:"page,omitempty"`
// PageSize 页面大小
PageSize int `json:"page_size,omitempty"`
}
// Encode implement GetRequest interface
func (r SelectRequest) Encode() string {
values := util.GetUrlValues()
values.Add("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10))
if len(r.ConvertIDs) > 0 {
buf, _ := json.Marshal(r.ConvertIDs)
values.Add("convert_ids", string(buf))
}
if r.OptStatus != "" {
values.Add("opt_status", string(r.OptStatus))
}
if r.Page > 1 {
values.Add("page", strconv.Itoa(r.Page))
}
if r.PageSize > 0 {
values.Add("page_size", strconv.Itoa(r.PageSize))
}
ret := values.Encode()
util.PutUrlValues(values)
return ret
}
// SelectResponse 转化目标列表 API Response
type SelectResponse struct {
model.BaseResponse
// Data json返回值
Data *SelectResponseData `json:"data,omitempty"`
}
// SelectResponseData json返回值
type SelectResponseData struct {
// PageInfo 分页相关信息
PageInfo *model.PageInfo `json:"page_info,omitempty"`
// List 转化的数据list
List []Convert `json:"ad_convert_list,omitempty"`
}