-
Notifications
You must be signed in to change notification settings - Fork 42
/
keywords_get.go
55 lines (48 loc) · 1.49 KB
/
keywords_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
package ad
import (
"strconv"
"github.com/bububa/oceanengine/marketing-api/model"
"github.com/bububa/oceanengine/marketing-api/util"
)
// KeywordsGetRequest 获取计划的搜索关键词 API Request
type KeywordsGetRequest struct {
// AdvertiserID 千川广告账户id
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// Filtering 过滤条件
Filtering *KeywordsGetFilter `json:"filtering,omitempty"`
// Page 页码,从 1 开始,默认1
Page int `json:"page,omitempty"`
// PageSize 每页数目,上限500,默认100
PageSize int `json:"page_size,omitempty"`
}
type KeywordsGetFilter struct {
// AdID 待获取搜索关键词的计划ID
AdID uint64 `json:"ad_id,omitempty"`
}
// Encode implement GetRequest interface
func (r KeywordsGetRequest) Encode() string {
values := util.GetUrlValues()
values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10))
if r.Filtering != nil {
values.Set("filtering", string(util.JSONMarshal(r.Filtering)))
}
if r.Page > 0 {
values.Set("page", strconv.Itoa(r.Page))
}
if r.PageSize > 0 {
values.Set("page_size", strconv.Itoa(r.PageSize))
}
ret := values.Encode()
util.PutUrlValues(values)
return ret
}
// KeywordsGetResponse 获取计划的搜索关键词 API Response
type KeywordsGetResponse struct {
model.BaseResponse
Data *KeywordsGetResult `json:"data,omitempty"`
}
type KeywordsGetResult struct {
// List 关键词列表
List []Keyword `json:"list,omitempty"`
PageInfo *model.PageInfo `json:"page_info,omitempty"`
}