-
Notifications
You must be signed in to change notification settings - Fork 2
/
getReportRequestList.go
69 lines (61 loc) · 2.31 KB
/
getReportRequestList.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
package amazonmwsapi
import (
"context"
"encoding/xml"
"fmt"
)
// GetReportRequestListRequest calls a list of requested reports and thier status
type GetReportRequestListRequest struct {
amazonRequest
}
// ReportRequestIDList adds list of report IDs to request - not required
func (r *GetReportRequestListRequest) ReportRequestIDList(reportIDs []string) *GetReportRequestListRequest {
for i, id := range reportIDs {
r.params[fmt.Sprintf("ReportRequestIdList.Id.%d", (i+1))] = []string{id}
}
return r
}
// ReportTypeList adds list of reportTypes to request - not required
func (r *GetReportRequestListRequest) ReportTypeList(reportTypes []string) *GetReportRequestListRequest {
for i, t := range reportTypes {
r.params[fmt.Sprintf("ReportTypeList.Type.%d", (i+1))] = []string{t}
}
return r
}
// Do sends request to amazonMWS reports API and returns report request info
func (r *GetReportRequestListRequest) Do(ctx context.Context) (*GetReportRequestListResponse, error) {
respBytes, err := r.client.callAPI(ctx, &r.amazonRequest)
if err != nil {
return nil, err
}
xmlResponse := &GetReportRequestListResponse{}
err = xml.Unmarshal(respBytes, xmlResponse)
if err != nil {
return nil, r.client.parseAPIerrors(respBytes)
}
return xmlResponse, nil
}
// GetReportRequestListResponse type
type GetReportRequestListResponse struct {
XMLName xml.Name `xml:"GetReportRequestListResponse"`
Xmlns string `xml:"xmlns,attr"`
GetReportRequestListResult struct {
NextToken string `xml:"NextToken"`
HasNext string `xml:"HasNext"`
ReportRequestInfo []struct {
ReportRequestID string `xml:"ReportRequestId"`
ReportType string `xml:"ReportType"`
StartDate string `xml:"StartDate"`
EndDate string `xml:"EndDate"`
Scheduled string `xml:"Scheduled"`
SubmittedDate string `xml:"SubmittedDate"`
ReportProcessingStatus string `xml:"ReportProcessingStatus"`
GeneratedReportID string `xml:"GeneratedReportId"`
StartedProcessingDate string `xml:"StartedProcessingDate"`
CompletedDate string `xml:"CompletedDate"`
} `xml:"ReportRequestInfo"`
} `xml:"GetReportRequestListResult"`
ResponseMetadata struct {
RequestID string `xml:"RequestId"`
} `xml:"ResponseMetadata"`
}