From 5ab62c3075231d9b05ace47a946736b8ea578f7b Mon Sep 17 00:00:00 2001 From: jaketothepast Date: Wed, 27 Nov 2019 08:39:26 -0500 Subject: [PATCH] Finished balance and holdings calls, onto history!!! --- client.go | 16 ++++++++++++++-- types.go | 10 ++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index f2d47b7..e0caad5 100644 --- a/client.go +++ b/client.go @@ -79,8 +79,20 @@ func (c *AllyApi) AccountBalances() (balances []AccountBalance) { return resp.AccountBalances } -func (c *AllyApi) AccountDetail(accountId int) AccountDetailResponse { +func (c *AllyApi) AccountDetail(accountId string) AccountDetailResponse { var resp AccountDetailResponse - _ = xml.Unmarshal(c.getAndRead(fmt.Sprintf("accounts/%d", accountId)), &resp) + _ = xml.Unmarshal(c.getAndRead(fmt.Sprintf("accounts/%s", accountId)), &resp) + return resp +} + +func (c *AllyApi) AccountBalance(accountId string) AccountDetailBalanceResponse { + var resp AccountDetailBalanceResponse + _ = xml.Unmarshal(c.getAndRead(fmt.Sprintf("accounts/%s/balances", accountId)), &resp) + return resp +} + +func (c *AllyApi) AccountHoldings(accountId string) AccountDetailHoldingsResponse { + var resp AccountDetailHoldingsResponse + _ = xml.Unmarshal(c.getAndRead(fmt.Sprintf("accounts/%s/holdings", accountId)), &resp) return resp } diff --git a/types.go b/types.go index 3bc1e64..0185dd5 100644 --- a/types.go +++ b/types.go @@ -128,3 +128,13 @@ type AccountDetailResponse struct { AccountBalance Accountbalance `xml:"accountbalance"` AccountHoldings Accountholdings `xml:"accountholdings"` } + +type AccountDetailBalanceResponse struct { + XMLName xml.Name `xml:"response"` + AccountBalance Accountbalance `xml:"accountbalance"` +} + +type AccountDetailHoldingsResponse struct { + XMLName xml.Name `xml:"response"` + AccountHoldings Accountholdings `xml:"accountholdings"` +}