import "go.bmvs.io/ynab/api/transaction"
Package transaction implements transaction entities and services
entity.go enum.go payload.go service.go
type Bulk struct { // TransactionIDs The list of Transaction IDs that were created TransactionIDs []string `json:"transaction_ids"` // DuplicateImportIDs If any Transactions were not created because they had an // import ID matching a transaction already on the same account, the // specified import IDs will be included in this list DuplicateImportIDs []string `json:"duplicate_import_ids"` }
Bulk represents the output of transactions being created in bulk mode Deprecated: Use BulkTransactions instead.
ClearingStatus represents the clearing status of a transaction
const ( // ClearingStatusUncleared identifies an uncleared transaction ClearingStatusUncleared ClearingStatus = "uncleared" // ClearingStatusCleared identifies a cleared transaction ClearingStatusCleared ClearingStatus = "cleared" // ClearingStatusReconciled identifies a reconciled transaction ClearingStatusReconciled ClearingStatus = "reconciled" )
Filter represents the optional filter while fetching transactions
ToQuery returns the filters as a HTTP query string
FlagColor represents the flag color of a transaction
const ( // FlagColorRed identifies a transaction flagged red FlagColorRed FlagColor = "red" // FlagColorOrange identifies a transaction flagged orange FlagColorOrange FlagColor = "orange" // FlagColorYellow identifies a transaction flagged yellow FlagColorYellow FlagColor = "yellow" // FlagColorGreen identifies a transaction flagged green FlagColorGreen FlagColor = "green" // FlagColorBlue identifies a transaction flagged blue FlagColorBlue FlagColor = "blue" // FlagColorPurple identifies a transaction flagged purple FlagColorPurple FlagColor = "purple" )
type Hybrid struct { ID string `json:"id"` Date api.Date `json:"date"` // Amount Transaction amount in milliunits format Amount int64 `json:"amount"` Cleared ClearingStatus `json:"cleared"` Approved bool `json:"approved"` AccountID string `json:"account_id"` AccountName string `json:"account_name"` // Deleted Deleted transactions will only be included in delta requests Deleted bool `json:"deleted"` Type Type `json:"type"` Memo *string `json:"memo"` FlagColor *FlagColor `json:"flag_color"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` TransferAccountID *string `json:"transfer_account_id"` // ImportID If the Transaction was imported, this field is a unique (by account) import // identifier. If this transaction was imported through File Based Import or // Direct Import and not through the API, the import_id will have the format: // 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction // dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of // 'YNAB:-294230:2015-12-30:1’. If a second transaction on the same account // was imported and had the same date and same amount, its import_id would // be 'YNAB:-294230:2015-12-30:2’. ImportID *string `json:"import_id"` // ParentTransactionID For subtransaction types, this is the id of the parent transaction // For transaction types, this id will be always be null ParentTransactionID *string `json:"parent_transaction_id"` PayeeName *string `json:"payee_name"` CategoryName *string `json:"category_name"` }
Hybrid represents a hybrid transaction
type OperationSummary struct { // TransactionIDs The list of Transaction IDs that were created TransactionIDs []string `json:"transaction_ids"` // DuplicateImportIDs If any Transactions were not created because they had an // import ID matching a transaction already on the same account, the // specified import IDs will be included in this list DuplicateImportIDs []string `json:"duplicate_import_ids"` // Transactions If multiple transactions were specified, the transactions that were saved Transactions []*Transaction `json:"transactions"` // Transactions If a single transaction was specified, the transaction that was saved Transaction *Transaction `json:"transaction"` }
OperationSummary represents the output of transactions being created
type PayloadTransaction struct { ID string `json:"id"` AccountID string `json:"account_id"` Date api.Date `json:"date"` // Amount The transaction amount in milliunits format Amount int64 `json:"amount"` Cleared ClearingStatus `json:"cleared"` Approved bool `json:"approved"` // PayeeID Transfer payees are not permitted and will be ignored if supplied PayeeID *string `json:"payee_id"` // PayeeName If the payee name is provided and payee ID has a null value, the // payee name value will be used to resolve the payee by either (1) a matching // payee rename rule (only if import_id is also specified) or (2) a payee with // the same name or (3) creation of a new payee PayeeName *string `json:"payee_name"` // CategoryID Split and Credit Card Payment categories are not permitted and // will be ignored if supplied. CategoryID *string `json:"category_id"` Memo *string `json:"memo"` FlagColor *FlagColor `json:"flag_color"` // ImportID If the Transaction was imported, this field is a unique (by account) import // identifier. If this transaction was imported through File Based Import or // Direct Import and not through the API, the import_id will have the format: // 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction // dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of // 'YNAB:-294230:2015-12-30:1’. If a second transaction on the same account // was imported and had the same date and same amount, its import_id would // be 'YNAB:-294230:2015-12-30:2’. ImportID *string `json:"import_id"` }
PayloadTransaction is the payload contract for saving a transaction, new or existent
type Scheduled struct { ID string `json:"id"` DateFirst api.Date `json:"date_first"` DateNext api.Date `json:"date_next"` Frequency ScheduledFrequency `json:"frequency"` // Amount The scheduled transaction amount in milliunits format Amount int64 `json:"amount"` AccountID string `json:"account_id"` // Deleted Deleted scheduled transactions will only be included in delta requests. Deleted bool `json:"deleted"` AccountName string `json:"account_name"` SubTransactions []*ScheduledSubTransaction `json:"subtransactions"` Memo *string `json:"memo"` FlagColor *FlagColor `json:"flag_color"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` // TransferAccountID If a transfer, the account_id which the scheduled // transaction transfers to TransferAccountID *string `json:"transfer_account_id"` PayeeName *string `json:"payee_name"` CategoryName *string `json:"category_name"` }
Scheduled represents a scheduled transaction for a budget
ScheduledFrequency represents the frequency of a scheduled transaction or sub-transaction
const ( // FrequencyNever identifies a transaction that will never repeat FrequencyNever ScheduledFrequency = "never" // FrequencyDaily identifies a transaction that will repeat daily FrequencyDaily ScheduledFrequency = "daily" // FrequencyWeekly identifies a transaction that will repeat weekly FrequencyWeekly ScheduledFrequency = "weekly" // FrequencyEveryOtherWeek identifies a transaction that will repeat // every other week FrequencyEveryOtherWeek ScheduledFrequency = "everyOtherWeek" // FrequencyTwiceAMonth identifies a transaction that will repeat // twice a month FrequencyTwiceAMonth ScheduledFrequency = "twiceAMonth" // FrequencyEveryFourWeeks identifies a transaction that will repeat // every four weeks FrequencyEveryFourWeeks ScheduledFrequency = "every4Weeks" // FrequencyMonthly identifies a transaction that will repeat monthly FrequencyMonthly ScheduledFrequency = "monthly" // FrequencyEveryOtherMonth identifies a transaction that will repeat // every other month FrequencyEveryOtherMonth ScheduledFrequency = "everyOtherMonth" // FrequencyEveryThreeMonths identifies a transaction that will repeat // every three months FrequencyEveryThreeMonths ScheduledFrequency = "every3Months" // FrequencyEveryFourMonths identifies a transaction that will repeat // every four months FrequencyEveryFourMonths ScheduledFrequency = "every4Months" // FrequencyTwiceAYear identifies a transaction that will repeat // twice a year FrequencyTwiceAYear ScheduledFrequency = "twiceAYear" // FrequencyYearly identifies a transaction that will repeat yearly FrequencyYearly ScheduledFrequency = "yearly" // FrequencyEveryOtherYear identifies a transaction that will repeat // every other year FrequencyEveryOtherYear ScheduledFrequency = "everyOtherYear" )
type ScheduledSubTransaction struct { ID string `json:"id"` ScheduledTransactionID string `json:"scheduled_transaction_id"` // Amount The scheduled sub-transaction amount in milliunits format Amount int64 `json:"amount"` // Deleted Deleted scheduled sub-transactions will only be included in delta requests Deleted bool `json:"deleted"` Memo *string `json:"memo"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` // TransferAccountID If a transfer, the account_id which the scheduled // subtransaction transfers to TransferAccountID *string `json:"transfer_account_id"` }
ScheduledSubTransaction represents a scheduled sub-transaction for a scheduled transaction
type ScheduledSummary struct { ID string `json:"id"` DateFirst api.Date `json:"date_first"` DateNext api.Date `json:"date_next"` Frequency ScheduledFrequency `json:"frequency"` // Amount The scheduled transaction amount in milliunits format Amount int64 `json:"amount"` AccountID string `json:"account_id"` // Deleted Deleted scheduled transactions will only be included in delta requests. Deleted bool `json:"deleted"` Memo *string `json:"memo"` FlagColor *FlagColor `json:"flag_color"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` // TransferAccountID If a transfer, the account_id which the scheduled // transaction transfers to TransferAccountID *string `json:"transfer_account_id"` }
ScheduledSummary represents the summary of a scheduled transaction for a budget
type Service struct {
// contains filtered or unexported fields
}
Service wraps YNAB transaction API endpoints
func NewService(c api.ClientReaderWriter) *Service
NewService facilitates the creation of a new transaction service instance
BulkCreateTransactions creates multiple transactions for a budget https://api.youneedabudget.com/v1#/Transactions/bulkCreateTransactions Deprecated: Use transaction.CreateTransactions instead.
Code:
c := ynab.NewClient("<valid_ynab_access_token>") p := []transaction.PayloadTransaction{ { AccountID: "<valid_account_id>", // ... }, { AccountID: "<another_valid_account_id>", // ... }, } bulk, _ := c.Transaction().BulkCreateTransactions("<valid_budget_id>", p) fmt.Println(reflect.TypeOf(bulk))
Output:
*transaction.Bulk
func (s *Service) CreateTransaction(budgetID string, p PayloadTransaction) (*OperationSummary, error)
CreateTransaction creates a new transaction for a budget https://api.youneedabudget.com/v1#/Transactions/createTransaction
Code:
c := ynab.NewClient("<valid_ynab_access_token>")
p := transaction.PayloadTransaction{
AccountID: "<valid_account_id>",
// ...
}
tx, _ := c.Transaction().CreateTransaction("<valid_budget_id>", p)
fmt.Println(reflect.TypeOf(tx))
Output:
*transaction.OperationSummary
func (s *Service) CreateTransactions(budgetID string, p []PayloadTransaction) (*OperationSummary, error)
CreateTransactions creates one or more new transactions for a budget https://api.youneedabudget.com/v1#/Transactions/createTransaction
Code:
c := ynab.NewClient("<valid_ynab_access_token>")
p := []transaction.PayloadTransaction{
{
AccountID: "<valid_account_id>",
// ...
},
}
tx, _ := c.Transaction().CreateTransactions("<valid_budget_id>", p)
fmt.Println(reflect.TypeOf(tx))
Output:
*transaction.OperationSummary
func (s *Service) GetScheduledTransaction(budgetID, scheduledTransactionID string) (*Scheduled, error)
GetScheduledTransaction fetches a specific scheduled transaction from a budget https://api.youneedabudget.com/v1#/Scheduled_Transactions/getScheduledTransactionById
Code:
c := ynab.NewClient("<valid_ynab_access_token>") tx, _ := c.Transaction().GetScheduledTransaction("<valid_budget_id>", "<valid_scheduled_transaction_id>") fmt.Println(reflect.TypeOf(tx))
Output:
*transaction.Scheduled
GetScheduledTransactions fetches the list of scheduled transactions from a budget https://api.youneedabudget.com/v1#/Scheduled_Transactions/getScheduledTransactions
Code:
c := ynab.NewClient("<valid_ynab_access_token>") transactions, _ := c.Transaction().GetScheduledTransactions("<valid_budget_id>") fmt.Println(reflect.TypeOf(transactions))
Output:
[]*transaction.Scheduled
func (s *Service) GetTransaction(budgetID, transactionID string) (*Transaction, error)
GetTransaction fetches a specific transaction from a budget https://api.youneedabudget.com/v1#/Transactions/getTransactionsById
Code:
c := ynab.NewClient("<valid_ynab_access_token>") tx, _ := c.Transaction().GetTransaction("<valid_budget_id>", "<valid_transaction_id>") fmt.Println(reflect.TypeOf(tx))
Output:
*transaction.Transaction
GetTransactions fetches the list of transactions from a budget with filtering capabilities https://api.youneedabudget.com/v1#/Transactions/getTransactions
Code:
c := ynab.NewClient("<valid_ynab_access_token>") transactions, _ := c.Transaction().GetTransactions("<valid_budget_id>", nil) fmt.Println(reflect.TypeOf(transactions))
Output:
[]*transaction.Transaction
Code:
c := ynab.NewClient("<valid_ynab_access_token>") date, _ := api.DateFromString("2010-09-09") f := &transaction.Filter{ Since: &date, Type: transaction.StatusUnapproved.Pointer(), } transactions, _ := c.Transaction().GetTransactions("<valid_budget_id>", f) fmt.Println(reflect.TypeOf(transactions))
Output:
[]*transaction.Transaction
func (s *Service) GetTransactionsByAccount(budgetID, accountID string, f *Filter) ([]*Transaction, error)
GetTransactionsByAccount fetches the list of transactions of a specific account from a budget with filtering capabilities https://api.youneedabudget.com/v1#/Transactions/getTransactionsByAccount
Code:
c := ynab.NewClient("<valid_ynab_access_token>") transactions, _ := c.Transaction().GetTransactionsByAccount( "<valid_budget_id>", "<valid_account_id>", nil) fmt.Println(reflect.TypeOf(transactions))
Output:
[]*transaction.Transaction
Code:
c := ynab.NewClient("<valid_ynab_access_token>") date, _ := api.DateFromString("2010-09-09") f := &transaction.Filter{ Since: &date, Type: transaction.StatusUnapproved.Pointer(), } transactions, _ := c.Transaction().GetTransactionsByAccount( "<valid_budget_id>", "<valid_account_id>", f) fmt.Println(reflect.TypeOf(transactions))
Output:
[]*transaction.Transaction
func (s *Service) GetTransactionsByCategory(budgetID, categoryID string, f *Filter) ([]*Hybrid, error)
GetTransactionsByCategory fetches the list of transactions of a specific category from a budget with filtering capabilities https://api.youneedabudget.com/v1#/Transactions/getTransactionsByCategory
Code:
c := ynab.NewClient("<valid_ynab_access_token>") transactions, _ := c.Transaction().GetTransactionsByCategory( "<valid_budget_id>", "<valid_category_id>", nil) fmt.Println(reflect.TypeOf(transactions))
Output:
[]*transaction.Hybrid
Code:
c := ynab.NewClient("<valid_ynab_access_token>") date, _ := api.DateFromString("2010-09-09") f := &transaction.Filter{ Since: &date, Type: transaction.StatusUnapproved.Pointer(), } transactions, _ := c.Transaction().GetTransactionsByCategory( "<valid_budget_id>", "<valid_category_id>", f) fmt.Println(reflect.TypeOf(transactions))
Output:
[]*transaction.Hybrid
GetTransactionsByPayee fetches the list of transactions of a specific payee from a budget with filtering capabilities https://api.youneedabudget.com/v1#/Transactions/getTransactionsByPayee
Code:
c := ynab.NewClient("<valid_ynab_access_token>") transactions, _ := c.Transaction().GetTransactionsByPayee( "<valid_budget_id>", "<valid_payee_id>", nil) fmt.Println(reflect.TypeOf(transactions))
Output:
[]*transaction.Hybrid
Code:
c := ynab.NewClient("<valid_ynab_access_token>") date, _ := api.DateFromString("2010-09-09") f := &transaction.Filter{ Since: &date, Type: transaction.StatusUnapproved.Pointer(), } transactions, _ := c.Transaction().GetTransactionsByPayee( "<valid_budget_id>", "<valid_payee_id>", f) fmt.Println(reflect.TypeOf(transactions))
Output:
[]*transaction.Hybrid
func (s *Service) UpdateTransaction(budgetID, transactionID string, p PayloadTransaction) (*Transaction, error)
UpdateTransaction updates a whole transaction for a replacement https://api.youneedabudget.com/v1#/Transactions/updateTransaction
Code:
c := ynab.NewClient("<valid_ynab_access_token>")
p := transaction.PayloadTransaction{
AccountID: "<valid_account_id>",
// ...
}
tx, _ := c.Transaction().UpdateTransaction("<valid_budget_id>",
"<valid_transaction_id>", p)
fmt.Println(reflect.TypeOf(tx))
Output:
*transaction.Transaction
func (s *Service) UpdateTransactions(budgetID string, p []PayloadTransaction) (*OperationSummary, error)
UpdateTransactions creates one or more new transactions for a budget https://api.youneedabudget.com/v1#/Transactions/updateTransactions
Status represents the type of a transaction
const ( // StatusUncategorized identifies an uncategorized transaction StatusUncategorized Status = "uncategorized" // StatusUnapproved identifies an unapproved transaction StatusUnapproved Status = "unapproved" )
Pointer returns the pointer of a Status
type SubTransaction struct { ID string `json:"id"` TransactionID string `json:"transaction_id"` // Amount sub-transaction amount in milliunits format Amount int64 `json:"amount"` // Deleted Deleted sub-transactions will only be included in delta requests. Deleted bool `json:"deleted"` Memo *string `json:"memo"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` // TransferAccountID If a transfer, the account_id which the // sub-transaction transfers to TransferAccountID *string `json:"transfer_account_id"` }
SubTransaction represents a sub-transaction for a transaction
type Summary struct { ID string `json:"id"` Date api.Date `json:"date"` // Amount Transaction amount in milliunits format Amount int64 `json:"amount"` Cleared ClearingStatus `json:"cleared"` Approved bool `json:"approved"` AccountID string `json:"account_id"` // Deleted Deleted transactions will only be included in delta requests Deleted bool `json:"deleted"` Memo *string `json:"memo"` FlagColor *FlagColor `json:"flag_color"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` TransferAccountID *string `json:"transfer_account_id"` // ImportID If the Transaction was imported, this field is a unique (by account) import // identifier. If this transaction was imported through File Based Import or // Direct Import and not through the API, the import_id will have the format: // 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction // dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of // 'YNAB:-294230:2015-12-30:1’. If a second transaction on the same account // was imported and had the same date and same amount, its import_id would // be 'YNAB:-294230:2015-12-30:2’. ImportID *string `json:"import_id"` }
Summary represents the summary of a transaction for a budget
type Transaction struct { ID string `json:"id"` Date api.Date `json:"date"` // Amount Transaction amount in milliunits format Amount int64 `json:"amount"` Cleared ClearingStatus `json:"cleared"` Approved bool `json:"approved"` AccountID string `json:"account_id"` // Deleted Deleted transactions will only be included in delta requests Deleted bool `json:"deleted"` AccountName string `json:"account_name"` SubTransactions []*SubTransaction `json:"subtransactions"` Memo *string `json:"memo"` FlagColor *FlagColor `json:"flag_color"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` TransferAccountID *string `json:"transfer_account_id"` // ImportID If the Transaction was imported, this field is a unique (by account) import // identifier. If this transaction was imported through File Based Import or // Direct Import and not through the API, the import_id will have the format: // 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction // dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of // 'YNAB:-294230:2015-12-30:1’. If a second transaction on the same account // was imported and had the same date and same amount, its import_id would // be 'YNAB:-294230:2015-12-30:2’. ImportID *string `json:"import_id"` PayeeName *string `json:"payee_name"` CategoryName *string `json:"category_name"` }
Transaction represents a full transaction for a budget
Type represents the type of a hybrid transaction
const ( // TypeTransaction identifies a hybrid transaction as transaction TypeTransaction Type = "transaction" // TypeSubTransaction identifies a hybrid transaction as sub-transaction TypeSubTransaction Type = "subtransaction" )
Package transaction imports 4 packages (graph) and is imported by 2 packages. Updated 2019-12-25. Refresh now. Tools for package owners.