Skip to content

Commit

Permalink
Made Alphapoint API URL modifiable.
Browse files Browse the repository at this point in the history
  • Loading branch information
thrasher- committed May 31, 2015
1 parent 0316e29 commit f30e0b3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions alphapointhttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f30e0b3

Please sign in to comment.