product

package
v0.0.0-...-1ddc832 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package amazon provides methods for interacting with the Amazon Product Advertising API

types that help with using the Product Advertising API

helpers to transform the XML response to a struct

Index

Constants

View Source
const (
	MINIMUM_RESPONSE_GROUP  string = "ItemAttributes,Small,SalesRank"
	DEFAULT_RESPONSE_GROUP  string = "Images,ItemAttributes,Small,SalesRank"
	EXTENDED_RESPONSE_GROUP string = "Images,ItemAttributes,Small,SalesRank,EditorialReview"
)
View Source
const ENDPOINT_URI = "/onca/xml"

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument struct {
	Name  string `xml:"Name,attr"`
	Value string `xml:"Value,attr"`
}

Argument todo

type Dimension

type Dimension struct {
	Value int    `xml:",chardata"`
	Unit  string `xml:"Units,attr"`
}

type Dimensions

type Dimensions struct {
	Height Dimension
	Length Dimension
	Weight Dimension
	Width  Dimension
}

type EditorialReview

type EditorialReview struct {
	Source  string
	Content string
}

type EditorialReviews

type EditorialReviews struct {
	EditorialReviews []EditorialReview `xml:"EditorialReview"`
}

type Error

type Error struct {
	Code    string
	Message string
}

type Image

type Image struct {
	//XMLName xml.Name `xml:"MediumImage"`
	URL    string
	Height int
	Width  int
}

Image todo

type Item

type Item struct {
	ASIN             string
	URL              string
	DetailPageURL    string
	SalesRank        int
	SmallImage       Image
	MediumImage      Image
	LargeImage       Image
	ItemAttributes   ItemAttributes
	OfferSummary     OfferSummary
	Offers           Offers
	EditorialReviews EditorialReviews
	SimilarProducts  SimilarProducts
}

Item represents a product returned by the API

type ItemAttributes

type ItemAttributes struct {
	Title             string
	SKU               string
	EAN               string
	Brand             string
	Feature           []string
	ProductGroup      string
	ProductTypeName   string
	IsAdultProduct    bool
	Manufacturer      string
	Model             string
	Publisher         string
	ReleaseDate       string
	Studio            string
	Warranty          string
	Label             string
	PackageDimensions Dimensions
	PackageQuantity   int
}

ItemAttributes response group

type ItemLookupRequest

type ItemLookupRequest struct {
	IDType         string   `xml:"IdType"`
	ItemID         string   `xml:"ItemId"`
	ResponseGroups []string `xml:"ResponseGroup"`
	VariationPage  string
}

ItemLookupRequest is the confirmation of a ItemLookup request

type ItemLookupResponse

type ItemLookupResponse struct {
	Response

	Items struct {
		Request struct {
			IsValid           bool
			ItemLookupRequest ItemLookupRequest
			Errors            []Error `xml:"Errors>Error"`
		}
		TotalResults int
		TotalPages   int
		Item         []Item
	}
}

ItemLookupResponse describes the API response for the ItemLookup operation

func ConvertToItemLookupResponse

func ConvertToItemLookupResponse(response []byte) (*ItemLookupResponse, error)

type Offer

type Offer struct {
	Condition       string `xml:"OfferAttributes>Condition"`
	ID              string `xml:"OfferListing>OfferListingId"`
	Price           Price  `xml:"OfferListing>Price"`
	PercentageSaved uint   `xml:"OfferListing>PercentageSaved"`
	Availability    string `xml:"OfferListing>Availability"`
}

Offer response attribute

type OfferSummary

type OfferSummary struct {
	LowestNewPrice   Price
	LowerUsedPrice   Price
	TotalNew         int
	TotalUsed        int
	TotalCollectible int
	TotalRefurbished int
}

OfferSummary response group

type Offers

type Offers struct {
	TotalOffers     int
	TotalOfferPages int
	MoreOffersURL   string  `xml:"MoreOffersUrl"`
	Offers          []Offer `xml:"Offer"`
}

Offers response group

type Price

type Price struct {
	Amount         int
	CurrencyCode   string
	FormattedPrice string
}

Price describes the product price as Amount of cents in CurrencyCode

type ProductAPI

type ProductAPI struct {
	AccessKey    string
	SecretKey    string
	AssociateTag string
	Host         string
	Region       string
	Client       *http.Client
}

func InitAPI

func InitAPI(region string) *ProductAPI

InitAPI initialize the Amazon Product API

func (ProductAPI) BrowseNodeLookup

func (api ProductAPI) BrowseNodeLookup(nodeId string) ([]byte, error)

BrowseNodeLookup takes a BrowseNodeId and returns the result.

func (ProductAPI) BrowseNodeLookupWithResponseGroup

func (api ProductAPI) BrowseNodeLookupWithResponseGroup(nodeId string, responseGroup string) ([]byte, error)

func (ProductAPI) CartAdd

func (api ProductAPI) CartAdd(items map[string]int, cartid, HMAC string) ([]byte, error)

CartAdd takes a map containing ASINs and quantities and adds them to the given cart. Up to 10 items are allowed

func (ProductAPI) CartClear

func (api ProductAPI) CartClear(CartId, HMAC string) ([]byte, error)

CartClear takes a CartId and HMAC that were returned when generating a cart It then removes the contents of the cart

func (ProductAPI) CartCreate

func (api ProductAPI) CartCreate(items map[string]int) ([]byte, error)

CartCreate takes a map containing ASINs and quantities. Up to 10 items are allowed

func (ProductAPI) CartGet

func (api ProductAPI) CartGet(CartId, HMAC string) ([]byte, error)

Cart get takes a CartID and HMAC that were returned when generating a cart Returns the contents of the specified cart

func (ProductAPI) ItemLookup

func (api ProductAPI) ItemLookup(ItemId string) ([]byte, error)

ItemLookup takes a product ID (ASIN) and returns the result

func (ProductAPI) ItemLookupWithParams

func (api ProductAPI) ItemLookupWithParams(params map[string]string) ([]byte, error)

ItemLookupWithParams takes the params for ItemLookup and returns the result

func (ProductAPI) ItemLookupWithResponseGroup

func (api ProductAPI) ItemLookupWithResponseGroup(ItemId string, ResponseGroup string) ([]byte, error)

func (ProductAPI) ItemSearch

func (api ProductAPI) ItemSearch(SearchIndex string, Parameters map[string]string) ([]byte, error)

func (ProductAPI) ItemSearchByKeyword

func (api ProductAPI) ItemSearchByKeyword(Keywords string, page int) ([]byte, error)

ItemSearchByKeyword takes a string containing keywords and returns the search results

func (ProductAPI) ItemSearchByKeywordWithResponseGroup

func (api ProductAPI) ItemSearchByKeywordWithResponseGroup(Keywords string, ResponseGroup string) ([]byte, error)

func (ProductAPI) MultipleItemLookup

func (api ProductAPI) MultipleItemLookup(ItemIds []string) ([]byte, error)

func (ProductAPI) MultipleItemLookupWithResponseGroup

func (api ProductAPI) MultipleItemLookupWithResponseGroup(ItemIds []string, ResponseGroup string) ([]byte, error)

func (ProductAPI) MultipleSimilarityLookup

func (api ProductAPI) MultipleSimilarityLookup(ItemIds []string) ([]byte, error)

func (ProductAPI) MultipleSimilarityLookupWithResponseGroup

func (api ProductAPI) MultipleSimilarityLookupWithResponseGroup(ItemIds []string, ResponseGroup string) ([]byte, error)

func (ProductAPI) SimilarityLookup

func (api ProductAPI) SimilarityLookup(ItemId string) ([]byte, error)

The SimilarityLookup operation returns up to ten products per page that are similar to one or more items specified in the request

func (ProductAPI) SimilarityLookupWithResponseGroup

func (api ProductAPI) SimilarityLookupWithResponseGroup(ItemId string, ResponseGroup string) ([]byte, error)

type Response

type Response struct {
	OperationRequest struct {
		RequestID             string     `xml:"RequestId"`
		Arguments             []Argument `xml:"Arguments>Argument"`
		RequestProcessingTime float64
	}
}

type SimilarProduct

type SimilarProduct struct {
	ASIN  string
	Title string
}

type SimilarProducts

type SimilarProducts struct {
	SimilarProducts []SimilarProduct `xml:"SimilarProduct"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL