本文整理汇总了Golang中restapi.PostJson函数的典型用法代码示例。如果您正苦于以下问题:Golang PostJson函数的具体用法?Golang PostJson怎么用?Golang PostJson使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PostJson函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CancelOrder
// CancelOrder cancels an open order.
func CancelOrder(c appengine.Context, login xgen.Credentials, oid string) (x xgen.OpenOrders, err os.Error) {
defer func() {
if e, ok := recover().(os.Error); ok {
err = e
}
}()
var openOrders OpenOrders
err = restapi.PostJson(c, JsonCancel, map[string][]string{"name": {login.Username}, "pass": {login.Password}, "oid": {oid}}, &openOrders)
check(err)
x = openOrders.convert() // Note: Canceling an order may take up to 1 second. During that time the order is considered active and will be returned as active by GetOrders.
return
}
示例2: GetOpenOrders
// GetOpenOrders retrieves a list of all open orders.
func GetOpenOrders(c appengine.Context, login xgen.Credentials) (x xgen.OpenOrders, err os.Error) {
defer func() {
if e, ok := recover().(os.Error); ok {
err = e
}
}()
var openOrders OpenOrders
err = restapi.PostJson(c, JsonOrders, map[string][]string{"name": {login.Username}, "pass": {login.Password}}, &openOrders)
check(err)
x = openOrders.convert()
return
}
示例3: Sell
// Sell opens a new order to sell BTC.
func Sell(c appengine.Context, login xgen.Credentials, price float64, amount float64) (x xgen.OpenOrders, err os.Error) {
defer func() {
if e, ok := recover().(os.Error); ok {
err = e
}
}()
var openOrders OpenOrders
err = restapi.PostJson(c, JsonSell, map[string][]string{"name": {login.Username}, "pass": {login.Password},
"price": {strconv.Ftoa64(price, 'f', -1)}, "amount": {strconv.Ftoa64(amount, 'f', -1)}}, &openOrders)
check(err)
x = openOrders.convert()
return
}
示例4: GetBalance
// GetBalance retrieves the account balance.
func GetBalance(c appengine.Context, login xgen.Credentials) (x xgen.Balance, err os.Error) {
defer func() {
if e, ok := recover().(os.Error); ok {
err = e
}
}()
var b Balance
err = restapi.PostJson(c, JsonBalance, map[string][]string{"name": {login.Username}, "pass": {login.Password}}, &b)
check(err)
x[xgen.BTC], err = strconv.Atof64(b.BTC)
check(err)
x[xgen.USD], err = strconv.Atof64(b.USD)
return
}
示例5: CancelOrder
// CancelOrder cancels an open order.
func CancelOrder(c appengine.Context, login xgen.Credentials, oid string, orderType int8) (f interface{}, err os.Error) {
err = restapi.PostJson(c, JsonCancel, map[string][]string{"name": {login.Username}, "pass": {login.Password}, "nonce": {strconv.Itoa64(time.Nanoseconds())},
"oid": {oid}, "type": {strconv.Itoa(int(orderType))}}, &f)
return
}
示例6: Sell
// Sell opens a new order to sell BTC.
func Sell(c appengine.Context, login xgen.Credentials, price float64, amount float64) (f interface{}, err os.Error) {
err = restapi.PostJson(c, JsonBuySell, map[string][]string{"user": {login.Username}, "pass": {login.Password}, "TradeMode": {"QuickSell"},
"Price": {strconv.Ftoa64(price, 'f', -1)}, "Quantity": {strconv.Ftoa64(amount, 'f', -1)}}, &f)
return
}
示例7: CancelOrder
// CancelOrder cancels an open order.
func CancelOrder(c appengine.Context, login xgen.Credentials, oid string, orderType string) (f interface{}, err os.Error) {
err = restapi.PostJson(c, JsonCancel, map[string][]string{"user": {login.Username}, "pass": {login.Password}, "Type": {orderType}, "OrderID": {oid}}, &f)
return
}