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 pathfeeds.go
99 lines (84 loc) · 3.17 KB
/
feeds.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
package mws
import (
"bytes"
)
type FeedService struct {
*AmazonClient
}
func NewFeedService() *FeedService {
return &FeedService{
AmazonClient: newAmazonClient("/Feeds/2009-01-01", "2009-01-01"),
}
}
func (s *FeedService) SubmitFeed(c *Credential, marketplaceIdList []string, feedType FeedType, feedContent []byte, params ...Values) (string, *SubmitFeedResult, error) {
data := ActionValues("SubmitFeed")
data.Set("FeedType", string(feedType))
data.Sets("MarketplaceIdList.Id", marketplaceIdList...)
data.Set("ContentMD5Value", FeedContentMd5(feedContent))
data.SetAll(params...)
//data.Set("PurgeAndReplace", strconv.FormatBool(purgeAndReplace))
var result struct {
BaseResponse
Result *SubmitFeedResult `xml:"SubmitFeedResult"`
}
if _, err := s.GetModel("POST", c, data, bytes.NewBuffer(feedContent), &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
func (s *FeedService) GetFeedSubmissionList(c *Credential, params ...Values) (string, *GetFeedSubmissionListResult, error) {
data := ActionValues("GetFeedSubmissionList")
data.SetAll(params...)
//data.Sets("FeedSubmissionIdList.Id", feedSubmissionIdList...)
//data.SetInt("MaxCount", maxCount)
//data.Sets("FeedTypeList.Type", feedTypeList...)
//data.Sets("FeedProcessingStatusList.Status", feedProcessingStatusList...)
//data.SetTime("SubmittedFromDate", submittedFromDate)
//data.SetTime("SubmittedToDate", submittedToDate)
var result struct {
BaseResponse
Result *GetFeedSubmissionListResult `xml:"GetFeedSubmissionListResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
func (s *FeedService) GetFeedSubmissionListByNextToken(c *Credential, nextToken string) (string, *GetFeedSubmissionListResult, error) {
data := ActionValues("GetFeedSubmissionListByNextToken")
data.Set("NextToken", nextToken)
var result struct {
BaseResponse
Result *GetFeedSubmissionListResult `xml:"GetFeedSubmissionListByNextTokenResult"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", nil, err
}
return result.RequestID, result.Result, nil
}
func (s *FeedService) GetFeedSubmissionCount(c *Credential, params ...Values) (string, int, error) {
data := ActionValues("GetFeedSubmissionCount")
data.SetAll(params...)
//data := NewValues()
//data.Sets("FeedTypeList.Type", feedTypeList...)
//data.Sets("FeedProcessingStatusList.Status", feedProcessingStatusList...)
//data.SetTime("SubmittedFromDate", submittedFromDate)
//data.SetTime("SubmittedToDate", submittedToDate)
var result struct {
BaseResponse
Count int `xml:"GetFeedSubmissionCountResult>Count"`
}
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return "", 0, err
}
return result.RequestID, result.Count, nil
}
func (s *FeedService) GetFeedSubmissionResult(c *Credential, feedSubmissionId string) (*GetFeedSubmissionResult, error) {
data := ActionValues("GetFeedSubmissionResult")
data.Set("FeedSubmissionId", feedSubmissionId)
var result GetFeedSubmissionResult
if _, err := s.GetModel("POST", c, data, nil, &result); err != nil {
return nil, err
}
return &result, nil
}