product

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration interface {
	RefreshInterval() time.Duration
}

Configuration handles the products configuration

type Crawler

type Crawler interface {
	Extract(url string) (*Product, error)
}

Crawler handles the products crawling

type Notifications

type Notifications struct {
	PriceBelows    float32
	PriceOver      float32
	PriceIncreases bool
	PriceDecreases bool
	OutOfStock     bool
	BackInStock    bool
}

Notifications model

func (*Notifications) GetTotal

func (n *Notifications) GetTotal() int

GetTotal returns the number of enabled notifications

type Notifier

type Notifier interface {
	NotifyChanges(p *Product)
	IsConfigured() bool
}

Notifier handles the products notifications

type Notifiers added in v1.1.4

type Notifiers []Notifier

Notifiers is a slice of Notifier

type Product

type Product struct {
	URL        string
	Title      string
	ImageURL   string
	LastPrice  float32
	Price      float32
	Currency   string
	Added      time.Time
	LastUpdate time.Time

	Notifications *Notifications
	// contains filtered or unexported fields
}

Product model

func (*Product) ShouldSendAnyNotification

func (p *Product) ShouldSendAnyNotification() bool

ShouldSendAnyNotification returns true if the product should trigger any notifications

func (*Product) ShouldSendBackInStockNotification

func (p *Product) ShouldSendBackInStockNotification() bool

ShouldSendBackInStockNotification returns true if should trigger a "back in stock" notification

func (*Product) ShouldSendOutOfStockNotification

func (p *Product) ShouldSendOutOfStockNotification() bool

ShouldSendOutOfStockNotification returns true if should trigger a "out of stock" notification

func (*Product) ShouldSendPriceBelowsNotification

func (p *Product) ShouldSendPriceBelowsNotification() bool

ShouldSendPriceBelowsNotification returns true if should trigger a "price belows" notification

func (*Product) ShouldSendPriceDecreasesNotification

func (p *Product) ShouldSendPriceDecreasesNotification() bool

ShouldSendPriceDecreasesNotification returns true if should trigger a "price decreases" notification

func (*Product) ShouldSendPriceIncreasesNotification

func (p *Product) ShouldSendPriceIncreasesNotification() bool

ShouldSendPriceIncreasesNotification returns true if should trigger a "price increases" notification

func (*Product) ShouldSendPriceOverNotification

func (p *Product) ShouldSendPriceOverNotification() bool

ShouldSendPriceOverNotification returns true if should trigger a "price over" notification

func (*Product) UpdateInfo

func (p *Product) UpdateInfo(other *Product)

UpdateInfo updates the product values

type Products added in v1.1.4

type Products []*Product

Products is a slice of Product

type Repository

type Repository interface {
	Add(p *Product) error
	Delete(url string) (*Product, error)
	List() (*Products, error)
	Update(p *Product) error
	Get(url string) (*Product, error)
}

Repository handles the products persistence

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service struct

func NewService

func NewService(r Repository, c Crawler, cfg Configuration, ns *Notifiers) (ps *Service)

NewService creates a new Product Service

func (*Service) AddProductByURL

func (ps *Service) AddProductByURL(url string) (p *Product, err error)

AddProductByURL adds a new Amazon product by its URL

func (*Service) DeleteProductByURL

func (ps *Service) DeleteProductByURL(url string) (*Product, error)

DeleteProductByURL deletes a product by its URL

func (*Service) ListProducts

func (ps *Service) ListProducts() (*Products, error)

ListProducts list current saved products

func (*Service) UpdateNotifications added in v1.1.4

func (ps *Service) UpdateNotifications(url string, n *Notifications) (err error)

UpdateNotifications updates the product notifications

Jump to

Keyboard shortcuts

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