ynab

package
v0.0.0-...-98d6b81 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "api.youneedabudget.com/v1"

BaseURL is the default domain to use

View Source
const Scheme = "https://"

Scheme is what scheme is used to talkt to the api

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID   AccountID
	Name string
}

Account is the model for an Account

type AccountID

type AccountID = uuid.UUID

AccountID identifies the budget from YNAB

type Amount

type Amount = money.Amount

Amount is the common type to contain values

type Budget

type Budget struct {
	ID   BudgetID
	Name string
}

Budget is the model for a budget

type BudgetID

type BudgetID = uuid.UUID

BudgetID identifies the budget from YNAB

type Category

type Category struct {
	ID     CategoryID
	Name   string
	Hidden bool
}

Category is the model for a category

type CategoryGroup

type CategoryGroup struct {
	ID         CategoryID
	Name       string
	Categories []Category
}

CategoryGroup is a collection of Categories

type CategoryID

type CategoryID = uuid.UUID

CategoryID identifies the budget from YNAB

type Client

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

Client communicates with the YNAB api

func (*Client) GetAccounts

func (c *Client) GetAccounts(budgetID BudgetID) ([]Account, error)

GetAccounts return all accounts for the budget

func (*Client) GetBudgets

func (c *Client) GetBudgets() ([]Budget, error)

GetBudgets returns all Budgets for this user

func (*Client) GetCategories

func (c *Client) GetCategories(budgetID BudgetID) ([]CategoryGroup, error)

GetCategories return all categories for the budget

func (*Client) GetPayees

func (c *Client) GetPayees(budgetID BudgetID) ([]Payee, error)

GetPayees returns all Payees for this budget

func (*Client) GetUser

func (c *Client) GetUser() (User, error)

GetUser returns this user

func (*Client) PostTransactions

func (c *Client) PostTransactions(budgetID BudgetID, transactions []Transaction) error

PostTransactions send transactions to YNAB

type Config

type Config struct {
	Token   Token
	Scheme  string
	BaseURL string
	Client  HTTPClient
}

Config is how you want the client to work

func (Config) NewClient

func (c Config) NewClient() *Client

NewClient creates a new client based of the config

type Error

type Error struct {
	ID     string
	Name   string
	Detail string
}

func (Error) Error

func (e Error) Error() string

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the interface that is needed to reach the internet

type Payee

type Payee struct {
	ID   PayeeID
	Name string
}

Payee is the model for a payee

type PayeeID

type PayeeID = uuid.UUID

PayeeID identifies the budget from YNAB

type Token

type Token string

Token is the auth token from YNAB

type Transaction

type Transaction struct {
	Account  Account
	Date     time.Time
	Amount   Amount
	Payee    Payee
	Category Category
	Memo     string
	Cleared  string
	Approved bool
	ID       TransactionID
}

Transaction is a transaction on the YNAB site

func (Transaction) MarshalJSON

func (t Transaction) MarshalJSON() ([]byte, error)

MarshalJSON converts the struct to json

type TransactionID

type TransactionID = uuid.UUID

TransactionID identifies the budget from YNAB

type User

type User struct {
	ID UserID
}

User is the model of a user

type UserID

type UserID = uuid.UUID

UserID is the ID of a user

Jump to

Keyboard shortcuts

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