This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathproducts.go
227 lines (208 loc) · 9.48 KB
/
products.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
package mws
type ProductService struct {
*AmazonClient
}
//Products 创建商品服务
func NewProductService() *ProductService {
return &ProductService{
AmazonClient: newAmazonClient("/Products/2011-10-01", "2011-10-01"),
}
}
//ListMatchingProducts 根据搜索查询返回产品及其属性的列表。
func (s *ProductService) ListMatchingProducts(c *Credential, marketplaceId, query string, params ...Values) (string, *ListMatchingProductsResult, error) {
data := ActionValues("ListMatchingProducts")
data.Set("MarketplaceId", marketplaceId)
data.Set("Query", query)
//data.Set("QueryContextId",queryContextId)
data.SetAll(params...)
var result struct {
BaseResponse
Result *ListMatchingProductsResult `xml:"ListMatchingProductsResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
//GetMatchingProduct 根据ASIN值列表返回产品及其属性的列表。
func (s *ProductService) GetMatchingProduct(c *Credential, marketplaceId string, asinList ...string) (string, []*GetMatchingProductResult, error) {
data := ActionValues("GetMatchingProduct")
data.Set("MarketplaceId", marketplaceId)
data.Sets("ASINList.ASIN", asinList...)
var result struct {
BaseResponse
Result []*GetMatchingProductResult `xml:"GetMatchingProductResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
//GetMatchingProductForId 根据ASIN,GCID,SellerSKU,UPC,EAN,ISBN和JAN值的列表返回产品及其属性的列表。
func (s *ProductService) GetMatchingProductForId(c *Credential, marketplaceId, idType string, idList ...string) (string, []*GetMatchingProductForIdResult, error) {
data := ActionValues("GetMatchingProductForId")
data.Set("MarketplaceId", marketplaceId)
data.Set("IdType", string(idType))
data.Sets("IdList.Id", idList...)
var result struct {
BaseResponse
Result []*GetMatchingProductForIdResult `xml:"GetMatchingProductForIdResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
//GetCompetitivePricingForSKU 根据SellerSKU返回产品的当前有竞争力的价格。
func (s *ProductService) GetCompetitivePricingForSKU(c *Credential, marketplaceId string, sellerSKUList ...string) (string, []*GetCompetitivePricingForSKUResult, error) {
data := ActionValues("GetCompetitivePricingForSKU")
data.Set("MarketplaceId", marketplaceId)
data.Sets("SellerSKUList.SellerSKU", sellerSKUList...)
var result struct {
BaseResponse
Result []*GetCompetitivePricingForSKUResult `xml:"GetCompetitivePricingForSKUResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
//GetCompetitivePricingForASIN 根据ASIN返回产品的当前竞争价格。
func (s *ProductService) GetCompetitivePricingForASIN(c *Credential, marketplaceId string, asinList ...string) (string, []*GetCompetitivePricingForASINResult, error) {
data := ActionValues("GetCompetitivePricingForASIN")
data.Set("MarketplaceId", marketplaceId)
data.Sets("ASINList.ASIN", asinList...)
var result struct {
BaseResponse
Result []*GetCompetitivePricingForASINResult `xml:"GetCompetitivePricingForASINResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
//GetLowestOfferListingsForSKUResult
type GetLowestOfferListingsForSKUResult struct {
AllOfferListingsConsidered bool `xml:"AllOfferListingsConsidered"`
Product ProductType `xml:"Product"`
}
//GetLowestOfferListingsForSKU 根据SellerSKU返回最多20种产品的最低价格有效报价清单的定价信息。
func (s *ProductService) GetLowestOfferListingsForSKU(c *Credential, marketplaceId string, sellerSKUList ...string) (string, []*GetLowestOfferListingsForSKUResult, error) {
data := ActionValues("GetLowestOfferListingsForSKU")
data.Set("MarketplaceId", marketplaceId)
data.Sets("SellerSKUList.SellerSKU", sellerSKUList...)
//data.Set("ItemCondition", string(itemCondition))
var result struct {
BaseResponse
Result []*GetLowestOfferListingsForSKUResult `xml:"GetLowestOfferListingsForSKUResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
//GetLowestOfferListingsForASINResult
type GetLowestOfferListingsForASINResult struct {
AllOfferListingsConsidered bool `xml:"AllOfferListingsConsidered"`
Product ProductType `xml:"Product"`
}
//GetLowestOfferListingsForASIN 返回基于ASIN的多达20种产品的最低价格有效报价清单的定价信息。
func (s *ProductService) GetLowestOfferListingsForASIN(c *Credential, marketplaceId string, asinList ...string) (string, []*GetLowestOfferListingsForASINResult, error) {
data := ActionValues("GetLowestOfferListingsForASIN")
data.Set("MarketplaceId", marketplaceId)
data.Sets("ASINList.ASIN", asinList...)
//data.Set("ItemCondition", string(itemCondition))
var result struct {
BaseResponse
Result []*GetLowestOfferListingsForASINResult `xml:"GetLowestOfferListingsForASINResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
//GetLowestPricedOffersForSKU TODO:根据SellerSKU返回单个产品的最低报价。 http://docs.developer.amazonservices.com/en_US/products/Products_GetLowestPricedOffersForSKU.html
func (s *ProductService) GetLowestPricedOffersForSKU(c *Credential, marketplaceId, sellerSKU, itemCondition string) (string, *GetLowestPricedOffersForSKUResult, error) {
data := ActionValues("GetLowestPricedOffersForSKU")
data.Set("MarketplaceId", marketplaceId)
data.Set("SellerSKU", sellerSKU)
data.Set("ItemCondition", itemCondition)
var result struct {
BaseResponse
Result *GetLowestPricedOffersForSKUResult `xml:"GetLowestPricedOffersForSKUResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
//GetLowestPricedOffersForASIN TODO:根据ASIN返回单个产品的最低报价。 http://docs.developer.amazonservices.com/en_US/products/Products_GetLowestPricedOffersForASIN.html
func (s *ProductService) GetLowestPricedOffersForASIN(c *Credential, marketplaceId, asin, itemCondition string) {
data := ActionValues("GetLowestPricedOffersForASIN")
data.Set("MarketplaceId", marketplaceId)
data.Set("ASIN", asin)
data.Set("ItemCondition", string(itemCondition))
}
//GetMyFeesEstimate TODO:返回产品列表的估计费用。 http://docs.developer.amazonservices.com/en_US/products/Products_GetMyFeesEstimate.html
func (s *ProductService) GetMyFeesEstimate(c *Credential, marketplaceId string) {
data := ActionValues("GetMyFeesEstimate")
data.Set("MarketplaceId", marketplaceId)
}
//GetMyPriceForSKU 根据SellerSKU返回您自己的活动商品清单的定价信息。
func (s *ProductService) GetMyPriceForSKU(c *Credential, marketplaceId string, sellerSKUList ...string) (string, []*GetMyPriceForSKUResult, error) {
data := ActionValues("GetMyPriceForSKU")
data.Set("MarketplaceId", marketplaceId)
data.Sets("SellerSKUList.SKU", sellerSKUList...)
//data.Set("ItemCondition", string(itemCondition))
var result struct {
BaseResponse
Result []*GetMyPriceForSKUResult `xml:"GetMyPriceForSKUResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
//GetMyPriceForASIN 根据ASIN返回您自己的活动商品清单的定价信息。
func (s *ProductService) GetMyPriceForASIN(c *Credential, marketplaceId string, asinList ...string) (string, []*GetMyPriceForASINResult, error) {
data := ActionValues("GetMyPriceForASIN")
data.Set("MarketplaceId", marketplaceId)
data.Sets("ASINList.ASIN", asinList...)
//data.Set("ItemCondition", string(itemCondition))
var result struct {
BaseResponse
Result []*GetMyPriceForASINResult `xml:"GetMyPriceForASINResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
//GetProductCategoriesForSKU 根据SellerSKU返回产品所属的产品类别和父类别。
func (s *ProductService) GetProductCategoriesForSKU(c *Credential, marketplaceId, sellerSKU string) (string, *GetProductCategoriesForSKUResult, error) {
data := ActionValues("GetProductCategoriesForSKU")
data.Set("MarketplaceId", marketplaceId)
data.Set("SellerSKU", sellerSKU)
var result struct {
BaseResponse
Result *GetProductCategoriesForSKUResult `xml:"GetProductCategoriesForSKUResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
//GetProductCategoriesForASIN 根据ASIN返回产品所属的产品类别和父类别。
func (s *ProductService) GetProductCategoriesForASIN(c *Credential, marketplaceId, asin string) (string, *GetProductCategoriesForASINResult, error) {
data := ActionValues("GetProductCategoriesForASIN")
data.Set("MarketplaceId", marketplaceId)
data.Set("ASIN", asin)
var result struct {
BaseResponse
Result *GetProductCategoriesForASINResult `xml:"GetProductCategoriesForASINResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}