ynab: go.bmvs.io/ynab/api/budget Index | Examples | Files

package budget

import "go.bmvs.io/ynab/api/budget"

Package budget implements budget entities and services

Index

Examples

Package Files

entity.go service.go

type Budget Uses

type Budget struct {
    ID             string         `json:"id"`
    Name           string         `json:"name"`
    DateFormat     DateFormat     `json:"date_format"`
    CurrencyFormat CurrencyFormat `json:"currency_format"`

    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"`

    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 Uses

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 Uses

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

DateFormat represents date format for a budget settings

type Filter Uses

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 Uses

func (f *Filter) ToQuery() string

ToQuery returns the filters as a HTTP query string

type Service Uses

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

Service wraps YNAB budget API endpoints

func NewService Uses

func NewService(c api.ClientReader) *Service

NewService facilitates the creation of a new budget service instance

func (*Service) GetBudget Uses

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

Code:

c := ynab.NewClient("<valid_ynab_access_token>")
b, _ := c.Budget().GetBudget("<valid_budget_id>", nil)
fmt.Println(reflect.TypeOf(b))

Output:

*budget.Snapshot

Code:

c := ynab.NewClient("<valid_ynab_access_token>")

f := budget.Filter{LastKnowledgeOfServer: 10}
b, _ := c.Budget().GetBudget("<valid_budget_id>", &f)
fmt.Println(reflect.TypeOf(b))

Output:

*budget.Snapshot

func (*Service) GetBudgetSettings Uses

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

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

Code:

c := ynab.NewClient("<valid_ynab_access_token>")
s, _ := c.Budget().GetBudgetSettings("<valid_budget_id>")
fmt.Println(reflect.TypeOf(s))

Output:

*budget.Settings

func (*Service) GetBudgets Uses

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

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

Code:

c := ynab.NewClient("<valid_ynab_access_token>")
budgets, _ := c.Budget().GetBudgets()
fmt.Println(reflect.TypeOf(budgets))

Output:

[]*budget.Summary

func (*Service) GetLastUsedBudget Uses

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

Code:

c := ynab.NewClient("<valid_ynab_access_token>")
b, _ := c.Budget().GetLastUsedBudget(nil)
fmt.Println(reflect.TypeOf(b))

Output:

*budget.Snapshot

type Settings Uses

type Settings struct {
    DateFormat     DateFormat     `json:"date_format"`
    CurrencyFormat CurrencyFormat `json:"currency_format"`
}

Settings represents the settings for a budget

type Snapshot Uses

type Snapshot struct {
    Budget          *Budget
    ServerKnowledge int64
}

Snapshot represents a versioned snapshot for a budget

type Summary Uses

type Summary struct {
    ID             string         `json:"id"`
    Name           string         `json:"name"`
    DateFormat     DateFormat     `json:"date_format"`
    CurrencyFormat CurrencyFormat `json:"currency_format"`

    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

Package budget imports 8 packages (graph) and is imported by 1 packages. Updated 2018-10-07. Refresh now. Tools for package owners.