From f30e0b3b3b4fbf8ebd4bfdae7bb284c45d4356c8 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Sun, 24 May 2015 15:49:50 +1000 Subject: [PATCH] Made Alphapoint API URL modifiable. --- alphapointhttp.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/alphapointhttp.go b/alphapointhttp.go index f20ac6fd..6d1634aa 100644 --- a/alphapointhttp.go +++ b/alphapointhttp.go @@ -10,7 +10,7 @@ import ( ) const ( - ALPHAPOINT_API_URL = "https://sim3.alphapoint.com:8400" + ALPHAPOINT_DEFAULT_API_URL = "https://sim3.alphapoint.com:8400" ALPHAPOINT_API_VERSION = "1" ALPHAPOINT_TICKER = "GetTicker" ALPHAPOINT_TRADES = "GetTrades" @@ -155,6 +155,10 @@ type AlphapointOrderInfo struct { Orders []AlphapointOrder `json:"openOrders"` } +func (a *Alphapoint) SetDefaults() { + a.APIUrl = ALPHAPOINT_DEFAULT_API_URL +} + func (a *Alphapoint) GetTicker(symbol string) (AlphapointTicker, error) { request := make(map[string]interface{}) request["productPair"] = symbol @@ -495,7 +499,7 @@ func (a *Alphapoint) GetOrderFee(symbol, side string, quantity, price float64) ( func (a *Alphapoint) SendRequest(method, path string, data map[string]interface{}, result interface{}) error { headers := make(map[string]string) headers["Content-Type"] = "application/json" - path = fmt.Sprintf("%s/ajax/v%s/%s", ALPHAPOINT_API_URL, ALPHAPOINT_API_VERSION, path) + path = fmt.Sprintf("%s/ajax/v%s/%s", a.APIUrl, ALPHAPOINT_API_VERSION, path) PayloadJson, err := JSONEncode(data) if err != nil { @@ -524,7 +528,7 @@ func (a *Alphapoint) SendAuthenticatedHTTPRequest(method, path string, data map[ data["apiNonce"] = nonce hmac := GetHMAC(HASH_SHA256, []byte(nonce+a.UserID+a.APIKey), []byte(a.APISecret)) data["apiSig"] = StringToUpper(HexEncodeToString(hmac)) - path = fmt.Sprintf("%s/ajax/v%s/%s", ALPHAPOINT_API_URL, ALPHAPOINT_API_VERSION, path) + path = fmt.Sprintf("%s/ajax/v%s/%s", a.APIUrl, ALPHAPOINT_API_VERSION, path) PayloadJson, err := JSONEncode(data) if err != nil {