-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjd_promote.go
229 lines (212 loc) · 8.65 KB
/
jd_promote.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
// jd联盟go-sdk
package jd
type PromotionService interface {
// 网站/APP获取推广链接接口
// 文档: https://union.jd.com/openplatform/api/10421
PromotionCommonGet(*PromoteCommonGetRequest) (*PromoteCommonGetResult, error)
// 社交媒体获取推广链接接口【申请】
// 文档: https://union.jd.com/openplatform/api/10424
PromotionBysubunionidGet(*PromotionBysubunionidGetRequest) (*PromotionBysubunionidGetResult, error)
// 工具商获取推广链接接口【申请】
// 文档: https://union.jd.com/openplatform/api/10425
PromotionByunionidGet(*PromotionByunionidGetRequest) (*PromotionByunionidGetResult, error)
// 通过小程序获取推广链接【申请】
// 文档: https://union.jd.com/openplatform/api/11793
PromotionAppletGet(request *PromotionAppletGetRequest) (*PromotionAppletGetResult, error)
// 网站/APP获取推广链接接口
// 文档: https://union.jd.com/openplatform/api/10421
PromotionCommonGetResult(*PromoteCommonGetRequest) ([]byte, error)
// 社交媒体获取推广链接接口【申请】
// 文档: https://union.jd.com/openplatform/api/10424
PromotionBysubunionidGetResult(*PromotionBysubunionidGetRequest) ([]byte, error)
// 工具商获取推广链接接口【申请】
// 文档: https://union.jd.com/openplatform/api/10425
PromotionByunionidGetResult(*PromotionByunionidGetRequest) ([]byte, error)
// 通过小程序获取推广链接【申请】
// 文档: https://union.jd.com/openplatform/api/11793
PromotionAppletGetResult(request *PromotionAppletGetRequest) ([]byte, error)
// 网站/APP获取推广链接接口
// 文档: https://union.jd.com/openplatform/api/10421
PromotionCommonGetMap(*PromoteCommonGetRequest) (map[string]interface{}, error)
// 社交媒体获取推广链接接口【申请】
// 文档: https://union.jd.com/openplatform/api/10424
PromotionBysubunionidGetMap(*PromotionBysubunionidGetRequest) (map[string]interface{}, error)
// 工具商获取推广链接接口【申请】
// 文档: https://union.jd.com/openplatform/api/10425
PromotionByunionidGetMap(*PromotionByunionidGetRequest) (map[string]interface{}, error)
// 通过小程序获取推广链接【申请】
// 文档: https://union.jd.com/openplatform/api/11793
PromotionAppletGetMap(request *PromotionAppletGetRequest) (map[string]interface{}, error)
}
type PromotionServiceImpl struct {
service Service
}
func newPromotionService(service Service) PromotionService {
return &PromotionServiceImpl{
service: service,
}
}
// 网站/APP获取推广链接接口
// 文档: https://union.jd.com/openplatform/api/10421
func (promo *PromotionServiceImpl) PromotionCommonGet(request *PromoteCommonGetRequest) (*PromoteCommonGetResult, error) {
err := promo.service.CheckRequiredParameters(request)
if err != nil {
return nil, err
}
param := map[string]interface{}{}
param["promotionCodeReq"] = request
var res PromoteCommonGetResult
err = promo.service.Do(&res, PromotionCommonGet, param)
return &res, err
}
// 社交媒体获取推广链接接口【申请】
// 文档: https://union.jd.com/openplatform/api/10424
func (promo *PromotionServiceImpl) PromotionBysubunionidGet(request *PromotionBysubunionidGetRequest) (*PromotionBysubunionidGetResult, error) {
err := promo.service.CheckRequiredParameters(request)
if err != nil {
return nil, err
}
param := map[string]interface{}{}
param["promotionCodeReq"] = request
var res PromotionBysubunionidGetResult
err = promo.service.Do(&res, PromotionBysubunionidGet, param)
return &res, err
}
// 工具商获取推广链接接口【申请】
// 文档: https://union.jd.com/openplatform/api/10425
func (promo *PromotionServiceImpl) PromotionByunionidGet(request *PromotionByunionidGetRequest) (*PromotionByunionidGetResult, error) {
err := promo.service.CheckRequiredParameters(request)
if err != nil {
return nil, err
}
param := map[string]interface{}{}
param["promotionCodeReq"] = request
var res PromotionByunionidGetResult
err = promo.service.Do(&res, PromotionByunionidGet, param)
return &res, err
}
// 通过小程序获取推广链接【申请】
// 文档: https://union.jd.com/openplatform/api/11793
func (promo *PromotionServiceImpl) PromotionAppletGet(request *PromotionAppletGetRequest) (*PromotionAppletGetResult, error) {
err := promo.service.CheckRequiredParameters(request)
if err != nil {
return nil, err
}
param := map[string]interface{}{}
param["promotionCodeReq"] = request
var res PromotionAppletGetResult
err = promo.service.Do(&res, PromotionAppletGet, param)
return &res, err
}
// 网站/APP获取推广链接接口
// 文档: https://union.jd.com/openplatform/api/10421
func (promo *PromotionServiceImpl) PromotionCommonGetResult(request *PromoteCommonGetRequest) ([]byte, error) {
res, err := promo.PromotionCommonGet(request)
return promo.service.GetResult(res, err)
}
// 社交媒体获取推广链接接口【申请】
// 文档: https://union.jd.com/openplatform/api/10424
func (promo *PromotionServiceImpl) PromotionBysubunionidGetResult(request *PromotionBysubunionidGetRequest) ([]byte, error) {
res, err := promo.PromotionBysubunionidGet(request)
return promo.service.GetResult(res, err)
}
// 工具商获取推广链接接口【申请】
// 文档: https://union.jd.com/openplatform/api/10425
func (promo *PromotionServiceImpl) PromotionByunionidGetResult(request *PromotionByunionidGetRequest) ([]byte, error) {
res, err := promo.PromotionByunionidGet(request)
return promo.service.GetResult(res, err)
}
// 通过小程序获取推广链接【申请】
// 文档: https://union.jd.com/openplatform/api/11793
func (promo *PromotionServiceImpl) PromotionAppletGetResult(request *PromotionAppletGetRequest) ([]byte, error) {
res, err := promo.PromotionAppletGet(request)
return promo.service.GetResult(res, err)
}
// 网站/APP获取推广链接接口
// 文档: https://union.jd.com/openplatform/api/10421
func (promo *PromotionServiceImpl) PromotionCommonGetMap(request *PromoteCommonGetRequest) (map[string]interface{}, error) {
err := promo.service.CheckRequiredParameters(request)
if err != nil {
return nil, err
}
param := map[string]interface{}{}
param["promotionCodeReq"] = request
var res = make(map[string]interface{})
err = promo.service.Do(&res, PromotionCommonGet, param)
if err != nil {
return nil, err
}
var key ResponseKey
if promo.service.GetRouteApi() == JosRootEndpoint {
key = PromotionCommonGetResponce
} else {
key = PromotionCommonGetResponse
}
return promo.service.ParseResult(res, key)
}
// 社交媒体获取推广链接接口【申请】
// 文档: https://union.jd.com/openplatform/api/10424
func (promo *PromotionServiceImpl) PromotionBysubunionidGetMap(request *PromotionBysubunionidGetRequest) (map[string]interface{}, error) {
err := promo.service.CheckRequiredParameters(request)
if err != nil {
return nil, err
}
param := map[string]interface{}{}
param["promotionCodeReq"] = request
var res map[string]interface{}
err = promo.service.Do(&res, PromotionBysubunionidGet, param)
if err != nil {
return nil, err
}
var key ResponseKey
if promo.service.GetRouteApi() == JosRootEndpoint {
key = PromotionBysubunionidGetResponce
} else {
key = PromotionBysubunionidGetResponse
}
return promo.service.ParseResult(res, key)
}
// 工具商获取推广链接接口【申请】
// 文档: https://union.jd.com/openplatform/api/10425
func (promo *PromotionServiceImpl) PromotionByunionidGetMap(request *PromotionByunionidGetRequest) (map[string]interface{}, error) {
err := promo.service.CheckRequiredParameters(request)
if err != nil {
return nil, err
}
param := map[string]interface{}{}
param["promotionCodeReq"] = request
var res map[string]interface{}
err = promo.service.Do(&res, PromotionByunionidGet, param)
if err != nil {
return nil, err
}
var key ResponseKey
if promo.service.GetRouteApi() == JosRootEndpoint {
key = PromotionByunionidGetResponce
} else {
key = PromotionByunionidGetResponse
}
return promo.service.ParseResult(res, key)
}
// 通过小程序获取推广链接【申请】
// 文档: https://union.jd.com/openplatform/api/11793
func (promo *PromotionServiceImpl) PromotionAppletGetMap(request *PromotionAppletGetRequest) (map[string]interface{}, error) {
err := promo.service.CheckRequiredParameters(request)
if err != nil {
return nil, err
}
param := map[string]interface{}{}
param["promotionCodeReq"] = request
var res map[string]interface{}
err = promo.service.Do(&res, PromotionAppletGet, param)
if err != nil {
return nil, err
}
var key ResponseKey
if promo.service.GetRouteApi() == JosRootEndpoint {
key = PromotionAppletGetResponce
} else {
key = PromotionAppletGetResponse
}
return promo.service.ParseResult(res, key)
}