Documentation ¶
Index ¶
- Variables
- func Process(u *User) error
- func ProcessDefaults(u *User) error
- func ProcessLastPaycheck(u *User) error
- func ProcessProducts(u *User) error
- func ProcessPurchaseAvailability(u *User) error
- func ProcessSaved(u *User) error
- func ProcessValidation(u *User) error
- type AmazonPAPIParser
- type AmazonParser
- type BiWeekly
- type Budget
- type BudgetView
- type Category
- type CategoryType
- type DefaultParser
- type Frequency
- type HTMLParser
- type Merchant
- type MetaTagParser
- type Monthly
- type OpenGraphParser
- type PAPIRequest
- type PAPIResponse
- type Processor
- type Product
- type Producter
- type Purchase
- type PushNotificationToken
- type SchemaOrgParser
- type Tracking
- type Transaction
- type TransactionTime
- type TwiceMonthly
- type User
- type Weekly
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingEmail = errors.New("missing Email") ErrMissingProductName = errors.New("missing product Name") ErrMissingProductPrice = errors.New("missing product Price") ErrMissingProductURL = errors.New("missing product URL") )
var ( ErrInvalidFrequency = errors.New("invalid contribution frequency") ErrInvalidAvailability = errors.New("invalid availability calculator") )
var Processors = []Processor{ ProcessDefaults, ProcessValidation, ProcessSaved, ProcessLastPaycheck, ProcessPurchaseAvailability, ProcessProducts, }
Functions ¶
func ProcessDefaults ¶
func ProcessLastPaycheck ¶
func ProcessProducts ¶
func ProcessSaved ¶
func ProcessValidation ¶
Types ¶
type AmazonPAPIParser ¶
AmazonPAPIParser parses amazon.com links with their Product API.
type AmazonParser ¶
AmazonParser is made specifically for parsing Amazon.com
type Budget ¶
type Budget struct { ID string View BudgetView Start time.Time End time.Time Categories []Category Transactions []Transaction }
type BudgetView ¶
type BudgetView int
type Category ¶
type Category struct { ID string Name string Group string Type CategoryType // PlannedInCents represents the planned amount * 100 (12.50 === 1250) // This helps avoid floating point issues with float64. PlannedInCents int64 }
type CategoryType ¶
type CategoryType string
type DefaultParser ¶
type DefaultParser struct { AmazonPAPIParser AmazonPAPIParser AmazonParser AmazonParser SchemaOrgParser SchemaOrgParser OpenGraphParser OpenGraphParser HTMLParser HTMLParser MetaTagParser MetaTagParser }
DefaultParser combines the above parsers in a single convenient parser.
func NewDefaultParser ¶
func NewDefaultParser(url string, body []byte, c config.C) DefaultParser
NewDefaultParser creates a new parser than combines other parsers.
type Frequency ¶
type Frequency interface { Saved() (int64, error) LastPaycheck() (*time.Time, error) PurchaseDate(*Purchase) (*time.Time, error) }
func NewFrequency ¶
type HTMLParser ¶
HTMLParser looks through the HTML for certain values. It's not very accurate but can make a last-ditch attempt.
type MetaTagParser ¶
MetaTagParser is more accurate than HTMLParser but will not be able to gather all info.
type OpenGraphParser ¶
OpenGraphParser is generally very accurate but pricing is not used widely.
type PAPIRequest ¶
type PAPIResponse ¶
type PAPIResponse struct { Errors []struct { Message string } ItemsResult struct { Items []struct { DetailPageURL string ItemInfo struct { Title struct { DisplayValue string } } Offers struct { Listings []struct { Price struct { Amount float64 } } } Images struct { Primary struct { Large struct { URL string } } } } } }
type Product ¶
type Product struct { Name string `datastore:",noindex" json:"name"` Description string `datastore:",noindex" json:"description"` Price int64 `json:"price"` URL string `datastore:",noindex" json:"url"` AffiliateURL string `datastore:",noindex" json:"affiliateURL"` Image string `datastore:",noindex" json:"image"` OriginalImage string `datastore:",noindex" json:"originalImage"` }
Product contains information about the thing a User wants to buy.
type Producter ¶
type Producter interface { // Product returns a Product and an error. Product(ctx context.Context) (Product, error) }
Producter is an interface for retrieving products.
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"` Notified bool `json:"notified"` }
Purchase is something a User wants to buy.
type PushNotificationToken ¶
type PushNotificationToken struct { // DeviceToken is the IOS or Android device's push notification token. DeviceToken string `datastore:",noindex" json:"deviceToken,omitempty"` // DeviceTokenType is "ios" or "android" DeviceTokenType string `datastore:",noindex" json:"deviceTokenType,omitempty"` // Expo token is used to send messages with expo's push notification service. ExpoToken string `datastore:",noindex" json:"expoToken,omitempty"` }
PushNotificationToken is used to save a user's device and expo push tokens. It also stores the type of push token, which determines where to send manual push notifications to if expo notifications don't work.
type SchemaOrgParser ¶
SchemaOrgParser is VERY accurate because it's what is intended to be shown On search engines.
type Tracking ¶
type Tracking struct { // UserID, if available, is the ID of the current user UserID string // PageviewID is a random ID for the current page view PageViewID string // Type is the type of tracking, such as a view or a click Type string // Name is some human-readable name to inform which event is happening Name string // Time is when the tracking happened Time time.Time // URL is the URL where the tracking happened URL string // UserAgent is the User-Agent header set in the request UserAgent string // Host is the Host header set in the request Host string // Referer is the Referer header set in the request Referer string // Country is the country where the request originated Country string // Region is the region where the request originated (ex. CA = California in the US) Region string // Trace is the unique ID for the request Trace string }
type Transaction ¶
type Transaction struct { ID string CategoryID string // AmountInCents represents the price * 100 (12.50 === 1250) // This helps avoid floating point issues with float64. AmountInCents int64 Time TransactionTime Merchant Merchant }
type TwiceMonthly ¶
type TwiceMonthly struct {
// contains filtered or unexported fields
}
func (TwiceMonthly) LastPaycheck ¶
func (w TwiceMonthly) LastPaycheck() (*time.Time, error)
func (TwiceMonthly) PurchaseDate ¶
func (w TwiceMonthly) PurchaseDate(p *Purchase) (*time.Time, error)
func (TwiceMonthly) Saved ¶
func (w TwiceMonthly) Saved() (int64, error)
type User ¶
type User struct { ID string `json:"id"` Issuer string `json:"issuer"` 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"` PushNotificationTokens []PushNotificationToken `json:"pushNotificationTokens,omitempty"` Budgets []Budget }
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.