Documentation

Overview

    Package budget implements budget entities and services

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type Budget

    type Budget struct {
    	ID   string `json:"id"`
    	Name string `json:"name"`
    
    	Accounts                 []*account.Account                     `json:"accounts"`
    	Payees                   []*payee.Payee                         `json:"payees"`
    	PayeeLocations           []*payee.Location                      `json:"payee_locations"`
    	Categories               []*category.Category                   `json:"categories"`
    	CategoryGroups           []*category.Group                      `json:"category_groups"`
    	Months                   []*month.Month                         `json:"months"`
    	Transactions             []*transaction.Summary                 `json:"transactions"`
    	SubTransactions          []*transaction.SubTransaction          `json:"subtransactions"`
    	ScheduledTransactions    []*transaction.ScheduledSummary        `json:"scheduled_transactions"`
    	ScheduledSubTransactions []*transaction.ScheduledSubTransaction `json:"scheduled_sub_transactions"`
    
    	// DateFormat the date format setting for the budget. In some cases
    	// the format will not be available and will be specified as null.
    	DateFormat *DateFormat `json:"date_format"`
    	// CurrencyFormat the currency format setting for the budget. In
    	// some cases the format will not be available and will be specified
    	// as null.
    	CurrencyFormat *CurrencyFormat `json:"currency_format"`
    	// LastModifiedOn the last time any changes were made to the budget
    	// from either a web or mobile client.
    	LastModifiedOn *time.Time `json:"last_modified_on"`
    	// FirstMonth undocumented field
    	FirstMonth *api.Date `json:"first_month"`
    	// LastMonth undocumented field
    	LastMonth *api.Date `json:"last_month"`
    }

      Budget represents a budget

      type CurrencyFormat

      type CurrencyFormat struct {
      	ISOCode          string `json:"iso_code"`
      	ExampleFormat    string `json:"example_format"`
      	DecimalDigits    uint64 `json:"decimal_digits"`
      	DecimalSeparator string `json:"decimal_separator"`
      	GroupSeparator   string `json:"group_separator"`
      	SymbolFirst      bool   `json:"symbol_first"`
      	CurrencySymbol   string `json:"currency_symbol"`
      	DisplaySymbol    bool   `json:"display_symbol"`
      }

        CurrencyFormat represents a currency format for a budget settings

        type DateFormat

        type DateFormat struct {
        	Format string `json:"format"`
        }

          DateFormat represents date format for a budget

          type Filter

          type Filter struct {
          	// LastKnowledgeOfServer The starting server knowledge. If provided,
          	// only entities that have changed since last_knowledge_of_server
          	// will be included
          	LastKnowledgeOfServer uint64
          }

            Filter represents the optional version filter while fetching a budget

            func (*Filter) ToQuery

            func (f *Filter) ToQuery() string

              ToQuery returns the filters as a HTTP query string

              type Service

              type Service struct {
              	// contains filtered or unexported fields
              }

                Service wraps YNAB budget API endpoints

                func NewService

                func NewService(c api.ClientReader) *Service

                  NewService facilitates the creation of a new budget service instance

                  func (*Service) GetBudget

                  func (s *Service) GetBudget(budgetID string, f *Filter) (*Snapshot, error)

                    GetBudget fetches a single budget with all related entities, effectively a full budget export with filtering capabilities https://api.youneedabudget.com/v1#/Budgets/getBudgetById

                    Example
                    Output:
                    
                    *budget.Snapshot
                    
                    Example (Filtered)
                    Output:
                    
                    *budget.Snapshot
                    

                    func (*Service) GetBudgetSettings

                    func (s *Service) GetBudgetSettings(budgetID string) (*Settings, error)

                      GetBudgetSettings fetches a budget settings https://api.youneedabudget.com/v1#/Budgets/getBudgetSettingsById

                      Example
                      Output:
                      
                      *budget.Settings
                      

                      func (*Service) GetBudgets

                      func (s *Service) GetBudgets() ([]*Summary, error)

                        GetBudgets fetches the list of budgets of the logger in user https://api.youneedabudget.com/v1#/Budgets/getBudgets

                        Example
                        Output:
                        
                        []*budget.Summary
                        

                        func (*Service) GetLastUsedBudget

                        func (s *Service) GetLastUsedBudget(f *Filter) (*Snapshot, error)

                          GetLastUsedBudget fetches the last used budget with all related entities, effectively a full budget export with filtering capabilities https://api.youneedabudget.com/v1#/Budgets/getBudgetById

                          Example
                          Output:
                          
                          *budget.Snapshot
                          

                          type Settings

                          type Settings struct {
                          	// DateFormat the date format setting for the budget. In some cases
                          	// the format will not be available and will be specified as null.
                          	DateFormat *DateFormat `json:"date_format"`
                          	// CurrencyFormat the currency format setting for the budget. In
                          	// some cases the format will not be available and will be specified
                          	// as null.
                          	CurrencyFormat *CurrencyFormat `json:"currency_format"`
                          }

                            Settings represents the settings for a budget

                            type Snapshot

                            type Snapshot struct {
                            	Budget          *Budget
                            	ServerKnowledge int64
                            }

                              Snapshot represents a versioned snapshot for a budget

                              type Summary

                              type Summary struct {
                              	ID   string `json:"id"`
                              	Name string `json:"name"`
                              
                              	// DateFormat the date format setting for the budget. In some cases
                              	// the format will not be available and will be specified as null.
                              	DateFormat *DateFormat `json:"date_format"`
                              	// CurrencyFormat the currency format setting for the budget. In
                              	// some cases the format will not be available and will be specified
                              	// as null.
                              	CurrencyFormat *CurrencyFormat `json:"currency_format"`
                              	// LastModifiedOn the last time any changes were made to the budget
                              	// from either a web or mobile client.
                              	LastModifiedOn *time.Time `json:"last_modified_on"`
                              	// FirstMonth undocumented field
                              	FirstMonth *api.Date `json:"first_month"`
                              	// LastMonth undocumented field
                              	LastMonth *api.Date `json:"last_month"`
                              }

                                Summary represents the summary of a budget