plan

package module
v0.0.0-...-e5c5c61 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2021 License: BSD-3-Clause Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Weekly       Frequency = "Every Week"
	Biweekly               = "Every 2 Weeks"
	Monthly                = "Once A Month"
	TwiceMonthly           = "1st and 15th"
)

Variables

View Source
var (
	ErrMissingEmail        = errors.New("missing Email")
	ErrMissingProductName  = errors.New("missing product Name")
	ErrMissingProductPrice = errors.New("missing product Price")
	ErrMissingProductURL   = errors.New("missing product URL")
)
View Source
var (
	ErrInvalidFrequency              = errors.New("invalid contribution frequency")
	ErrInvalidAvailabilityCalculator = errors.New("invalid availability calculator")
)

Functions

func Process

func Process(u *User) error

func ProcessDefaults

func ProcessDefaults(u *User) error

func ProcessLastPaycheck

func ProcessLastPaycheck(u *User) error

func ProcessPurchaseAvailability

func ProcessPurchaseAvailability(u *User) error

func ProcessValidation

func ProcessValidation(u *User) error

Types

type BiWeeklyCalculator

type BiWeeklyCalculator struct {
	Contributions int64
}

func (BiWeeklyCalculator) Calculate

func (w BiWeeklyCalculator) Calculate(u *User, p *Purchase) (*time.Time, error)

func (BiWeeklyCalculator) LastPaycheck

func (w BiWeeklyCalculator) LastPaycheck(u *User) (*time.Time, error)

type Frequency

type Frequency string

type MonthlyCalculator

type MonthlyCalculator struct {
	Contributions int64
}

func (MonthlyCalculator) Calculate

func (w MonthlyCalculator) Calculate(u *User, p *Purchase) (*time.Time, error)

func (MonthlyCalculator) LastPaycheck

func (w MonthlyCalculator) LastPaycheck(u *User) (*time.Time, error)

type Processor

type Processor func(*User) error

type Product

type Product struct {
	Name          string `datastore:",noindex" json:"name"`
	Description   string `datastore:",noindex" json:"description"`
	Price         int64  `json:"price"`
	URL           string `json:"url"`
	Image         string `json:"image"`
	OriginalImage string `datastore:",noindex" json:"originalImage"`
}

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

type Purchase

type Purchase struct {
	ID          string     `json:"id"`
	Deleted     bool       `json:"deleted"`
	Purchased   bool       `json:"purchased"`
	PurchasedAt *time.Time `json:"purchasedAt"`
	Date        *time.Time `json:"date"`
	Product     Product    `json:"product"`
	Quantity    int64      `json:"quantity"`
}

Purchase is something a User wants to buy.

type PurchaseCalculator

type PurchaseCalculator interface {
	Calculate(*User, *Purchase) (*time.Time, error)
	LastPaycheck(*User) (*time.Time, error)
}

func GetPurchaseCalculator

func GetPurchaseCalculator(u *User) (PurchaseCalculator, error)

type TwiceMonthlyCalculator

type TwiceMonthlyCalculator struct {
	Contributions int64
}

func (TwiceMonthlyCalculator) Calculate

func (w TwiceMonthlyCalculator) Calculate(u *User, p *Purchase) (*time.Time, error)

func (TwiceMonthlyCalculator) LastPaycheck

func (w TwiceMonthlyCalculator) LastPaycheck(u *User) (*time.Time, error)

type User

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

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.

type WeeklyCalculator

type WeeklyCalculator struct {
	Contributions int64
}

func (WeeklyCalculator) Calculate

func (w WeeklyCalculator) Calculate(u *User, p *Purchase) (*time.Time, error)

func (WeeklyCalculator) LastPaycheck

func (w WeeklyCalculator) LastPaycheck(u *User) (*time.Time, error)

Jump to

Keyboard shortcuts

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