-
Notifications
You must be signed in to change notification settings - Fork 43
/
assets_list.go
67 lines (60 loc) · 1.88 KB
/
assets_list.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
package dpa
import (
"encoding/json"
"strconv"
"github.com/bububa/oceanengine/marketing-api/model"
"github.com/bububa/oceanengine/marketing-api/util"
)
// AssetsListRequest 获取投放条件列表 API Request
type AssetsListRequest struct {
// AdvertiserID 广告主ID
AdvertiserID uint64 `json:"advertiser_id,omitempty"`
// PlatformID 商品库ID
PlatformID uint64 `json:"platform_id,omitempty"`
// ProductIDs 商品ID列表
ProductIDs []uint64 `json:"product_ids,omitempty"`
// Filtering 过滤条件
Filtering *AssetsListFilter `json:"filtering,omitempty"`
// Page 页码, 默认值: 1
Page int `json:"page,omitempty"`
// PageSize 页面数据量, 默认值: 10,最大 100
PageSize int `json:"page_size,omitempty"`
}
// AssetsListFilter 过滤条件
type AssetsListFilter struct {
// Status 物件状态, 0代表暂停, 1代表启用
Status int `json:"status"`
}
// Encode implement GetRequest interface
func (r AssetsListRequest) Encode() string {
values := util.GetUrlValues()
values.Set("advertiser_id", strconv.FormatUint(r.AdvertiserID, 10))
values.Set("platform_id", strconv.FormatUint(r.PlatformID, 10))
bs, _ := json.Marshal(r.ProductIDs)
values.Set("product_ids", string(bs))
if r.Filtering != nil {
bs, _ := json.Marshal(r.Filtering)
values.Set("filtering", string(bs))
}
if r.Page > 1 {
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
}
// AssetsListResponse 获取投放条件列表 API Response
type AssetsListResponse struct {
model.BaseResponse
Data *AssetsListResponseData `json:"data,omitempty"`
}
// AssetsListResponseData
type AssetsListResponseData struct {
// PageInfo 分页信息
PageInfo *model.PageInfo `json:"page_info,omitempty"`
// List 商品库商品列表
List []Asset `json:"list,omitempty"`
}