-
Notifications
You must be signed in to change notification settings - Fork 3
/
setShopLevelRule.go
executable file
·64 lines (52 loc) · 1.71 KB
/
setShopLevelRule.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
package crm
import (
"github.com/XiBao/jos/api"
"github.com/XiBao/jos/sdk"
"github.com/XiBao/jos/sdk/request/crm"
)
type SetShopLevelRuleRequest struct {
api.BaseRequest
CustomerLevelName []string `json:"customerLevelName,omitempty"` //按顺序填写店铺会员等级名称
}
type SetShopLevelRuleResponse struct {
ErrorResp *api.ErrorResponnse `json:"error_response,omitempty" codec:"error_response,omitempty"`
Data *SetShopLevelRuleData `json:"jingdong_pop_crm_setShopLevelRule_responce,omitempty" codec:"jingdong_pop_crm_setShopLevelRule_responce,omitempty"`
}
func (r SetShopLevelRuleResponse) IsError() bool {
return r.ErrorResp != nil || r.Data == nil || r.Data.IsError()
}
func (r SetShopLevelRuleResponse) Error() string {
if r.ErrorResp != nil {
return r.ErrorResp.Error()
}
if r.Data != nil {
return r.Data.Error()
}
return "no result data"
}
type SetShopLevelRuleData struct {
ReturnType *ReturnType `json:"returnType,omitempty" codec:"returnType,omitempty"`
}
func (r SetShopLevelRuleData) IsError() bool {
return r.ReturnType == nil || r.ReturnType.IsError()
}
func (r SetShopLevelRuleData) Error() string {
if r.ReturnType != nil {
return r.ReturnType.Error()
}
return "no result data"
}
// TODO 修改会员体系规则
func SetShopLevelRule(req *SetShopLevelRuleRequest) (bool, error) {
client := sdk.NewClient(req.AnApiKey.Key, req.AnApiKey.Secret)
client.Debug = req.Debug
r := crm.NewSetShopLevelRuleRequest()
if len(req.CustomerLevelName) > 0 {
r.SetCustomerLevelName(req.CustomerLevelName)
}
var response SetShopLevelRuleResponse
if err := client.Execute(r.Request, req.Session, &response); err != nil {
return false, err
}
return response.Data.ReturnType.Data, nil
}