Documentation ¶
Index ¶
- type Configuration
- type Crawler
- type Notifications
- type Notifier
- type Notifiers
- type Product
- func (p *Product) ShouldSendAnyNotification() bool
- func (p *Product) ShouldSendBackInStockNotification() bool
- func (p *Product) ShouldSendOutOfStockNotification() bool
- func (p *Product) ShouldSendPriceBelowsNotification() bool
- func (p *Product) ShouldSendPriceDecreasesNotification() bool
- func (p *Product) ShouldSendPriceIncreasesNotification() bool
- func (p *Product) ShouldSendPriceOverNotification() bool
- func (p *Product) UpdateInfo(other *Product)
- type Products
- type Repository
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
Configuration handles the products configuration
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 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 ¶
ShouldSendAnyNotification returns true if the product should trigger any notifications
func (*Product) ShouldSendBackInStockNotification ¶
ShouldSendBackInStockNotification returns true if should trigger a "back in stock" notification
func (*Product) ShouldSendOutOfStockNotification ¶
ShouldSendOutOfStockNotification returns true if should trigger a "out of stock" notification
func (*Product) ShouldSendPriceBelowsNotification ¶
ShouldSendPriceBelowsNotification returns true if should trigger a "price belows" notification
func (*Product) ShouldSendPriceDecreasesNotification ¶
ShouldSendPriceDecreasesNotification returns true if should trigger a "price decreases" notification
func (*Product) ShouldSendPriceIncreasesNotification ¶
ShouldSendPriceIncreasesNotification returns true if should trigger a "price increases" notification
func (*Product) ShouldSendPriceOverNotification ¶
ShouldSendPriceOverNotification returns true if should trigger a "price over" notification
func (*Product) UpdateInfo ¶
UpdateInfo updates the product values
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 ¶
AddProductByURL adds a new Amazon product by its URL
func (*Service) DeleteProductByURL ¶
DeleteProductByURL deletes a product by its URL
func (*Service) ListProducts ¶
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