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

package category

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

Package category implements category entities and services

Index

Examples

Package Files

entity.go enum.go service.go

type Category Uses

type Category struct {
    ID              string `json:"id"`
    CategoryGroupID string `json:"category_group_id"`
    Name            string `json:"name"`
    Hidden          bool   `json:"hidden"`
    // Budgeted Budgeted amount in current month in milliunits format
    Budgeted int64 `json:"budgeted"`
    // Activity Activity amount in current month in milliunits format
    Activity int64 `json:"activity"`
    // Balance Balance in current month in milliunits format
    Balance int64 `json:"balance"`
    // Deleted Deleted category groups will only be included in delta requests
    Deleted bool `json:"deleted"`

    Note *string `json:"note"`
    // OriginalCategoryGroupID If category is hidden this is the ID of the category
    // group it originally belonged to before it was hidden
    OriginalCategoryGroupID *string `json:"original_category_group_id"`

    GoalType *Goal `json:"goal_type"`
    // GoalCreationMonth the month a goal was created
    GoalCreationMonth *api.Date `json:"goal_creation_month"`
    // GoalTarget the goal target amount in milliunits
    GoalTarget *int64 `json:"goal_target"`
    // GoalTargetMonth if the goal type is GoalTargetCategoryBalanceByDate,
    // this is the target month for the goal to be completed
    GoalTargetMonth *api.Date `json:"goal_target_month"`
    // GoalPercentageComplete the percentage completion of the goal
    GoalPercentageComplete *uint16 `json:"goal_percentage_complete"`
}

Category represents a category for a budget

type Goal Uses

type Goal string

Goal represents the goal of a category

const (
    // GoalTargetCategoryBalance Goal targets category balance
    GoalTargetCategoryBalance Goal = "TB"
    // GoalTargetCategoryBalanceByDate Goal targets category balance by date
    GoalTargetCategoryBalanceByDate Goal = "TBD"
    // GoalMonthlyFunding Goal by monthly funding
    GoalMonthlyFunding Goal = "MF"
)

func (Goal) Pointer Uses

func (g Goal) Pointer() *Goal

Pointer returns the pointer of a Goal

type Group Uses

type Group struct {
    ID     string `json:"id"`
    Name   string `json:"name"`
    Hidden bool   `json:"hidden"`
    // Deleted Deleted category groups will only be included in delta requests
    Deleted bool `json:"deleted"`
}

Group represents a resumed category group for a budget

type GroupWithCategories Uses

type GroupWithCategories struct {
    ID     string `json:"id"`
    Name   string `json:"name"`
    Hidden bool   `json:"hidden"`
    // Deleted Deleted category groups will only be included in delta requests
    Deleted bool `json:"deleted"`

    Categories []*Category `json:"categories"`
}

GroupWithCategories represents a category group for a budget

type Service Uses

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

Service wraps YNAB category API endpoints

func NewService Uses

func NewService(c api.ClientReader) *Service

NewService facilitates the creation of a new category service instance

func (*Service) GetCategories Uses

func (s *Service) GetCategories(budgetID string) ([]*GroupWithCategories, error)

GetCategories fetches the list of category groups for a budget https://api.youneedabudget.com/v1#/Categories/getCategories

Code:

c := ynab.NewClient("<valid_ynab_access_token>")
categories, _ := c.Category().GetCategories("<valid_budget_id>")
fmt.Println(reflect.TypeOf(categories))

Output:

[]*category.GroupWithCategories

func (*Service) GetCategory Uses

func (s *Service) GetCategory(budgetID, categoryID string) (*Category, error)

GetCategory fetches a specific category from a budget https://api.youneedabudget.com/v1#/Categories/getCategoryById

Code:

c := ynab.NewClient("<valid_ynab_access_token>")
category, _ := c.Category().GetCategory("<valid_budget_id>", "<valid_category_id>")
fmt.Println(reflect.TypeOf(category))

Output:

*category.Category

Package category imports 2 packages (graph) and is imported by 3 packages. Updated 2018-10-07. Refresh now. Tools for package owners.