Wizardry with unmarshal and xml
This commit is contained in:
parent
d2861c2df2
commit
b816717362
46
client.go
46
client.go
@ -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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user