market-api-calls #2

Manually merged
jacob.windle merged 10 commits from market-api-calls into master 2020-01-22 00:15:38 +00:00
2 changed files with 31 additions and 17 deletions
Showing only changes of commit b816717362 - Show all commits

View File

@ -79,26 +79,40 @@ func (c *AllyApi) AccountBalances() (balances []AccountBalance) {
return resp.AccountBalances return resp.AccountBalances
} }
func (c *AllyApi) AccountDetail(accountId string) AccountDetailResponse { /**
var resp AccountDetailResponse Return an object representing account detail of a given string
_ = xml.Unmarshal(c.getAndRead(fmt.Sprintf("accounts/%s", accountId)), &resp) */
return resp func (c *AllyApi) AccountDetail(accountId string) (resp AccountDetailResponse) {
c.marshalInterfaceResponse(fmt.Sprintf("accounts/%s", accountId), &resp)
return
} }
func (c *AllyApi) AccountBalance(accountId string) AccountDetailBalanceResponse { /**
var resp AccountDetailBalanceResponse Return an object representing account balances of a given string ID
_ = xml.Unmarshal(c.getAndRead(fmt.Sprintf("accounts/%s/balances", accountId)), &resp) */
return resp func (c *AllyApi) AccountBalance(accountId string) (resp AccountDetailBalanceResponse) {
c.marshalInterfaceResponse(fmt.Sprintf("accounts/%s/balances", accountId), &resp)
return
} }
func (c *AllyApi) AccountHoldings(accountId string) AccountDetailHoldingsResponse { /**
var resp AccountDetailHoldingsResponse Return an object representing the account holdings of a given string.
_ = xml.Unmarshal(c.getAndRead(fmt.Sprintf("accounts/%s/holdings", accountId)), &resp) */
return resp func (c *AllyApi) AccountHoldings(accountId string) (resp AccountDetailHoldingsResponse) {
c.marshalInterfaceResponse(fmt.Sprintf("accounts/%s/holdings", accountId), &resp)
return
} }
func (c *AllyApi) MarketClock() MarketClockResponse { /**
var resp MarketClockResponse Return an object representing the market clock response.
_ = xml.Unmarshal(c.getAndRead("market/clock"), &resp) */
return resp func (c *AllyApi) MarketClock() (resp MarketClockResponse) {
c.marshalInterfaceResponse("market/clock", &resp)
return
}
// Why does this work?? wtf??
func (c *AllyApi) marshalInterfaceResponse(p string, i interface{}) {
resp := c.getAndRead(p)
_ = xml.Unmarshal(resp, &i)
} }

View File

@ -9,5 +9,5 @@ func main() {
var api AllyApi var api AllyApi
api.Initialize() api.Initialize()
fmt.Printf("Market Clock: %d\n", api.MarketClock().UnixTime) fmt.Printf("Market Clock: %d\n", api.MarketClock().CurrentStatus)
} }