Documentation
¶
Index ¶
- Constants
- Variables
- func Process(u *User) error
- func ProcessDefaults(u *User) error
- func ProcessLastPaycheck(u *User) error
- func ProcessPurchaseAvailability(u *User) error
- func ProcessValidation(u *User) error
- type BiWeeklyCalculator
- type Frequency
- type MonthlyCalculator
- type Processor
- type Product
- type Purchase
- type PurchaseCalculator
- type TwiceMonthlyCalculator
- type User
- type WeeklyCalculator
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") )
View Source
var Processors = []Processor{ ProcessDefaults, ProcessValidation, ProcessLastPaycheck, ProcessPurchaseAvailability, }
Functions ¶
func ProcessDefaults ¶
func ProcessLastPaycheck ¶
func ProcessValidation ¶
Types ¶
type BiWeeklyCalculator ¶
type BiWeeklyCalculator struct {
Contributions int64
}
func (BiWeeklyCalculator) LastPaycheck ¶
func (w BiWeeklyCalculator) LastPaycheck(u *User) (*time.Time, error)
type MonthlyCalculator ¶
type MonthlyCalculator struct {
Contributions int64
}
func (MonthlyCalculator) LastPaycheck ¶
func (w MonthlyCalculator) LastPaycheck(u *User) (*time.Time, 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) 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) LastPaycheck ¶
func (w WeeklyCalculator) LastPaycheck(u *User) (*time.Time, error)
Click to show internal directories.
Click to hide internal directories.