-
Notifications
You must be signed in to change notification settings - Fork 3
/
groupModelList.go
executable file
·94 lines (79 loc) · 3.39 KB
/
groupModelList.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
package crm
import (
"github.com/XiBao/jos/api"
"github.com/XiBao/jos/sdk"
crm "github.com/XiBao/jos/sdk/request/crm/shopGift"
)
type ShopGiftGroupModelListRequest struct {
api.BaseRequest
Channel uint8 `json:"channel" codec:"channel"` // 渠道来源,pc:1 app:2 等
}
type ShopGiftGroupModelListResponse struct {
ErrorResp *api.ErrorResponnse `json:"error_response,omitempty" codec:"error_response,omitempty"`
Data *ShopGiftGroupModelListData `json:"jingdong_pop_crm_shopGift_getGroupModelList_responce,omitempty" codec:"jingdong_pop_crm_shopGift_getGroupModelList_responce,omitempty"`
}
func (r ShopGiftGroupModelListResponse) IsError() bool {
return r.ErrorResp != nil || r.Data == nil || r.Data.IsError()
}
func (r ShopGiftGroupModelListResponse) Error() string {
if r.ErrorResp != nil {
return r.ErrorResp.Error()
}
if r.Data != nil {
return r.Data.Error()
}
return "no result data"
}
type ShopGiftGroupModelListData struct {
Code string `json:"code,omitempty" codec:"code,omitempty"`
ErrorDesc string `json:"error_description,omitempty" codec:"error_description,omitempty"`
Result *ShopGiftGroupModelListResult `json:"commonResult,omitempty" codec:"commonResult,omitempty"`
}
func (r ShopGiftGroupModelListData) IsError() bool {
return r.Code != "0" || r.Result == nil || r.Result.IsError()
}
func (r ShopGiftGroupModelListData) Error() string {
if r.Result != nil && r.Result.IsError() {
return r.Result.Error()
}
return sdk.ErrorString(r.Code, r.ErrorDesc)
}
type ShopGiftGroupModelListResult struct {
Code string `json:"code,omitempty" codec:"code,omitempty"`
Desc string `json:"desc,omitempty" codec:"desc,omitempty"`
Data []ShopGiftGroupModel `json:"data,omitempty" codec:"data,omitempty"`
}
func (r ShopGiftGroupModelListResult) IsError() bool {
return r.Code != "200"
}
func (r ShopGiftGroupModelListResult) Error() string {
return sdk.ErrorString(r.Code, r.Desc)
}
type ShopGiftGroupModel struct {
Id uint64 `json:"id"` // 人群id
VenderId int `json:"venderId"` // 商家id
ModelId int `json:"modelId"` // 人群模型id
ModelName string `json:"modelName"` // 人群名称
ModelDesc string `json:"modelDesc"` // 人群名称描述
SRange string `json:"range,omitempty"` // 范围
RuleExp string `json:"ruleExp"` // 规则
IsDelete uint8 `json:"isDelete"` // 是否删除
CreateTime uint64 `json:"createTime"` // 创建时间
ModifyTime uint64 `json:"modifyTime"` // 修改时间
ModelNum uint `json:"modelNum"` // 模型数
ModelType uint `json:"modelType"` // 模型类型
TaskId uint64 `json:"taskId,omitempty"` // 任务id
Status int `json:"status"` // 状态
ModelDescList []string `json:"modelDescList"` // 人群信息描述
}
func ShopGiftGroupModelList(req *ShopGiftGroupModelListRequest) ([]ShopGiftGroupModel, error) {
client := sdk.NewClient(req.AnApiKey.Key, req.AnApiKey.Secret)
client.Debug = req.Debug
r := crm.NewShopGiftGroupModelListRequest()
r.SetChannel(req.Channel)
var response ShopGiftGroupModelListResponse
if err := client.Execute(r.Request, req.Session, &response); err != nil {
return nil, err
}
return response.Data.Result.Data, nil
}