account

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2018 License: BSD-2-Clause Imports: 2 Imported by: 5

Documentation

Overview

Package account implements account entities and services

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Type     Type   `json:"type"`
	OnBudget bool   `json:"on_budget"`
	// Balance The current balance of the account in milliunits format
	Balance int64 `json:"balance"`
	// ClearedBalance The current cleared balance of the account in milliunits format
	ClearedBalance int64 `json:"cleared_balance"`
	// ClearedBalance The current uncleared balance of the account in milliunits format
	UnclearedBalance int64 `json:"uncleared_balance"`
	Closed           bool  `json:"closed"`
	// Deleted Deleted accounts will only be included in delta requests
	Deleted bool `json:"deleted"`

	Note *string `json:"note"`
}

Account represents an account for a budget

type Service

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

Service wraps YNAB account API endpoints

func NewService

func NewService(c api.ClientReader) *Service

NewService facilitates the creation of a new account service instance

func (*Service) GetAccount

func (s *Service) GetAccount(budgetID, accountID string) (*Account, error)

GetAccount fetches a specific account from a budget https://api.youneedabudget.com/v1#/Accounts/getAccountById

Example
package main

import (
	"fmt"
	"reflect"

	"go.bmvs.io/ynab"
)

func main() {
	c := ynab.NewClient("<valid_ynab_access_token>")
	account, _ := c.Account().GetAccount("<valid_budget_id>", "<valid_account_id>")
	fmt.Println(reflect.TypeOf(account))

}
Output:

*account.Account

func (*Service) GetAccounts

func (s *Service) GetAccounts(budgetID string) ([]*Account, error)

GetAccounts fetches the list of accounts from a budget https://api.youneedabudget.com/v1#/Accounts/getAccounts

Example
package main

import (
	"fmt"
	"reflect"

	"go.bmvs.io/ynab"
)

func main() {
	c := ynab.NewClient("<valid_ynab_access_token>")
	accounts, _ := c.Account().GetAccounts("<valid_budget_id>")
	fmt.Println(reflect.TypeOf(accounts))

}
Output:

[]*account.Account

type Type

type Type string

Type identifies an account type

const (
	// TypeChecking identifies a checking account
	TypeChecking Type = "checking"
	// TypeSavings identifies a savings account
	TypeSavings Type = "savings"
	// TypeCash identifies a cash account
	TypeCash Type = "cash"
	// TypeCreditCard identifies a credit card account
	TypeCreditCard Type = "creditCard"
	// TypeLineOfCredit identifies a line of credit account
	TypeLineOfCredit Type = "lineOfCredit"
	// TypeOtherAsset identifies an other asset account
	TypeOtherAsset Type = "otherAsset"
	// TypeOtherLiability identifies an other liability account
	TypeOtherLiability Type = "otherLiability"
	// TypePayPal DEPRECATED identifies a PayPal account
	TypePayPal Type = "payPal"
	// TypeMerchant DEPRECATED identifies a merchant account
	TypeMerchant Type = "merchantAccount"
	// TypeInvestment DEPRECATED identifies an investment account
	TypeInvestment Type = "investmentAccount"
	// TypeMortgage DEPRECATED identifies a mortgage account
	TypeMortgage Type = "mortgage"
)

Jump to

Keyboard shortcuts

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