forked from dominicphillips/amazing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
response.go
147 lines (123 loc) · 3.43 KB
/
response.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
package amazing
import (
"encoding/xml"
"fmt"
)
const (
errorFormat = "ErrorCode: %s\nMessage: %s\nRequest:%s"
)
type AmazonItemLookupResponse struct {
XMLName xml.Name `xml:"ItemLookupResponse"`
OperationRequest AmazonOperationRequest
AmazonItems AmazonItems `xml:"Items"`
}
type AmazonItemSearchResponse struct {
XMLName xml.Name `xml:"ItemSearchResponse"`
OperationRequest AmazonOperationRequest
AmazonItems AmazonItems `xml:"Items"`
}
type AmazonSimilarityLookupResponse struct {
XMLName xml.Name `xml:"SimilarityLookupResponse"`
OperationRequest AmazonOperationRequest
AmazonItems AmazonItems `xml:"Items"`
}
type AmazonOperationRequest struct {
HTTPHeaders []AmazonOperationRequestHeader `xml:"HTTPHeaders>Header"`
Arguments []AmazonOperationRequestArgument `xml:"Arguments>Argument"`
RequestId string
RequestProcessingTime float64
}
type AmazonOperationRequestHeader struct {
Name string `xml:"Name,attr"`
Value string `xml:"Value,attr"`
}
type AmazonOperationRequestArgument struct {
Name string `xml:"Name,attr"`
Value string `xml:"Value,attr"`
}
type AmazonItems struct {
Request AmazonRequest
Items []AmazonItem `xml:"Item"`
}
type AmazonItem struct {
ASIN string
ParentASIN string
DetailPageURL string
SalesRank string
ItemLinks []AmazonItemLink `xml:"ItemLinks>ItemLink"`
SmallImage AmazonImage
MediumImage AmazonImage
LargeImage AmazonImage
ImageSets []AmazonImageSet `xml:"ImageSets>ImageSet"`
ItemAttributes AmazonItemAttributes
OfferSummary AmazonItemOfferSummary
EditorialReviews []AmazonEditorialReview `xml:"EditorialReviews>EditorialReview"`
BrowseNodes []AmazonBrowseNode `xml:"BrowseNodes>BrowseNode"`
}
type AmazonBrowseNode struct {
BrowseNodeId string `xml:"BrowseNodeId"`
Name string `xml:"Name"`
Ancestors []AmazonBrowseNode `xml:"Ancestors>BrowseNode"`
}
type AmazonEditorialReview struct {
Source string
Content string
}
type AmazonItemAtributes AmazonItemAttributes
type AmazonItemAttributes struct {
Title string
Brand string
ListPrice AmazonItemPrice
}
type AmazonItemOfferSummary struct {
LowestUsedPrice AmazonItemPrice
LowestNewPrice AmazonItemPrice
LowestCollectiblePrice AmazonItemPrice
}
type AmazonItemPrice struct {
Amount int64
CurrencyCode string
FormattedPrice string
}
type AmazonItemLink struct {
Description string
URL string
}
type AmazonImageSet struct {
Category string `xml:"Category,attr"`
SwatchImage AmazonImage
SmallImage AmazonImage
ThumbnailImage AmazonImage
TinyImage AmazonImage
MediumImage AmazonImage
LargeImage AmazonImage
}
type AmazonRequest struct {
IsValid bool
ItemLookupRequest AmazonItemLookupRequest
Errors []AmazonError
}
type AmazonItemLookupRequest struct {
Condition string
IdType string
ItemId string
ResponseGroups []string `xml:"ResponseGroup"`
VariationPage string
}
type AmazonItemLookupErrorResponse struct {
XMLName xml.Name
AmazonError
}
type AmazonError struct {
Code string `xml:"Error>Code"`
Message string `xml:"Error>Message"`
RequestId string
}
type AmazonImage struct {
URL string
Height uint16
Width uint16
}
func (a *AmazonError) Error() string {
return fmt.Sprintf(errorFormat, a.Code, a.Message, a.RequestId)
}