Documentation
¶
Index ¶
- Constants
- func IsTooEarly(err error) bool
- func ParseAmount(amount string) (float64, error)
- func ParseCurrency(amount, currency string) (*money.Money, error)
- type AttachFileRequest
- type BalanceHistoryAccount
- type BalanceHistoryAccountType
- type BalanceHistoryEntry
- type BalanceHistoryFilters
- type BalanceHistorySource
- type Budget
- type BudgetFilters
- type BudgetInvalidPeriodError
- type BudgetSettings
- type BudgetSummary
- type CategoriesResponse
- type Category
- type CategoryDependenciesError
- type CategoryDependents
- type CategoryFilters
- type Client
- func (c *Client) AttachFileToTransaction(ctx context.Context, id int64, af *AttachFileRequest) (*TransactionAttachment, error)
- func (c *Client) CreateCategory(ctx context.Context, category *CreateCategory) (*Category, error)
- func (c *Client) CreateCryptoManual(ctx context.Context, account *CreateCryptoManual) (*CryptoManual, error)
- func (c *Client) CreateCryptocurrency(ctx context.Context, req *CreateCryptocurrency) (*Cryptocurrency, error)
- func (c *Client) CreateManualAccount(ctx context.Context, account *CreateManualAccount) (*ManualAccount, error)
- func (c *Client) CreateTag(ctx context.Context, tag *CreateTag) (*Tag, error)
- func (c *Client) Delete(ctx context.Context, path string, options map[string]string, body ...any) (io.Reader, error)
- func (c *Client) DeleteBalanceHistoryForAccount(ctx context.Context, accountType BalanceHistoryAccountType, accountID int64) error
- func (c *Client) DeleteBalanceHistoryForCryptoSynced(ctx context.Context, accountID int64, symbol string) error
- func (c *Client) DeleteBudget(ctx context.Context, categoryID int64, startDate string) error
- func (c *Client) DeleteCategory(ctx context.Context, id int64, force bool) error
- func (c *Client) DeleteCryptoManual(ctx context.Context, id int64, opts *DeleteCryptoManualOptions) error
- func (c *Client) DeleteManualAccount(ctx context.Context, id int64, opts *DeleteManualAccountOptions) error
- func (c *Client) DeleteTag(ctx context.Context, id int64, force bool) error
- func (c *Client) DeleteTransaction(ctx context.Context, id int64) error
- func (c *Client) DeleteTransactionAttachment(ctx context.Context, fileID int64) error
- func (c *Client) DeleteTransactions(ctx context.Context, dtReq DeleteTransactionsRequest) error
- func (c *Client) Get(ctx context.Context, path string, options map[string]string) (io.Reader, error)
- func (c *Client) GetBalanceHistory(ctx context.Context, filters *BalanceHistoryFilters) ([]*BalanceHistoryAccount, error)
- func (c *Client) GetBalanceHistoryForAccount(ctx context.Context, accountType BalanceHistoryAccountType, accountID int64, ...) ([]*BalanceHistoryAccount, error)
- func (c *Client) GetBalanceHistoryForCryptoSynced(ctx context.Context, accountID int64, symbol string, ...) ([]*BalanceHistoryAccount, error)
- func (c *Client) GetBudgetSettings(ctx context.Context) (*BudgetSettings, error)
- func (c *Client) GetBudgetSummary(ctx context.Context, filters *BudgetFilters) (*BudgetSummary, error)
- func (c *Client) GetCategories(ctx context.Context, filters *CategoryFilters) ([]*Category, error)
- func (c *Client) GetCategory(ctx context.Context, id int64) (*Category, error)
- func (c *Client) GetCryptoManual(ctx context.Context) ([]*CryptoManual, error)
- func (c *Client) GetCryptoManualAccount(ctx context.Context, id int64) (*CryptoManual, error)
- func (c *Client) GetCryptoSynced(ctx context.Context) ([]*CryptoSyncedAccount, error)
- func (c *Client) GetCryptoSyncedAccount(ctx context.Context, id int64) (*CryptoSyncedAccount, error)
- func (c *Client) GetCryptoSyncedBalance(ctx context.Context, id int64, symbol string) (*CryptoSyncedBalance, error)
- func (c *Client) GetCryptocurrencies(ctx context.Context) ([]*Cryptocurrency, error)
- func (c *Client) GetManualAccount(ctx context.Context, id int64) (*ManualAccount, error)
- func (c *Client) GetManualAccounts(ctx context.Context) ([]*ManualAccount, error)
- func (c *Client) GetPlaidAccount(ctx context.Context, id int64) (*PlaidAccount, error)
- func (c *Client) GetPlaidAccounts(ctx context.Context) ([]*PlaidAccount, error)
- func (c *Client) GetRecurringItem(ctx context.Context, id int64, filters *RecurringItemFilters) (*RecurringItem, error)
- func (c *Client) GetRecurringItems(ctx context.Context, filters *RecurringItemFilters) ([]*RecurringItem, error)
- func (c *Client) GetTag(ctx context.Context, id int64) (*Tag, error)
- func (c *Client) GetTags(ctx context.Context) ([]*Tag, error)
- func (c *Client) GetTransaction(ctx context.Context, id int64) (*Transaction, error)
- func (c *Client) GetTransactionAttachmentURL(ctx context.Context, fileID int64) (*TransactionAttachmentURL, error)
- func (c *Client) GetTransactions(ctx context.Context, filters *TransactionFilters) (*TransactionsResponse, error)
- func (c *Client) GetUser(ctx context.Context) (*User, error)
- func (c *Client) GroupTransactions(ctx context.Context, req GroupTransactionsRequest) (*Transaction, error)
- func (c *Client) InsertTransactions(ctx context.Context, itReq InsertTransactionsRequest) (*InsertTransactionsResponse, error)
- func (c *Client) Post(ctx context.Context, path string, body any) (io.Reader, error)
- func (c *Client) Put(ctx context.Context, path string, body any) (io.Reader, error)
- func (c *Client) RefreshCryptoSynced(ctx context.Context, id int64) (*CryptoSyncedAccount, error)
- func (c *Client) SplitTransaction(ctx context.Context, id int64, req SplitTransactionRequest) (*Transaction, error)
- func (c *Client) TriggerPlaidFetch(ctx context.Context, filters *PlaidFetchFilters) ([]*PlaidAccount, error)
- func (c *Client) UngroupTransactions(ctx context.Context, id int64) error
- func (c *Client) UnsplitTransaction(ctx context.Context, id int64) error
- func (c *Client) UpdateCategory(ctx context.Context, id int64, category *UpdateCategory) (*Category, error)
- func (c *Client) UpdateCryptoManual(ctx context.Context, id int64, account *UpdateCryptoManual) (*CryptoManual, error)
- func (c *Client) UpdateManualAccount(ctx context.Context, id int64, account *UpdateManualAccount) (*ManualAccount, error)
- func (c *Client) UpdateTag(ctx context.Context, id int64, tag *UpdateTag) (*Tag, error)
- func (c *Client) UpdateTransaction(ctx context.Context, id int64, ut *UpdateTransaction) (*Transaction, error)
- func (c *Client) UpsertBalanceHistoryForAccount(ctx context.Context, accountType BalanceHistoryAccountType, accountID int64, ...) (*BalanceHistoryAccount, error)
- func (c *Client) UpsertBalanceHistoryForCryptoSynced(ctx context.Context, accountID int64, symbol string, ...) (*BalanceHistoryAccount, error)
- func (c *Client) UpsertBudget(ctx context.Context, budget *UpsertBudget) (*Budget, error)
- type CreateCategory
- type CreateCryptoManual
- type CreateCryptocurrency
- type CreateManualAccount
- type CreateTag
- type CryptoManual
- type CryptoSyncedAccount
- type CryptoSyncedBalance
- type Cryptocurrency
- type DeleteCryptoManualOptions
- type DeleteManualAccountOptions
- type DeleteTransactionsRequest
- type ErrorEntry
- type ErrorResponse
- type GroupTransactionsRequest
- type InsertTransaction
- type InsertTransactionsRequest
- type InsertTransactionsResponse
- type ManualAccount
- type ManualAccountsResponse
- type PlaidAccount
- type PlaidAccountsResponse
- type PlaidFetchFilters
- type RecurringCriteria
- type RecurringItem
- type RecurringItemFilters
- type RecurringItemsResponse
- type RecurringMatch
- type RecurringMatches
- type RecurringOverrides
- type RolloverAdjustment
- type RolloverPool
- type SkippedDuplicate
- type SplitTransactionChild
- type SplitTransactionRequest
- type SummaryCategory
- type SummaryCategoryTotal
- type SummaryOccurrence
- type SummaryTotals
- type SummaryTotalsBreakdown
- type Tag
- type TagDependents
- type TagInUseError
- type TagsResponse
- type Timestamp
- type Transaction
- type TransactionAttachment
- type TransactionAttachmentURL
- type TransactionFilters
- type TransactionsResponse
- type UpdateCategory
- type UpdateCryptoManual
- type UpdateManualAccount
- type UpdateTag
- type UpdateTransaction
- type UpsertBalanceHistory
- type UpsertBalanceHistoryItem
- type UpsertBudget
- type User
Constants ¶
const ( // CategoryFormatNested returns category groups with their members in a // Children slice. This is the API default. CategoryFormatNested = "nested" // CategoryFormatFlattened returns every category at the top level, which // is what v1 of the API did. CategoryFormatFlattened = "flattened" )
Category format options accepted by GetCategories.
const ( StatusReviewed = "reviewed" StatusUnreviewed = "unreviewed" StatusDeletePending = "delete_pending" )
Transaction status values. Pending transactions are flagged by IsPending rather than by a status.
const ( // BaseAPIURL is the base url we use for all API requests. It points at v2 // of the Lunch Money API; v1 is not supported by this library. BaseAPIURL = "https://api.lunchmoney.dev/v2/" )
Variables ¶
This section is empty.
Functions ¶
func IsTooEarly ¶ added in v0.11.0
IsTooEarly reports whether err is a 425 Too Early response, which the API returns when a Plaid fetch was already triggered within the last minute.
func ParseAmount ¶ added in v0.17.0
ParseAmount converts an amount string (e.g. "1250.8400", "-45.50") into a float64 rounded to two decimal places.
Types ¶
type AttachFileRequest ¶ added in v0.14.0
type AttachFileRequest struct {
// Name is the filename the API stores and shows.
Name string `validate:"required"`
// File is read to the end and buffered in memory before the upload starts.
File io.Reader `validate:"required"`
// ContentType overrides the type derived from Name's extension, which is
// worth setting for the formats Go has no mapping for.
ContentType string
// Notes is optional free text stored alongside the file.
Notes string
}
AttachFileRequest is a file to attach to a transaction. The API caps files at 10MB and accepts jpeg, png, pdf, heic and heif.
type BalanceHistoryAccount ¶ added in v0.16.0
type BalanceHistoryAccount struct {
Source *BalanceHistorySource `json:"source"`
Balances []*BalanceHistoryEntry `json:"balances"`
}
BalanceHistoryAccount groups one source account and its monthly balances.
type BalanceHistoryAccountType ¶ added in v0.16.0
type BalanceHistoryAccountType string
BalanceHistoryAccountType names path values accepted by balance-history account endpoints.
const ( BalanceHistoryAccountTypeManual BalanceHistoryAccountType = "manual" BalanceHistoryAccountTypePlaid BalanceHistoryAccountType = "plaid" BalanceHistoryAccountTypeCryptoManual BalanceHistoryAccountType = "crypto_manual" BalanceHistoryAccountTypeDeleted BalanceHistoryAccountType = "deleted" )
type BalanceHistoryEntry ¶ added in v0.16.0
type BalanceHistoryEntry struct {
Type string `json:"type"`
ID *int64 `json:"id,omitempty"`
Month string `json:"month"`
Balance string `json:"balance"`
Currency string `json:"currency"`
ToBase float64 `json:"to_base"`
CryptoBalance *string `json:"crypto_balance"`
}
BalanceHistoryEntry is one balance datapoint for a month.
func (*BalanceHistoryEntry) ParsedAmount ¶ added in v0.16.0
func (e *BalanceHistoryEntry) ParsedAmount() (*money.Money, error)
ParsedAmount converts the balance and currency into money.Money.
type BalanceHistoryFilters ¶ added in v0.16.0
BalanceHistoryFilters are optional month-range filters for balance history. StartMonth and EndMonth must be provided together.
type BalanceHistorySource ¶ added in v0.16.0
type BalanceHistorySource struct {
Type string `json:"type"`
ManualAccountID *int64 `json:"manual_account_id"`
PlaidAccountID *int64 `json:"plaid_account_id"`
CryptoManualID *int64 `json:"crypto_manual_id"`
CryptoSyncedID *int64 `json:"crypto_synced_id"`
DeletedAccountID *int64 `json:"deleted_account_id"`
Name *string `json:"name"`
InstitutionName *string `json:"institution_name"`
DisplayName *string `json:"display_name"`
AccountType *string `json:"account_type"`
Subtype *string `json:"subtype"`
Mask *string `json:"mask"`
Symbol *string `json:"symbol"`
}
BalanceHistorySource identifies an account source in balance history output.
type Budget ¶
type Budget struct {
CategoryID int64 `json:"category_id"`
StartDate string `json:"start_date"`
Amount string `json:"amount"`
Currency string `json:"currency"`
ToBase float64 `json:"to_base"`
Notes string `json:"notes"`
}
Budget is a single category's budget for one period.
func (*Budget) ParsedAmount ¶ added in v0.15.0
ParsedAmount converts the budgeted amount and currency into a money.Money.
func (*Budget) UnmarshalJSON ¶ added in v0.15.1
UnmarshalJSON decodes a budget, accepting an amount sent as a number as well as a string.
type BudgetFilters ¶
type BudgetFilters struct {
StartDate string `validate:"datetime=2006-01-02,required"`
EndDate string `validate:"datetime=2006-01-02,required"`
IncludeExcludeFromBudgets *bool
IncludeOccurrences *bool
IncludePastBudgetDates *bool
IncludeTotals *bool
IncludeRolloverPool *bool
}
BudgetFilters are options to pass into the request for a budget summary. Both dates are required.
type BudgetInvalidPeriodError ¶ added in v0.15.0
type BudgetInvalidPeriodError struct {
Message string `json:"message"`
ErrMsg string `json:"errMsg"`
RequestedStartDate string `json:"requested_start_date"`
// PreviousValidStartDate and NextValidStartDate are empty when the
// requested date has no valid period start before or after it.
PreviousValidStartDate string `json:"previous_valid_start_date"`
NextValidStartDate string `json:"next_valid_start_date"`
// Err is the API error the period details arrived as.
Err error `json:"-"`
}
BudgetInvalidPeriodError is the 400 returned when a start date is not a period start. It carries the valid dates either side; reachable with errors.As.
func (*BudgetInvalidPeriodError) Error ¶ added in v0.15.0
func (e *BudgetInvalidPeriodError) Error() string
func (*BudgetInvalidPeriodError) Unwrap ¶ added in v0.15.0
func (e *BudgetInvalidPeriodError) Unwrap() error
type BudgetSettings ¶ added in v0.7.0
type BudgetSettings struct {
// PeriodGranularity is one of day, week, month, year or "twice a month".
PeriodGranularity string `json:"budget_period_granularity"`
PeriodQuantity float64 `json:"budget_period_quantity"`
PeriodAnchorDate string `json:"budget_period_anchor_date"`
HideNoActivity bool `json:"budget_hide_no_activity"`
UseLastDayOfMonth bool `json:"budget_use_last_day_of_month"`
// IncomeOption is one of max, budgeted or activity.
IncomeOption string `json:"budget_income_option"`
RolloverLeftToBudget bool `json:"budget_rollover_left_to_budget"`
}
BudgetSettings describes how the user's budget periods are configured.
type BudgetSummary ¶ added in v0.7.0
type BudgetSummary struct {
// Aligned reports whether the requested range lines up with the user's
// configured budget periods. When false, the numbers cover a range that
// spans or splits budget periods.
Aligned bool `json:"aligned"`
Categories []*SummaryCategory `json:"categories"`
Totals *SummaryTotals `json:"totals,omitempty"`
RolloverPool *RolloverPool `json:"rollover_pool,omitempty"`
}
BudgetSummary is the budget and activity rollup for a date range. It replaces the per-category, per-month Budget list v1 returned from /budgets.
func (*BudgetSummary) CategoryByID ¶ added in v0.17.0
func (s *BudgetSummary) CategoryByID(id int64) *SummaryCategory
CategoryByID finds a category by its ID within the budget summary, or nil if not found.
func (*BudgetSummary) CategoryMap ¶ added in v0.17.0
func (s *BudgetSummary) CategoryMap() map[int64]*SummaryCategory
CategoryMap returns a map of category ID to SummaryCategory for convenient lookup.
type CategoriesResponse ¶
type CategoriesResponse struct {
Categories []*Category `json:"categories"`
}
CategoriesResponse is the response we get from requesting categories.
type Category ¶
type Category struct {
ID int64 `json:"id"` // Unique identifier for the category
Name string `json:"name"` // Display name of the category
Description string `json:"description"` // Optional description of the category
IsIncome bool `json:"is_income"` // Whether this category represents income
ExcludeFromBudget bool `json:"exclude_from_budget"` // Whether to exclude from budget calculations
ExcludeFromTotals bool `json:"exclude_from_totals"` // Whether to exclude from total calculations
UpdatedAt time.Time `json:"updated_at"` // Last modification timestamp
CreatedAt time.Time `json:"created_at"` // Creation timestamp
IsGroup bool `json:"is_group"` // Whether this category is a group
GroupID *int64 `json:"group_id"` // ID of the parent group, or nil
Children []*Category `json:"children,omitempty"` // Members of this group, when requesting the nested format
Archived bool `json:"archived"` // Whether the category is hidden in the app
ArchivedAt *time.Time `json:"archived_at"` // When the category was last archived, or nil
Order *int64 `json:"order"` // Position on the categories page, or nil for alphabetical
Collapsed bool `json:"collapsed"` // Whether the group appears collapsed in the app
}
Category is a single LM category. Categories can be grouped, and marked as income or excluded from budgets and totals.
type CategoryDependenciesError ¶ added in v0.9.0
type CategoryDependenciesError struct {
CategoryName string `json:"category_name"`
Dependents CategoryDependents `json:"dependents"`
// Err is the API error the dependents arrived as.
Err error `json:"-"`
}
CategoryDependenciesError is the 422 returned when a category still has dependents. Reachable with errors.As; force deletes it anyway.
func (*CategoryDependenciesError) Error ¶ added in v0.9.0
func (e *CategoryDependenciesError) Error() string
func (*CategoryDependenciesError) Unwrap ¶ added in v0.9.0
func (e *CategoryDependenciesError) Unwrap() error
type CategoryDependents ¶ added in v0.9.0
type CategoryDependents struct {
Budget int64 `json:"budget"`
CategoryRules int64 `json:"category_rules"`
Transactions int64 `json:"transactions"`
Children int64 `json:"children"`
Recurring int64 `json:"recurring"`
PlaidCats int64 `json:"plaid_cats"`
}
CategoryDependents counts what still refers to a category, by kind.
type CategoryFilters ¶ added in v0.7.0
type CategoryFilters struct {
// Format is either CategoryFormatNested or CategoryFormatFlattened. An
// empty value uses the API default, which is nested.
Format string `validate:"omitempty,oneof=nested flattened"`
// IsGroup, when set, restricts the response to category groups or to
// categories that are not groups.
IsGroup *bool
}
CategoryFilters are options to pass into the request for categories.
type Client ¶
Client holds our base configuration for our LunchMoney client.
func (*Client) AttachFileToTransaction ¶ added in v0.14.0
func (c *Client) AttachFileToTransaction(ctx context.Context, id int64, af *AttachFileRequest) (*TransactionAttachment, error)
AttachFileToTransaction uploads a file and attaches it to a transaction.
func (*Client) CreateCategory ¶ added in v0.9.0
CreateCategory creates a category or category group and returns it.
func (*Client) CreateCryptoManual ¶ added in v0.16.0
func (c *Client) CreateCryptoManual(ctx context.Context, account *CreateCryptoManual) (*CryptoManual, error)
CreateCryptoManual creates a manual crypto balance and returns it.
func (*Client) CreateCryptocurrency ¶ added in v0.16.0
func (c *Client) CreateCryptocurrency(ctx context.Context, req *CreateCryptocurrency) (*Cryptocurrency, error)
CreateCryptocurrency adds a supported cryptocurrency by CoinGecko URL.
func (*Client) CreateManualAccount ¶ added in v0.10.0
func (c *Client) CreateManualAccount(ctx context.Context, account *CreateManualAccount) (*ManualAccount, error)
CreateManualAccount creates a manual account and returns it.
func (*Client) Delete ¶ added in v0.7.0
func (c *Client) Delete(ctx context.Context, path string, options map[string]string, body ...any) (io.Reader, error)
Delete performs a DELETE request against the given path, with options as query parameters and an optional JSON body. v2 answers with 204 and no body.
func (*Client) DeleteBalanceHistoryForAccount ¶ added in v0.16.0
func (c *Client) DeleteBalanceHistoryForAccount(ctx context.Context, accountType BalanceHistoryAccountType, accountID int64) error
DeleteBalanceHistoryForAccount deletes all history entries for one account source.
func (*Client) DeleteBalanceHistoryForCryptoSynced ¶ added in v0.16.0
func (c *Client) DeleteBalanceHistoryForCryptoSynced(ctx context.Context, accountID int64, symbol string) error
DeleteBalanceHistoryForCryptoSynced deletes all entries for a synced symbol stream.
func (*Client) DeleteBudget ¶ added in v0.15.0
DeleteBudget removes the budget for a category and period. Removing a budget that is not set succeeds.
func (*Client) DeleteCategory ¶ added in v0.9.0
DeleteCategory deletes a category or group. Without force, one with dependents returns a *CategoryDependenciesError.
func (*Client) DeleteCryptoManual ¶ added in v0.16.0
func (c *Client) DeleteCryptoManual(ctx context.Context, id int64, opts *DeleteCryptoManualOptions) error
DeleteCryptoManual deletes one manual crypto balance.
func (*Client) DeleteManualAccount ¶ added in v0.10.0
func (c *Client) DeleteManualAccount(ctx context.Context, id int64, opts *DeleteManualAccountOptions) error
DeleteManualAccount deletes the manual account with the given ID.
func (*Client) DeleteTag ¶ added in v0.8.0
DeleteTag deletes a tag. Without force, one that rules or transactions reference returns a *TagInUseError.
func (*Client) DeleteTransaction ¶ added in v0.12.0
DeleteTransaction deletes a transaction, irreversibly. The API refuses split or grouped ones; unsplit or ungroup first.
func (*Client) DeleteTransactionAttachment ¶ added in v0.14.0
DeleteTransactionAttachment detaches a file from its transaction and deletes it.
func (*Client) DeleteTransactions ¶ added in v0.12.0
func (c *Client) DeleteTransactions(ctx context.Context, dtReq DeleteTransactionsRequest) error
DeleteTransactions deletes the transactions with the specified IDs.
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, path string, options map[string]string) (io.Reader, error)
Get performs a GET request against the given path, with options as query parameters.
func (*Client) GetBalanceHistory ¶ added in v0.16.0
func (c *Client) GetBalanceHistory(ctx context.Context, filters *BalanceHistoryFilters) ([]*BalanceHistoryAccount, error)
GetBalanceHistory returns balance history grouped by account source.
func (*Client) GetBalanceHistoryForAccount ¶ added in v0.16.0
func (c *Client) GetBalanceHistoryForAccount(ctx context.Context, accountType BalanceHistoryAccountType, accountID int64, filters *BalanceHistoryFilters) ([]*BalanceHistoryAccount, error)
GetBalanceHistoryForAccount returns balance history for one account source.
func (*Client) GetBalanceHistoryForCryptoSynced ¶ added in v0.16.0
func (c *Client) GetBalanceHistoryForCryptoSynced(ctx context.Context, accountID int64, symbol string, filters *BalanceHistoryFilters) ([]*BalanceHistoryAccount, error)
GetBalanceHistoryForCryptoSynced returns balance history for one synced symbol stream.
func (*Client) GetBudgetSettings ¶ added in v0.7.0
func (c *Client) GetBudgetSettings(ctx context.Context) (*BudgetSettings, error)
GetBudgetSettings returns the user's budget period configuration.
func (*Client) GetBudgetSummary ¶ added in v0.7.0
func (c *Client) GetBudgetSummary(ctx context.Context, filters *BudgetFilters) (*BudgetSummary, error)
GetBudgetSummary returns the budget and activity summary for a period. It replaces v1's GetBudgets.
func (*Client) GetCategories ¶ added in v0.4.0
GetCategories returns all categories, nested by default. Pass CategoryFormatFlattened for the v1 shape.
func (*Client) GetCategory ¶ added in v0.4.0
GetCategory retrieves a single category by its ID.
func (*Client) GetCryptoManual ¶ added in v0.16.0
func (c *Client) GetCryptoManual(ctx context.Context) ([]*CryptoManual, error)
GetCryptoManual returns all manual crypto balances.
func (*Client) GetCryptoManualAccount ¶ added in v0.16.0
GetCryptoManualAccount returns one manual crypto balance by ID.
func (*Client) GetCryptoSynced ¶ added in v0.16.0
func (c *Client) GetCryptoSynced(ctx context.Context) ([]*CryptoSyncedAccount, error)
GetCryptoSynced returns all synced crypto accounts.
func (*Client) GetCryptoSyncedAccount ¶ added in v0.16.0
func (c *Client) GetCryptoSyncedAccount(ctx context.Context, id int64) (*CryptoSyncedAccount, error)
GetCryptoSyncedAccount returns one synced crypto account by ID.
func (*Client) GetCryptoSyncedBalance ¶ added in v0.16.0
func (c *Client) GetCryptoSyncedBalance(ctx context.Context, id int64, symbol string) (*CryptoSyncedBalance, error)
GetCryptoSyncedBalance returns one symbol balance from a synced crypto account.
func (*Client) GetCryptocurrencies ¶ added in v0.16.0
func (c *Client) GetCryptocurrencies(ctx context.Context) ([]*Cryptocurrency, error)
GetCryptocurrencies returns all symbols supported for manual crypto balances.
func (*Client) GetManualAccount ¶ added in v0.7.0
GetManualAccount retrieves a single manual account by its ID.
func (*Client) GetManualAccounts ¶ added in v0.7.0
func (c *Client) GetManualAccounts(ctx context.Context) ([]*ManualAccount, error)
GetManualAccounts retrieves all manual accounts.
func (*Client) GetPlaidAccount ¶ added in v0.7.0
GetPlaidAccount retrieves a single Plaid-connected account by its ID.
func (*Client) GetPlaidAccounts ¶
func (c *Client) GetPlaidAccounts(ctx context.Context) ([]*PlaidAccount, error)
GetPlaidAccounts retrieves all Plaid-connected accounts.
func (*Client) GetRecurringItem ¶ added in v0.7.0
func (c *Client) GetRecurringItem(ctx context.Context, id int64, filters *RecurringItemFilters) (*RecurringItem, error)
GetRecurringItem retrieves a single recurring item by its ID. The filters control the date range used to populate the item's Matches.
func (*Client) GetRecurringItems ¶ added in v0.7.0
func (c *Client) GetRecurringItems(ctx context.Context, filters *RecurringItemFilters) ([]*RecurringItem, error)
GetRecurringItems retrieves recurring items matching filters.
func (*Client) GetTransaction ¶
GetTransaction retrieves a single transaction by its ID.
func (*Client) GetTransactionAttachmentURL ¶ added in v0.14.0
func (c *Client) GetTransactionAttachmentURL(ctx context.Context, fileID int64) (*TransactionAttachmentURL, error)
GetTransactionAttachmentURL returns a signed, expiring link to an attachment.
func (*Client) GetTransactions ¶
func (c *Client) GetTransactions(ctx context.Context, filters *TransactionFilters) (*TransactionsResponse, error)
GetTransactions retrieves transactions matching filters, plus a flag saying whether more remain beyond this page.
func (*Client) GroupTransactions ¶ added in v0.13.0
func (c *Client) GroupTransactions(ctx context.Context, req GroupTransactionsRequest) (*Transaction, error)
GroupTransactions groups transactions and returns the new group parent with its children populated.
func (*Client) InsertTransactions ¶ added in v0.5.0
func (c *Client) InsertTransactions(ctx context.Context, itReq InsertTransactionsRequest) (*InsertTransactionsResponse, error)
InsertTransactions creates new transactions.
func (*Client) Post ¶ added in v0.5.0
Post performs a POST request against the given path with body as JSON.
func (*Client) Put ¶ added in v0.4.0
Put performs a PUT request against the given path with body as JSON.
func (*Client) RefreshCryptoSynced ¶ added in v0.16.0
RefreshCryptoSynced triggers a refresh and returns the updated synced account.
func (*Client) SplitTransaction ¶ added in v0.13.0
func (c *Client) SplitTransaction(ctx context.Context, id int64, req SplitTransactionRequest) (*Transaction, error)
SplitTransaction splits a transaction and returns the split parent with its new children populated.
func (*Client) TriggerPlaidFetch ¶ added in v0.11.0
func (c *Client) TriggerPlaidFetch(ctx context.Context, filters *PlaidFetchFilters) ([]*PlaidAccount, error)
TriggerPlaidFetch queues a background fetch from Plaid. It answers 425 if one was triggered in the last minute; check with IsTooEarly.
func (*Client) UngroupTransactions ¶ added in v0.13.0
UngroupTransactions deletes a transaction group, leaving its members as ungrouped transactions.
func (*Client) UnsplitTransaction ¶ added in v0.13.0
UnsplitTransaction deletes the children of a split transaction and restores the parent. In v1 this was POST /transactions/unsplit.
func (*Client) UpdateCategory ¶ added in v0.9.0
func (c *Client) UpdateCategory(ctx context.Context, id int64, category *UpdateCategory) (*Category, error)
UpdateCategory updates the category with the given ID and returns it.
func (*Client) UpdateCryptoManual ¶ added in v0.16.0
func (c *Client) UpdateCryptoManual(ctx context.Context, id int64, account *UpdateCryptoManual) (*CryptoManual, error)
UpdateCryptoManual updates one manual crypto balance and returns it.
func (*Client) UpdateManualAccount ¶ added in v0.7.0
func (c *Client) UpdateManualAccount(ctx context.Context, id int64, account *UpdateManualAccount) (*ManualAccount, error)
UpdateManualAccount updates the account with the given ID and returns it.
func (*Client) UpdateTag ¶ added in v0.8.0
UpdateTag modifies the tag with the given ID and returns it.
func (*Client) UpdateTransaction ¶ added in v0.4.0
func (c *Client) UpdateTransaction(ctx context.Context, id int64, ut *UpdateTransaction) (*Transaction, error)
UpdateTransaction modifies a transaction and returns it. Use SplitTransaction to split one.
func (*Client) UpsertBalanceHistoryForAccount ¶ added in v0.16.0
func (c *Client) UpsertBalanceHistoryForAccount(ctx context.Context, accountType BalanceHistoryAccountType, accountID int64, request *UpsertBalanceHistory) (*BalanceHistoryAccount, error)
UpsertBalanceHistoryForAccount upserts one or more entries for one account source.
func (*Client) UpsertBalanceHistoryForCryptoSynced ¶ added in v0.16.0
func (c *Client) UpsertBalanceHistoryForCryptoSynced(ctx context.Context, accountID int64, symbol string, request *UpsertBalanceHistory) (*BalanceHistoryAccount, error)
UpsertBalanceHistoryForCryptoSynced upserts one or more entries for a synced symbol stream.
func (*Client) UpsertBudget ¶ added in v0.15.0
UpsertBudget sets the budget for a category and period, creating it if there is none, and returns it.
type CreateCategory ¶ added in v0.9.0
type CreateCategory struct {
Name string `json:"name" validate:"required,min=1,max=100"`
Description string `json:"description,omitempty" validate:"max=200"`
IsIncome bool `json:"is_income,omitempty"`
ExcludeFromBudget bool `json:"exclude_from_budget,omitempty"`
ExcludeFromTotals bool `json:"exclude_from_totals,omitempty"`
IsGroup bool `json:"is_group,omitempty"`
GroupID *int64 `json:"group_id,omitempty"`
Archived bool `json:"archived,omitempty"`
// Children populates a new group, and may only be set alongside IsGroup.
// Each entry is the ID of an existing category, the name of a category to
// create, or a Category.
Children []any `json:"children,omitempty"`
Order *int64 `json:"order,omitempty"`
Collapsed *bool `json:"collapsed,omitempty"`
}
CreateCategory is a category to create. Name is required. Setting IsGroup creates a category group, which is what v1 used /categories/group for.
type CreateCryptoManual ¶ added in v0.16.0
type CreateCryptoManual struct {
Name string `json:"name" validate:"required,min=1,max=45"`
DisplayName *string `json:"display_name,omitempty" validate:"omitnil,min=1,max=45"`
InstitutionName *string `json:"institution_name,omitempty" validate:"omitnil,min=1,max=50"`
Balance string `json:"balance" validate:"required"`
Symbol string `json:"symbol" validate:"required,min=1,max=25"`
}
CreateCryptoManual is the request body for creating a manual crypto balance.
type CreateCryptocurrency ¶ added in v0.16.0
type CreateCryptocurrency struct {
CoingeckoURL string `json:"coingecko_url" validate:"required,min=1,max=200"`
}
CreateCryptocurrency is the request body for adding a supported cryptocurrency.
type CreateManualAccount ¶ added in v0.10.0
type CreateManualAccount struct {
Name string `json:"name" validate:"required,min=1,max=45"`
InstitutionName *string `json:"institution_name,omitempty" validate:"omitnil,min=1,max=50"`
DisplayName *string `json:"display_name,omitempty"`
Type string `` /* 170-byte string literal not displayed */
Subtype *string `json:"subtype,omitempty" validate:"omitnil,min=1,max=100"`
Balance string `json:"balance" validate:"required"`
Currency *string `json:"currency,omitempty" validate:"omitnil,len=3"`
BalanceAsOf *string `json:"balance_as_of,omitempty"`
Status *string `json:"status,omitempty" validate:"omitnil,oneof=active closed"`
ClosedOn *string `json:"closed_on,omitempty"`
ExternalID *string `json:"external_id,omitempty" validate:"omitnil,max=75"`
CustomMetadata *map[string]any `json:"custom_metadata,omitempty"`
ExcludeFromTransactions *bool `json:"exclude_from_transactions,omitempty"`
}
CreateManualAccount describes a new manual account. Name, Type and Balance are required; only non-nil optional fields are sent.
type CreateTag ¶ added in v0.8.0
type CreateTag struct {
Name string `json:"name" validate:"required,min=1,max=100"`
Description string `json:"description,omitempty" validate:"max=200"`
TextColor string `json:"text_color,omitempty"`
BackgroundColor string `json:"background_color,omitempty"`
Archived bool `json:"archived,omitempty"`
}
CreateTag is a tag to create. Name is required and has to be unique.
type CryptoManual ¶ added in v0.16.0
type CryptoManual struct {
ID int64 `json:"id"`
Name string `json:"name"`
DisplayName *string `json:"display_name"`
InstitutionName *string `json:"institution_name"`
Balance string `json:"balance"`
Symbol string `json:"symbol"`
CoingeckoID *string `json:"coingecko_id"`
ToBase *float64 `json:"to_base"`
BalanceAsOf *Timestamp `json:"balance_as_of"`
ExchangeRateAsOf *Timestamp `json:"exchange_rate_as_of"`
CreatedByName *string `json:"created_by_name"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
CryptoManual is one manually managed crypto balance.
func (*CryptoManual) ParsedAmount ¶ added in v0.16.0
func (a *CryptoManual) ParsedAmount(primaryCurrency string) (*money.Money, error)
ParsedAmount converts the balance and symbol's currency into money.Money.
type CryptoSyncedAccount ¶ added in v0.16.0
type CryptoSyncedAccount struct {
ID int64 `json:"id"`
Provider string `json:"provider"`
Status string `json:"status"`
CreatedByName *string `json:"created_by_name"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LastImport *Timestamp `json:"last_import"`
DisplayName *string `json:"display_name"`
Balances []*CryptoSyncedBalance `json:"balances"`
}
CryptoSyncedAccount is one synced crypto connection and its balances.
type CryptoSyncedBalance ¶ added in v0.16.0
type CryptoSyncedBalance struct {
Name string `json:"name"`
DisplayName *string `json:"display_name"`
Balance string `json:"balance"`
Symbol string `json:"symbol"`
CoingeckoID *string `json:"coingecko_id"`
ToBase *float64 `json:"to_base"`
BalanceAsOf *Timestamp `json:"balance_as_of"`
ExchangeRateAsOf *Timestamp `json:"exchange_rate_as_of"`
UpdatedAt time.Time `json:"updated_at"`
}
CryptoSyncedBalance is one symbol balance nested under a synced crypto account.
func (*CryptoSyncedBalance) ParsedAmount ¶ added in v0.16.0
func (a *CryptoSyncedBalance) ParsedAmount(primaryCurrency string) (*money.Money, error)
ParsedAmount converts the converted balance value to money.Money.
type Cryptocurrency ¶ added in v0.16.0
type Cryptocurrency struct {
ID int64 `json:"id"`
CoingeckoID string `json:"coingecko_id"`
Symbol string `json:"symbol"`
FullName string `json:"full_name"`
}
Cryptocurrency is one symbol supported for manual crypto tracking.
type DeleteCryptoManualOptions ¶ added in v0.16.0
type DeleteCryptoManualOptions struct {
KeepHistory *bool
}
DeleteCryptoManualOptions configures whether account history is retained.
type DeleteManualAccountOptions ¶ added in v0.10.0
type DeleteManualAccountOptions struct {
// DeleteItems also deletes the transactions, rules and recurring items
// associated with the account.
DeleteItems *bool
DeleteBalanceHistory *bool
}
DeleteManualAccountOptions are options to pass to a delete request. Both default to false, and deleting items cannot be undone.
type DeleteTransactionsRequest ¶ added in v0.12.0
type DeleteTransactionsRequest struct {
IDs []int64 `json:"ids" validate:"min=1,max=500"`
}
DeleteTransactionsRequest deletes transactions in bulk. The whole request fails if any ID repeats, is unknown, or is split or grouped.
type ErrorEntry ¶ added in v0.7.0
ErrorEntry is a single problem reported inside an ErrorResponse. The API is free to add fields per error type, so unrecognized keys are kept in Extra.
func (*ErrorEntry) UnmarshalJSON ¶ added in v0.7.0
func (e *ErrorEntry) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes an error entry, keeping any fields beyond errMsg in Extra.
type ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"message"`
Errors []ErrorEntry `json:"errors,omitempty"`
// StatusCode is the HTTP status the body arrived with.
StatusCode int `json:"-"`
// RawBody is the undecoded error body, for the endpoints that answer a
// failure with a shape of their own rather than message and errors.
RawBody []byte `json:"-"`
}
ErrorResponse is the body the v2 API returns with a 4xx or 5xx. Failing calls wrap one, reachable with errors.As.
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type GroupTransactionsRequest ¶ added in v0.13.0
type GroupTransactionsRequest struct {
IDs []int64 `json:"ids" validate:"min=2,max=500"`
Date string `json:"date" validate:"datetime=2006-01-02"`
Payee string `json:"payee" validate:"max=140"`
CategoryID *int64 `json:"category_id,omitempty"`
Notes string `json:"notes,omitempty"`
Status string `json:"status,omitempty" validate:"omitempty,oneof=reviewed unreviewed"`
TagIDs []int64 `json:"tag_ids,omitempty"`
}
GroupTransactionsRequest groups transactions into a new one. Date and Payee are sent even when empty; the API requires both keys.
type InsertTransaction ¶ added in v0.5.0
type InsertTransaction struct {
Date string `json:"date" validate:"datetime=2006-01-02"`
Amount string `json:"amount" validate:"required"`
Currency string `json:"currency,omitempty"`
Payee string `json:"payee,omitempty"`
OriginalName string `json:"original_name,omitempty"`
CategoryID *int64 `json:"category_id,omitempty"`
Notes string `json:"notes,omitempty"`
ManualAccountID *int64 `json:"manual_account_id,omitempty"`
PlaidAccountID *int64 `json:"plaid_account_id,omitempty"`
RecurringID *int64 `json:"recurring_id,omitempty"`
Status string `json:"status,omitempty" validate:"omitempty,oneof=reviewed unreviewed"`
TagIDs []int64 `json:"tag_ids,omitempty"`
ExternalID string `json:"external_id,omitempty" validate:"max=75"`
CustomMetadata map[string]any `json:"custom_metadata,omitempty"`
}
InsertTransaction is a transaction to create. Date and Amount are required. Tags must already exist: v2 takes IDs and will not create tags inline.
type InsertTransactionsRequest ¶ added in v0.5.0
type InsertTransactionsRequest struct {
Transactions []InsertTransaction `json:"transactions" validate:"min=1,max=500,dive"`
ApplyRules bool `json:"apply_rules,omitempty"`
SkipDuplicates bool `json:"skip_duplicates,omitempty"`
SkipBalanceUpdate bool `json:"skip_balance_update,omitempty"`
}
InsertTransactionsRequest creates one or more transactions.
type InsertTransactionsResponse ¶ added in v0.5.0
type InsertTransactionsResponse struct {
Transactions []*Transaction `json:"transactions"`
SkippedDuplicates []SkippedDuplicate `json:"skipped_duplicates"`
}
InsertTransactionsResponse holds the results of an InsertTransactions call. Accepted rows come back in Transactions, duplicates in SkippedDuplicates.
type ManualAccount ¶ added in v0.7.0
type ManualAccount struct {
ID int64 `json:"id"`
Name string `json:"name"`
InstitutionName string `json:"institution_name"`
DisplayName string `json:"display_name"`
// Type is one of cash, credit, cryptocurrency, employee compensation,
// investment, loan, other liability, other asset, real estate or vehicle.
// The v1 "depository" type is now "cash".
Type string `json:"type"`
Subtype string `json:"subtype"`
Balance string `json:"balance"`
Currency string `json:"currency"`
ToBase float64 `json:"to_base"` // the balance converted to the user's primary currency
BalanceAsOf Timestamp `json:"balance_as_of"`
Status string `json:"status"`
ClosedOn string `json:"closed_on"`
ExternalID string `json:"external_id"`
CustomMetadata map[string]any `json:"custom_metadata"`
ExcludeFromTransactions bool `json:"exclude_from_transactions"`
CreatedByName string `json:"created_by_name"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ManualAccount is a single LM manual account. In v1 of the API these were called assets.
func (*ManualAccount) ParsedAmount ¶ added in v0.7.0
func (a *ManualAccount) ParsedAmount() (*money.Money, error)
ParsedAmount converts the account's balance and currency into a money.Money.
type ManualAccountsResponse ¶ added in v0.7.0
type ManualAccountsResponse struct {
ManualAccounts []*ManualAccount `json:"manual_accounts"`
}
ManualAccountsResponse is a response to a manual account lookup.
type PlaidAccount ¶
type PlaidAccount struct {
ID int64 `json:"id"`
PlaidItemID string `json:"plaid_item_id"`
DateLinked string `json:"date_linked"`
LinkedByName string `json:"linked_by_name"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
Type string `json:"type"`
Subtype string `json:"subtype"`
Mask string `json:"mask"`
InstitutionName string `json:"institution_name"`
// Status is one of active, inactive, closed, deactivated, not found,
// not supported, relink, syncing, revoked or error.
Status string `json:"status"`
AllowTransactionModifications bool `json:"allow_transaction_modifications"`
Limit *float64 `json:"limit"`
Balance string `json:"balance"`
Currency string `json:"currency"`
ToBase float64 `json:"to_base"` // the balance converted to the user's primary currency
BalanceLastUpdate *time.Time `json:"balance_last_update"`
ImportStartDate string `json:"import_start_date"`
LastImport *time.Time `json:"last_import"`
LastFetch *time.Time `json:"last_fetch"`
PlaidLastSuccessfulUpdate *time.Time `json:"plaid_last_successful_update"`
}
PlaidAccount is a single LM Plaid account.
func (*PlaidAccount) ParsedAmount ¶
func (p *PlaidAccount) ParsedAmount() (*money.Money, error)
ParsedAmount converts the account's balance and currency into a money.Money.
type PlaidAccountsResponse ¶
type PlaidAccountsResponse struct {
PlaidAccounts []*PlaidAccount `json:"plaid_accounts"`
}
PlaidAccountsResponse is a list plaid accounts response.
type PlaidFetchFilters ¶ added in v0.11.0
type PlaidFetchFilters struct {
// StartDate and EndDate bound the transactions to fetch. The API requires
// both or neither, so required_with comes before omitnil: omitnil
// short-circuits the rest of the tag when the field is nil, which is
// exactly the case the pairing rule has to catch.
StartDate *string `validate:"required_with=EndDate,omitnil,datetime=2006-01-02"`
EndDate *string `validate:"required_with=StartDate,omitnil,datetime=2006-01-02"`
// ID limits the fetch to a single Plaid account.
ID *int64
}
PlaidFetchFilters narrows what TriggerPlaidFetch asks Plaid for. All fields are optional; a nil filter fetches every eligible account.
type RecurringCriteria ¶ added in v0.7.0
type RecurringCriteria struct {
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
// Granularity is one of day, week, month or year, and combines with
// Quantity and AnchorDate to describe the cadence.
Granularity string `json:"granularity"`
Quantity int64 `json:"quantity"`
AnchorDate string `json:"anchor_date"`
Payee string `json:"payee"`
Amount string `json:"amount"`
ToBase float64 `json:"to_base"`
Currency string `json:"currency"`
PlaidAccountID *int64 `json:"plaid_account_id"`
ManualAccountID *int64 `json:"manual_account_id"`
}
RecurringCriteria is the set of properties used to identify transactions that match a recurring item.
func (*RecurringCriteria) Cadence ¶ added in v0.17.0
func (c *RecurringCriteria) Cadence() string
Cadence returns a human-readable description of the recurrence schedule, e.g. "monthly", "weekly", "every 2 weeks".
func (*RecurringCriteria) MonthlyFactor ¶ added in v0.17.0
func (c *RecurringCriteria) MonthlyFactor() (float64, bool)
MonthlyFactor converts the item's recurrence granularity and quantity into a per-month multiplier. Returns 0, false if the cadence is unrecognized or invalid (e.g. quantity <= 0).
type RecurringItem ¶ added in v0.7.0
type RecurringItem struct {
ID int64 `json:"id"`
Description string `json:"description"`
// Status is either "suggested" or "reviewed". Only reviewed items are
// applied to matching transactions.
Status string `json:"status"`
TransactionCriteria RecurringCriteria `json:"transaction_criteria"`
Overrides RecurringOverrides `json:"overrides"`
Matches *RecurringMatches `json:"matches"`
CreatedBy int64 `json:"created_by"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// Source is one of manual, transaction or system, and is empty for some
// older recurring items.
Source string `json:"source"`
}
RecurringItem is a transaction scheduled to happen repeatedly. v1 called these recurring expenses and kept the criteria flat.
func (*RecurringItem) MonthlyAmount ¶ added in v0.17.0
func (r *RecurringItem) MonthlyAmount() (float64, error)
MonthlyAmount calculates the effective monthly obligation for this recurring item.
func (*RecurringItem) ParsedAmount ¶ added in v0.7.0
func (r *RecurringItem) ParsedAmount() (*money.Money, error)
ParsedAmount converts the item's expected amount and currency into a money.Money.
type RecurringItemFilters ¶ added in v0.7.0
type RecurringItemFilters struct {
StartDate string `validate:"required_with=EndDate,omitempty,datetime=2006-01-02"`
EndDate string `validate:"required_with=StartDate,omitempty,datetime=2006-01-02"`
IncludeSuggested *bool
}
RecurringItemFilters are options for the request. StartDate and EndDate must be given together.
type RecurringItemsResponse ¶ added in v0.7.0
type RecurringItemsResponse struct {
RecurringItems []*RecurringItem `json:"recurring_items"`
}
RecurringItemsResponse is the data struct we get back from a get request.
type RecurringMatch ¶ added in v0.7.0
type RecurringMatch struct {
Date string `json:"date"`
TransactionID int64 `json:"transaction_id"`
}
RecurringMatch is a single transaction that matched a recurring item.
type RecurringMatches ¶ added in v0.7.0
type RecurringMatches struct {
RequestStartDate string `json:"request_start_date"`
RequestEndDate string `json:"request_end_date"`
ExpectedOccurrenceDates []string `json:"expected_occurrence_dates"`
FoundTransactions []RecurringMatch `json:"found_transactions"`
MissingTransactionDates []string `json:"missing_transaction_dates"`
}
RecurringMatches describes the expected, found and missing transactions for the requested date range. It is nil for items with a "suggested" status.
type RecurringOverrides ¶ added in v0.7.0
type RecurringOverrides struct {
Payee string `json:"payee"`
Notes string `json:"notes"`
CategoryID *int64 `json:"category_id"`
}
RecurringOverrides are the values applied to transactions that match a recurring item.
type RolloverAdjustment ¶ added in v0.7.0
type RolloverAdjustment struct {
InRange bool `json:"in_range"`
Date string `json:"date"`
Amount string `json:"amount"`
Currency string `json:"currency"`
ToBase float64 `json:"to_base"`
}
RolloverAdjustment is a single change to the rollover pool.
func (*RolloverAdjustment) ParsedAmount ¶ added in v0.7.0
func (a *RolloverAdjustment) ParsedAmount() (*money.Money, error)
ParsedAmount converts the adjustment's amount and currency into a money.Money.
type RolloverPool ¶ added in v0.7.0
type RolloverPool struct {
BudgetedToBase float64 `json:"budgeted_to_base"`
AllAdjustments []RolloverAdjustment `json:"all_adjustments"`
}
RolloverPool is the left-to-budget pool and the adjustments made to it. It is only present when the IncludeRolloverPool filter is set.
type SkippedDuplicate ¶ added in v0.7.0
type SkippedDuplicate struct {
// Reason is either "duplicate_external_id" or "duplicate_payee_amount_date".
Reason string `json:"reason"`
RequestTransactionIndex int64 `json:"request_transactions_index"`
ExistingTransactionID int64 `json:"existing_transaction_id"`
RequestTransaction InsertTransaction `json:"request_transaction"`
}
SkippedDuplicate describes a transaction the API declined to insert because it matched an existing one.
type SplitTransactionChild ¶ added in v0.13.0
type SplitTransactionChild struct {
Amount string `json:"amount" validate:"required"`
Payee string `json:"payee,omitempty" validate:"max=140"`
Date string `json:"date,omitempty" validate:"omitempty,datetime=2006-01-02"`
CategoryID *int64 `json:"category_id,omitempty"`
TagIDs []int64 `json:"tag_ids,omitempty"`
Notes string `json:"notes,omitempty"`
}
SplitTransactionChild is one child of a split. Only Amount is required; every other field is inherited from the parent when left unset.
type SplitTransactionRequest ¶ added in v0.13.0
type SplitTransactionRequest struct {
ChildTransactions []SplitTransactionChild `json:"child_transactions" validate:"min=2,max=500,dive"`
}
SplitTransactionRequest splits one transaction into child transactions. The children's amounts must sum to the parent's amount.
type SummaryCategory ¶ added in v0.7.0
type SummaryCategory struct {
CategoryID int64 `json:"category_id"`
Totals SummaryCategoryTotal `json:"totals"`
Occurrences []SummaryOccurrence `json:"occurrences,omitempty"`
}
SummaryCategory is one category's budget and activity within the range.
type SummaryCategoryTotal ¶ added in v0.7.0
type SummaryCategoryTotal struct {
OtherActivity float64 `json:"other_activity"`
RecurringActivity float64 `json:"recurring_activity"`
Budgeted *float64 `json:"budgeted"`
Available *float64 `json:"available"`
RecurringRemaining float64 `json:"recurring_remaining"`
RecurringExpected float64 `json:"recurring_expected"`
}
SummaryCategoryTotal holds a category's amounts across the whole range, in the user's primary currency.
type SummaryOccurrence ¶ added in v0.7.0
type SummaryOccurrence struct {
InRange bool `json:"in_range"`
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
OtherActivity float64 `json:"other_activity"`
RecurringActivity float64 `json:"recurring_activity"`
Budgeted *float64 `json:"budgeted"`
BudgetedAmount string `json:"budgeted_amount"`
BudgetedCurrency string `json:"budgeted_currency"`
Notes string `json:"notes"`
}
SummaryOccurrence is a category's amounts for a single budget period within the requested range.
func (*SummaryOccurrence) ParsedAmount ¶ added in v0.7.0
func (o *SummaryOccurrence) ParsedAmount() (*money.Money, error)
ParsedAmount converts the budgeted amount and currency into a money.Money.
type SummaryTotals ¶ added in v0.7.0
type SummaryTotals struct {
Inflow SummaryTotalsBreakdown `json:"inflow"`
Outflow SummaryTotalsBreakdown `json:"outflow"`
}
SummaryTotals splits the range's activity into money coming in and going out. It is only present when the IncludeTotals filter is set.
type SummaryTotalsBreakdown ¶ added in v0.7.0
type SummaryTotalsBreakdown struct {
OtherActivity float64 `json:"other_activity"`
RecurringActivity float64 `json:"recurring_activity"`
RecurringRemaining float64 `json:"recurring_remaining"`
RecurringExpected float64 `json:"recurring_expected"`
Uncategorized float64 `json:"uncategorized"`
UncategorizedCount int64 `json:"uncategorized_count"`
UncategorizedRecurring float64 `json:"uncategorized_recurring"`
}
SummaryTotalsBreakdown is one direction's activity across the range.
type Tag ¶
type Tag struct {
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
TextColor string `json:"text_color"`
BackgroundColor string `json:"background_color"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Archived bool `json:"archived"`
ArchivedAt *time.Time `json:"archived_at"`
}
Tag is a single LM tag.
type TagDependents ¶ added in v0.8.0
TagDependents counts the records that still reference a tag.
type TagInUseError ¶ added in v0.8.0
type TagInUseError struct {
TagName string `json:"tag_name"`
Dependents TagDependents `json:"dependents"`
// Err is the API error the dependents arrived as.
Err error `json:"-"`
}
TagInUseError is the 422 DeleteTag gets back when rules or transactions still reference the tag. Deleting it anyway takes another call with force set.
func (*TagInUseError) Error ¶ added in v0.8.0
func (e *TagInUseError) Error() string
func (*TagInUseError) Unwrap ¶ added in v0.8.0
func (e *TagInUseError) Unwrap() error
type TagsResponse ¶
type TagsResponse struct {
Tags []*Tag `json:"tags"`
}
TagsResponse is the response from getting all tags.
type Timestamp ¶ added in v0.7.0
Timestamp is a time the API may return as a date-time or a plain date. A time.Time alone fails on the date-only form.
func (Timestamp) MarshalJSON ¶ added in v0.7.0
MarshalJSON writes the timestamp back out in ISO 8601 extended format.
func (*Timestamp) UnmarshalJSON ¶ added in v0.7.0
UnmarshalJSON accepts an ISO 8601 date-time, a plain date, or null.
type Transaction ¶
type Transaction struct {
ID int64 `json:"id"`
Date string `json:"date"`
Amount string `json:"amount"`
Currency string `json:"currency"`
ToBase float64 `json:"to_base"`
RecurringID *int64 `json:"recurring_id"`
Payee string `json:"payee"`
OriginalName string `json:"original_name"`
CategoryID *int64 `json:"category_id"`
PlaidAccountID *int64 `json:"plaid_account_id"`
ManualAccountID *int64 `json:"manual_account_id"`
ExternalID string `json:"external_id"`
TagIDs []int64 `json:"tag_ids"`
Notes string `json:"notes"`
// Status is one of StatusReviewed, StatusUnreviewed or StatusDeletePending.
Status string `json:"status"`
IsPending bool `json:"is_pending"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
IsSplitParent bool `json:"is_split_parent"`
SplitParentID *int64 `json:"split_parent_id"`
IsGroupParent bool `json:"is_group_parent"`
GroupParentID *int64 `json:"group_parent_id"`
// Children is populated for split parents and transaction groups when the
// IncludeChildren filter is set.
Children []*Transaction `json:"children,omitempty"`
// PlaidMetadata and CustomMetadata are only present when the
// IncludeMetadata filter is set. Their schemas are variable.
PlaidMetadata map[string]any `json:"plaid_metadata,omitempty"`
CustomMetadata map[string]any `json:"custom_metadata,omitempty"`
// Files is only present when the IncludeFiles filter is set.
Files []TransactionAttachment `json:"files,omitempty"`
// Source is one of api, csv, manual, merge, plaid, recurring, rule, split
// or user.
Source string `json:"source"`
}
Transaction is a single LM transaction. A positive amount is a debit, a negative one a credit. Related records are not hydrated: resolve the IDs with GetCategory, GetManualAccount or GetPlaidAccount.
func (*Transaction) ParsedAmount ¶
func (t *Transaction) ParsedAmount() (*money.Money, error)
ParsedAmount converts the transaction's amount and currency into a money.Money.
type TransactionAttachment ¶ added in v0.7.0
type TransactionAttachment struct {
ID int64 `json:"id"`
UploadedBy int64 `json:"uploaded_by"`
Name string `json:"name"`
Type string `json:"type"`
Size int64 `json:"size"`
Notes string `json:"notes"`
CreatedAt time.Time `json:"created_at"`
}
TransactionAttachment describes a file attached to a transaction.
type TransactionAttachmentURL ¶ added in v0.14.0
type TransactionAttachmentURL struct {
URL string `json:"url"`
ExpiresAt time.Time `json:"expires_at"`
}
TransactionAttachmentURL is a signed link to download an attachment, and the moment that link stops working.
type TransactionFilters ¶
type TransactionFilters struct {
StartDate *string `validate:"omitnil,datetime=2006-01-02"`
EndDate *string `validate:"omitnil,datetime=2006-01-02"`
CreatedSince *string
UpdatedSince *string
TagID *int64
RecurringID *int64
PlaidAccountID *int64
ManualAccountID *int64
CategoryID *int64
IsGroupParent *bool
Status *string `validate:"omitnil,oneof=reviewed unreviewed delete_pending"`
IsPending *bool
IncludePending *bool
IncludeMetadata *bool
IncludeSplitParents *bool
IncludeGroupChildren *bool
IncludeChildren *bool
IncludeFiles *bool
Limit *int64 `validate:"omitnil,min=1,max=2000"`
Offset *int64
}
TransactionFilters are options to pass into the request for transactions. The v1 DebitAsNegative option is gone, and AssetID is now ManualAccountID.
type TransactionsResponse ¶
type TransactionsResponse struct {
Transactions []*Transaction `json:"transactions"`
HasMore bool `json:"has_more"`
}
TransactionsResponse is the response we get from requesting transactions.
type UpdateCategory ¶ added in v0.9.0
type UpdateCategory struct {
Name *string `json:"name,omitempty" validate:"omitnil,min=1,max=100"`
Description *string `json:"description,omitempty" validate:"omitnil,max=200"`
IsIncome *bool `json:"is_income,omitempty"`
ExcludeFromBudget *bool `json:"exclude_from_budget,omitempty"`
ExcludeFromTotals *bool `json:"exclude_from_totals,omitempty"`
Archived *bool `json:"archived,omitempty"`
// ArchivedAt cannot be cleared through this library; unset Archived instead.
ArchivedAt *time.Time `json:"archived_at,omitempty"`
GroupID *int64 `json:"group_id,omitempty"`
// Children replaces the group's members rather than adding to them. Each
// entry is the ID of an existing category, the name of a category to
// create, or a Category. Point at an empty slice to empty the group.
Children *[]any `json:"children,omitempty"`
Order *int64 `json:"order,omitempty"`
Collapsed *bool `json:"collapsed,omitempty"`
}
UpdateCategory holds the updatable fields of a category. Only non-nil fields are sent; IsGroup is absent because a category cannot become a group.
type UpdateCryptoManual ¶ added in v0.16.0
type UpdateCryptoManual struct {
ID *int64 `json:"id,omitempty"`
Name *string `json:"name,omitempty" validate:"omitnil,min=1,max=45"`
DisplayName *string `json:"display_name,omitempty" validate:"omitnil,min=1,max=45"`
InstitutionName *string `json:"institution_name,omitempty" validate:"omitnil,min=1,max=50"`
Balance *string `json:"balance,omitempty"`
Symbol *string `json:"symbol,omitempty"`
CoingeckoID *string `json:"coingecko_id,omitempty"`
ToBase *float64 `json:"to_base,omitempty"`
BalanceAsOf *Timestamp `json:"balance_as_of,omitempty"`
ExchangeRateAsOf *Timestamp `json:"exchange_rate_as_of,omitempty"`
CreatedByName *string `json:"created_by_name,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
UpdateCryptoManual is the request body for updating a manual crypto balance.
type UpdateManualAccount ¶ added in v0.7.0
type UpdateManualAccount struct {
Name *string `json:"name,omitempty" validate:"omitnil,min=1,max=45"`
InstitutionName *string `json:"institution_name,omitempty" validate:"omitnil,min=1,max=50"`
DisplayName *string `json:"display_name,omitempty"`
Type *string `` /* 179-byte string literal not displayed */
Subtype *string `json:"subtype,omitempty" validate:"omitnil,min=1,max=100"`
Balance *string `json:"balance,omitempty"`
Currency *string `json:"currency,omitempty" validate:"omitnil,len=3"`
BalanceAsOf *string `json:"balance_as_of,omitempty"`
Status *string `json:"status,omitempty" validate:"omitnil,oneof=active closed"`
ClosedOn *string `json:"closed_on,omitempty"`
ExternalID *string `json:"external_id,omitempty" validate:"omitnil,max=75"`
CustomMetadata *map[string]any `json:"custom_metadata,omitempty"`
ExcludeFromTransactions *bool `json:"exclude_from_transactions,omitempty"`
}
UpdateManualAccount contains the fields that can be updated for an existing manual account. Only non-nil fields are sent in the update request.
type UpdateTag ¶ added in v0.8.0
type UpdateTag struct {
Name *string `json:"name,omitempty" validate:"omitnil,min=1,max=100"`
Description *string `json:"description,omitempty" validate:"omitnil,max=200"`
TextColor *string `json:"text_color,omitempty"`
BackgroundColor *string `json:"background_color,omitempty"`
Archived *bool `json:"archived,omitempty"`
ArchivedAt *time.Time `json:"archived_at,omitempty"`
}
UpdateTag holds the updatable fields of a tag. Only non-nil fields are sent, so a nil ArchivedAt keeps the stored value rather than clearing it.
type UpdateTransaction ¶ added in v0.4.0
type UpdateTransaction struct {
Date *string `json:"date,omitempty" validate:"omitnil,datetime=2006-01-02"`
Amount *string `json:"amount,omitempty"`
Currency *string `json:"currency,omitempty"`
Payee *string `json:"payee,omitempty"`
CategoryID *int64 `json:"category_id,omitempty"`
Notes *string `json:"notes,omitempty"`
ManualAccountID *int64 `json:"manual_account_id,omitempty"`
PlaidAccountID *int64 `json:"plaid_account_id,omitempty"`
RecurringID *int64 `json:"recurring_id,omitempty"`
Status *string `json:"status,omitempty" validate:"omitnil,oneof=reviewed unreviewed"`
// TagIDs replaces the transaction's tags; AdditionalTagIDs adds to them.
TagIDs *[]int64 `json:"tag_ids,omitempty"`
AdditionalTagIDs *[]int64 `json:"additional_tag_ids,omitempty"`
ExternalID *string `json:"external_id,omitempty" validate:"omitnil,max=75"`
CustomMetadata *map[string]any `json:"custom_metadata,omitempty"`
}
UpdateTransaction holds the updatable fields of a transaction. Only non-nil fields are sent.
type UpsertBalanceHistory ¶ added in v0.16.0
type UpsertBalanceHistory struct {
Balances []*UpsertBalanceHistoryItem `json:"balances" validate:"required,min=1,dive"`
}
UpsertBalanceHistory is the request payload for balance history upserts.
type UpsertBalanceHistoryItem ¶ added in v0.16.0
type UpsertBalanceHistoryItem struct {
ID *int64 `json:"id,omitempty"`
Month string `json:"month" validate:"required"`
Balance string `json:"balance" validate:"required"`
Symbol *string `json:"symbol,omitempty" validate:"omitnil,min=1,max=25"`
CryptoBalance *string `json:"crypto_balance,omitempty"`
Currency *string `json:"currency,omitempty" validate:"omitnil,len=3"`
ToBase *float64 `json:"to_base,omitempty"`
}
UpsertBalanceHistoryItem is one monthly history entry for an upsert.
type UpsertBudget ¶ added in v0.15.0
type UpsertBudget struct {
StartDate string `json:"start_date" validate:"required,datetime=2006-01-02"`
CategoryID int64 `json:"category_id" validate:"required"`
Amount string `json:"amount" validate:"required"`
// Currency defaults to the account's primary currency when empty.
Currency string `json:"currency,omitempty"`
// Notes is a pointer so that an empty string clears the stored notes
// rather than being indistinguishable from leaving them alone.
Notes *string `json:"notes,omitempty" validate:"omitnil,max=350"`
}
UpsertBudget is a budget to set. StartDate has to be a period start for the account, which GetBudgetSettings describes.
type User ¶ added in v0.4.0
type User struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
AccountID int64 `json:"account_id"`
BudgetName string `json:"budget_name"`
PrimaryCurrency string `json:"primary_currency"`
APIKeyLabel string `json:"api_key_label"`
}
User represents the authenticated user's profile information from the Lunch Money API.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
accounts
command
|
|
|
categories
command
|
|
|
manual_accounts
command
|
|
|
recurring
command
|
|
|
summary
command
|
|
|
tags
command
|
|
|
transaction
command
|
|
|
transactions
command
|