category

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2018 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

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

Category represents a category for a budget

type Group

type Group struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Hidden  bool   `json:"hidden"`
	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 Service

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

Service wraps YNAB category API endpoints

func NewService

func NewService(c api.ClientReader) *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
package main

import (
	"fmt"
	"reflect"

	"go.bmvs.io/ynab"
)

func main() {
	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

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
package main

import (
	"fmt"
	"reflect"

	"go.bmvs.io/ynab"
)

func main() {
	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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL