From c6eb542a2c9c0ad5d66bb2ddd1f87394ccc06f5a Mon Sep 17 00:00:00 2001 From: jaketothepast Date: Tue, 26 Nov 2019 15:35:50 -0500 Subject: [PATCH] New account balance --- client.go | 13 +++++++++++++ types.go | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/client.go b/client.go index 2d27968..860d15e 100644 --- a/client.go +++ b/client.go @@ -6,6 +6,7 @@ import ( "github.com/joho/godotenv" "github.com/mrjones/oauth" "io/ioutil" + "log" "net/http" "os" ) @@ -68,3 +69,15 @@ func (c *AllyApi) Accounts() []AccountSummary { return resp.Accounts.Accountsummary } + +func (c *AllyApi) AccountBalances() (balances []AccountBalance) { + b, err := c.get("accounts/balances") + if err != nil { + log.Fatal("Could not get account balances") + return + } + defer b.Body.Close() + + var resp AccountBalanceResponse + +} diff --git a/types.go b/types.go index bd60c11..e229eb3 100644 --- a/types.go +++ b/types.go @@ -105,3 +105,16 @@ type AccountResponse struct { Accountsummary []AccountSummary `xml:"accountsummary"` } `xml:"accounts"` } + +type AccountBalance struct { + XMLName xml.Name `xml:"accountbalance"` + Account int `xml:"account"` + AccountName string `xml:"accountname"` + AccountValue float64 `xml:"accountvalue"` +} + +type AccountBalanceResponse struct { + XMLName xml.Name `xml:"response"` + AccountBalances []AccountBalance `xml:"accountbalance"` + TotalBalance float64 `xml:"totalbalance>accountvalue"` +}