planner

package module
v0.0.0-...-11fd6c2 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2021 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultParser

type DefaultParser struct {
	HTMLParser      HTMLParser
	MetaTagParser   MetaTagParser
	OpenGraphParser OpenGraphParser
	SchemaOrgParser SchemaOrgParser
}

DefaultParser combines the above parsers in a single convenient parser.

func NewDefaultParser

func NewDefaultParser(url string, body []byte) DefaultParser

NewDefaultParser creates a new parser than combines other parsers.

func (DefaultParser) Product

func (parser DefaultParser) Product() (Product, error)

Product returns the result of combining other Producters.

type HTMLParser

type HTMLParser struct {
	URL  string
	Body []byte
}

HTMLParser looks through the HTML for certain values. It's not very accurate but can make a last-ditch attempt.

func (HTMLParser) Product

func (parser HTMLParser) Product() (Product, error)

Product parses the HTML for a product.

type MetaTagParser

type MetaTagParser struct {
	URL  string
	Body []byte
}

MetaTagParser is more accurate than HTMLParser but will not be able to gather all info.

func (MetaTagParser) Product

func (parser MetaTagParser) Product() (Product, error)

Product parses meta tags for product information.

type OpenGraphParser

type OpenGraphParser struct {
	URL  string
	Body []byte
}

OpenGraphParser is generally very accurate but pricing is not used widely.

func (OpenGraphParser) Product

func (parser OpenGraphParser) Product() (Product, error)

Product parses opengraph meta tags for product information.

type Product

type Product struct {
	Name           string   `json:"name"`
	Description    string   `json:"description"`
	Price          int64    `json:"price"`
	URL            string   `json:"url"`
	Image          string   `json:"image"`
	OriginalImage  string   `json:"originalImage"`
	PossibleImages []string `json:"possibleImages"`
}

Product contains information about the thing a User wants to buy.

func (Product) Merge

func (p Product) Merge(p2 Product) Product

Merge takes another product and replaces zero values.

type Producter

type Producter interface {
	// Product returns a Product and an error.
	Product() (Product, error)
}

Producter is an interface for retrieving products.

type Purchase

type Purchase struct {
	Date    *time.Time `json:"date"`
	Product Product    `json:"product"`
}

Purchase is something a User wants to buy. TODO: Link it more appropriately with Product.

type SchemaOrgParser

type SchemaOrgParser struct {
	URL  string
	Body []byte
}

SchemaOrgParser is VERY accurate because it's what is intended to be shown On search engines.

func (SchemaOrgParser) Product

func (parser SchemaOrgParser) Product() (Product, error)

Product parses schema org JSON for data about a product.

type User

type User struct {
	Email         string     `json:"email"`
	Saved         int64      `json:"saved"`
	Contributions int64      `json:"contributions"`
	Frequency     string     `json:"frequency"`
	LastPaycheck  *time.Time `json:"lastPaycheck"`
	Purchases     []Purchase `json:"purchases"`
}

User is the top level struct for, you guessed it, user data. The data is stored in an object database, so purchases Are stored as a property on the user, rather than by association.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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