-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjd_coupon.go
122 lines (108 loc) · 4.09 KB
/
jd_coupon.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
// jd联盟go-sdk
package jd
type CouponService interface {
// 优惠券领取情况查询接口【申请】
// 文档: https://union.jd.com/openplatform/api/10423
CouponQuery([]*CouponQueryRequest) (*CouponQueryResult, error)
// 优惠券领取情况查询接口【申请】
// 文档: https://union.jd.com/openplatform/api/10423
CouponQueryByUrls(urls ...string) (*CouponQueryResult, error)
// 优惠券领取情况查询接口【申请】
// Deprecated: 使用 CouponQueryByUrls
// 文档: https://union.jd.com/openplatform/api/10423
CouponQueryByList(urls ...string) (*CouponQueryResult, error)
// 优惠券领取情况查询接口【申请】
// 文档: https://union.jd.com/openplatform/api/10423
CouponQueryResult(request []*CouponQueryRequest) ([]byte, error)
// 优惠券领取情况查询接口【申请】
// 文档: https://union.jd.com/openplatform/api/10423
CouponQueryResultByUrls(urls ...string) ([]byte, error)
// 优惠券领取情况查询接口【申请】
// 文档: https://union.jd.com/openplatform/api/10423
CouponQueryMap(request []*CouponQueryRequest) (map[string]interface{}, error)
// 优惠券领取情况查询接口【申请】
// 文档: https://union.jd.com/openplatform/api/10423
CouponQueryMapByUrls(urls ...string) (map[string]interface{}, error)
}
type CouponServiceImpl struct {
service Service
}
func newCouponService(service Service) CouponService {
return &CouponServiceImpl{
service: service,
}
}
// 优惠券领取情况查询接口【申请】
// 文档: https://union.jd.com/openplatform/api/10423
func (cou *CouponServiceImpl) CouponQuery(request []*CouponQueryRequest) (*CouponQueryResult, error) {
err := cou.service.CheckRequiredParameters(request)
if err != nil {
return nil, err
}
param := map[string]interface{}{}
param["couponUrls"] = request
var res CouponQueryResult
err = cou.service.Do(&res, CouponQuery, param)
return &res, err
}
// 优惠券领取情况查询接口【申请】
// 文档: https://union.jd.com/openplatform/api/10423
func (cou *CouponServiceImpl) CouponQueryByUrls(urls ...string) (*CouponQueryResult, error) {
var arr []*CouponQueryRequest
for _, url := range urls {
arr = append(arr, &CouponQueryRequest{
CouponUrl: url,
})
}
return cou.CouponQuery(arr)
}
// 优惠券领取情况查询接口【申请】
// Deprecated: 使用 CouponQueryByUrls
// 文档: https://union.jd.com/openplatform/api/10423
func (cou *CouponServiceImpl) CouponQueryByList(urls ...string) (*CouponQueryResult, error) {
return cou.CouponQueryByUrls(urls...)
}
// 优惠券领取情况查询接口【申请】
// 文档: https://union.jd.com/openplatform/api/10423
func (cou *CouponServiceImpl) CouponQueryResult(request []*CouponQueryRequest) ([]byte, error) {
res, err := cou.CouponQuery(request)
return cou.service.GetResult(res, err)
}
// 优惠券领取情况查询接口【申请】
// 文档: https://union.jd.com/openplatform/api/10423
func (cou *CouponServiceImpl) CouponQueryResultByUrls(urls ...string) ([]byte, error) {
return cou.service.GetResult(cou.CouponQueryByUrls(urls...))
}
// 优惠券领取情况查询接口【申请】
// 文档: https://union.jd.com/openplatform/api/10423
func (cou *CouponServiceImpl) CouponQueryMap(request []*CouponQueryRequest) (map[string]interface{}, error) {
err := cou.service.CheckRequiredParameters(request)
if err != nil {
return nil, err
}
param := map[string]interface{}{}
param["couponUrls"] = request
var res map[string]interface{}
err = cou.service.Do(&res, CouponQuery, param)
if err != nil {
return nil, err
}
var key ResponseKey
if cou.service.GetRouteApi() == JosRootEndpoint {
key = CouponQueryResponce
} else {
key = CouponQueryResponse
}
return cou.service.ParseResult(res, key)
}
// 优惠券领取情况查询接口【申请】
// 文档: https://union.jd.com/openplatform/api/10423
func (cou *CouponServiceImpl) CouponQueryMapByUrls(urls ...string) (map[string]interface{}, error) {
var arr []*CouponQueryRequest
for _, url := range urls {
arr = append(arr, &CouponQueryRequest{
CouponUrl: url,
})
}
return cou.CouponQueryMap(arr)
}