amazon

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultAmazonDomain is the domain where an Amazon wishlist will
	// be assumed to be located if not otherwise specified.
	DefaultAmazonDomain = "https://www.amazon.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	// IsPrime indicates whether the product is eligible for Amazon Prime free
	// shipping.
	IsPrime bool

	// DirectURL is the URL to view this product on Amazon.
	DirectURL string

	// AddToCartURL is the URL to add this product to your shopping cart on Amazon,
	// tied to the particular wishlist it came from.
	AddToCartURL string

	// ImageURL is the URL of an image that represents this product.
	ImageURL string

	// ReviewsURL is the URL to view customer reviews of this product.
	ReviewsURL string

	// ReviewCount is how many reviews customers have left for this product on Amazon.
	ReviewCount int

	// RequestedCount is how many of the product the wishlist recipient would like
	// to receive.
	RequestedCount int

	// OwnedCount is how many of the product the wishlist recipient already owns.
	OwnedCount int

	// Name is the name of this product.
	Name string

	// Price is a string representation of the cost of this product on Amazon.
	Price string

	// ID is a unique identifier for this product on Amazon.
	ID string

	// DateAdded is a string representation of when this item was added to the
	// wishlist. Example: "October 20, 2019"
	RawDateAdded string

	// Rating is a string description of how Amazon customers have rated this
	// product.
	Rating string
}

Item represents a product on an Amazon wishlist.

func NewItem

func NewItem(id string, name string, directURL string) *Item

NewItem constructs an Item with the given product identifier, name, and URL to its Amazon page.

func (*Item) DateAdded

func (i *Item) DateAdded() (*time.Time, error)

DateAdded returns the date this item was added to the wishlist.

func (*Item) String

func (i *Item) String() string

String returns a description of this product.

func (*Item) URL

func (i *Item) URL() string

URL returns a string URL to this product on Amazon. Prefers the link that ties this product to the wishlist it came from, if known.

type Wishlist

type Wishlist struct {
	// DebugMode specifies whether messages should be logged to STDOUT about
	// what's going on, as well as if the HTML source of the wishlist should
	// be saved to files.
	DebugMode bool

	// CacheResults determines whether responses from Amazon should be cached.
	CacheResults bool
	// contains filtered or unexported fields
}

Wishlist represents an Amazon wishlist of products.

func NewWishlist

func NewWishlist(urlStr string) (*Wishlist, error)

NewWishlist constructs an Amazon wishlist for the given URL.

func NewWishlistFromID

func NewWishlistFromID(id string) (*Wishlist, error)

NewWishlistFromID constructs an Amazon wishlist for the given wishlist ID.

func NewWishlistFromIDAtDomain

func NewWishlistFromIDAtDomain(id string, amazonDomain string) (*Wishlist, error)

NewWishlistFromIDAtDomain constructs an Amazon wishlist for the given wishlist ID at the given Amazon domain, e.g., "https://amazon.com".

func (*Wishlist) Errors

func (w *Wishlist) Errors() []error

Errors returns any errors that occurred when trying to load the wishlist.

func (*Wishlist) ID

func (w *Wishlist) ID() string

ID returns the identifier for this wishlist on Amazon.

func (*Wishlist) Items

func (w *Wishlist) Items() (map[string]*Item, error)

Items returns a map of the products on the wishlist, where keys are the product IDs and the values are the products.

func (*Wishlist) Name

func (w *Wishlist) Name() (string, error)

Name returns the name of this wishlist on Amazon.

func (*Wishlist) PrintURL

func (w *Wishlist) PrintURL() (string, error)

PrintURL returns the URL to the printer-friendly view of this wishlist on Amazon.

func (*Wishlist) SetProxyURLs

func (w *Wishlist) SetProxyURLs(urls ...string)

SetProxyURLs specifies URLs of proxies to use when accessing Amazon. May be useful if you're getting an error about Amazon thinking you're a bot.

func (*Wishlist) String

func (w *Wishlist) String() string

func (*Wishlist) URLs

func (w *Wishlist) URLs() []string

URLs returns the URLs used to access all the items in the wishlist. Will be extended as necessary when Items is called.

Jump to

Keyboard shortcuts

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