-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
111 lines (102 loc) · 3.31 KB
/
main.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
package main
import (
"context"
"fmt"
"os"
"github.com/utekaravinash/gopaapi5"
"github.com/utekaravinash/gopaapi5/api"
)
const tmpl = `Title: %s
URL: %s
----------------------
`
func main() {
// Get Access Key, Secret Key and Associate Tag from the environment variables
accessKey := os.Getenv("PA_ACCESS_KEY")
secretKey := os.Getenv("PA_SECRET_KEY")
associateTag := os.Getenv("PA_ASSOCIATE_TAG")
// Initiate gopaapi5 Client
client, err := gopaapi5.NewClient(accessKey, secretKey, associateTag, api.UnitedStates)
if err != nil {
panic(err)
}
// Construct request parameters for GetItems operation
params := api.GetItemsParams{
Condition: api.Any,
CurrencyOfPreference: api.UnitedStatesDollar,
Merchant: api.AllMerchants,
ItemIds: []string{
"B00AP06III",
"0451494946",
"1119293499",
},
Resources: []api.Resource{
api.BrowseNodeInfoBrowseNodes,
api.BrowseNodeInfoBrowseNodesAncestor,
api.BrowseNodeInfoBrowseNodesSalesRank,
api.BrowseNodeInfoWebsiteSalesRank,
api.CustomerReviewsCount,
api.CustomerReviewsStarRating,
api.ImagesPrimarySmall,
api.ImagesPrimaryMedium,
api.ImagesPrimaryLarge,
api.ImagesVariantsSmall,
api.ImagesVariantsMedium,
api.ImagesVariantsLarge,
api.ItemInfoByLineInfo,
api.ItemInfoContentInfo,
api.ItemInfoContentRating,
api.ItemInfoClassifications,
api.ItemInfoExternalIds,
api.ItemInfoFeatures,
api.ItemInfoManufactureInfo,
api.ItemInfoProductInfo,
api.ItemInfoTechnicalInfo,
api.ItemInfoTitle,
api.ItemInfoTradeInInfo,
api.OffersListingsAvailabilityMaxOrderQuantity,
api.OffersListingsAvailabilityMessage,
api.OffersListingsAvailabilityMinOrderQuantity,
api.OffersListingsAvailabilityType,
api.OffersListingsCondition,
api.OffersListingsConditionSubCondition,
api.OffersListingsDeliveryInfoIsAmazonFulfilled,
api.OffersListingsDeliveryInfoIsFreeShippingEligible,
api.OffersListingsDeliveryInfoIsPrimeEligible,
api.OffersListingsDeliveryInfoShippingCharges,
api.OffersListingsIsBuyBoxWinner,
api.OffersListingsLoyaltyPointsPoints,
api.OffersListingsMerchantInfo,
api.OffersListingsPrice,
api.OffersListingsProgramEligibilityIsPrimeExclusive,
api.OffersListingsProgramEligibilityIsPrimePantry,
api.OffersListingsPromotions,
api.OffersListingsSavingBasis,
api.OffersSummariesHighestPrice,
api.OffersSummariesLowestPrice,
api.OffersSummariesOfferCount,
api.ParentASIN,
api.RentalOffersListingsAvailabilityMaxOrderQuantity,
api.RentalOffersListingsAvailabilityMessage,
api.RentalOffersListingsAvailabilityMinOrderQuantity,
api.RentalOffersListingsAvailabilityType,
api.RentalOffersListingsBasePrice,
api.RentalOffersListingsCondition,
api.RentalOffersListingsConditionSubCondition,
api.RentalOffersListingsDeliveryInfoIsAmazonFulfilled,
api.RentalOffersListingsDeliveryInfoIsFreeShippingEligible,
api.RentalOffersListingsDeliveryInfoIsPrimeEligible,
api.RentalOffersListingsDeliveryInfoShippingCharges,
api.RentalOffersListingsMerchantInfo,
},
}
// Call GetItems operation
response, err := client.GetItems(context.Background(), ¶ms)
if err != nil {
panic(err)
}
// Loop over items in response
for _, item := range response.ItemsResult.Items {
fmt.Printf(tmpl, item.ItemInfo.Title.DisplayValue, item.DetailPageURL)
}
}