api

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package api defines the core interfaces and data structures for expensor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Labels

type Labels map[string]struct {
	Category string `json:"category"`
	Bucket   string `json:"bucket"`
}

Labels maps merchant names to their category and bucket classification.

func (Labels) LabelLookup

func (l Labels) LabelLookup(merchant string) (category, bucket string)

LabelLookup returns the category and bucket for a merchant. Returns empty strings if the merchant is not found.

type Reader

type Reader interface {
	Read(ctx context.Context, out chan<- *TransactionDetails, ackChan <-chan string) error
}

Reader reads transactions from a source and sends them to the provided channel. Implementations should close the channel when done or on error. The ackChan is used to receive acknowledgments of successfully written transactions.

type Rule

type Rule struct {
	Name         string
	Query        string
	Amount       *regexp.Regexp
	MerchantInfo *regexp.Regexp
	Enabled      bool
	Source       string
}

Rule defines an email matching rule for transaction extraction.

type TransactionDetails

type TransactionDetails struct {
	Amount       float64 `json:"amount"`
	Timestamp    string  `json:"timestamp"`
	MerchantInfo string  `json:"merchant_info"`
	Category     string  `json:"category"`
	// Bucket classifies the expense as Need/Want/Investment.
	Bucket string `json:"bucket"`
	Source string `json:"source"`
	// MessageID is the email message ID (used for marking as read after successful write).
	MessageID string `json:"-"`
}

TransactionDetails holds extracted transaction information.

type Writer

type Writer interface {
	Write(ctx context.Context, in <-chan *TransactionDetails, ackChan chan<- string) error
}

Writer consumes transactions from a channel and writes them to a destination. Successfully written transaction message IDs are sent to the ackChan.

Jump to

Keyboard shortcuts

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