Documentation

Overview

    Package category implements category entities and services

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type Category

    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

      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

        func (g Goal) Pointer() *Goal

          Pointer returns the pointer of a Goal

          type Group

          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

            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 PayloadMonthCategory

              type PayloadMonthCategory struct {
              	Budgeted int64
              }

                PayloadMonthCategory is the payload contract for updating a category for a month

                type Service

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

                  Service wraps YNAB category API endpoints

                  func NewService

                  func NewService(c api.ClientReaderWriter) *Service

                    NewService facilitates the creation of a new category service instance

                    func (*Service) GetCategories

                    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

                      Example
                      Output:
                      
                      []*category.GroupWithCategories
                      

                      func (*Service) GetCategory

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

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

                        Example
                        Output:
                        
                        *category.Category
                        

                        func (*Service) GetCategoryForCurrentMonth

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

                          GetCategoryForCurrentMonth fetches a specific category from the current budget month https://api.youneedabudget.com/v1#/Categories/getMonthCategoryById

                          Example
                          Output:
                          
                          *category.Category
                          

                          func (*Service) GetCategoryForMonth

                          func (s *Service) GetCategoryForMonth(budgetID, categoryID string,
                          	month api.Date) (*Category, error)

                            GetCategoryForMonth fetches a specific category from a budget month https://api.youneedabudget.com/v1#/Categories/getMonthCategoryById

                            Example
                            Output:
                            
                            *category.Category
                            

                            func (*Service) UpdateCategoryForCurrentMonth

                            func (s *Service) UpdateCategoryForCurrentMonth(budgetID, categoryID string,
                            	p PayloadMonthCategory) (*Category, error)

                              UpdateCategoryForCurrentMonth updates a category for the current month https://api.youneedabudget.com/v1#/Categories/updateMonthCategory

                              Example
                              Output:
                              
                              *category.Category
                              

                              func (*Service) UpdateCategoryForMonth

                              func (s *Service) UpdateCategoryForMonth(budgetID, categoryID string, month api.Date,
                              	p PayloadMonthCategory) (*Category, error)

                                UpdateCategoryForMonth updates a category for a month https://api.youneedabudget.com/v1#/Categories/updateMonthCategory

                                Example
                                Output:
                                
                                *category.Category