Kraken rework + localbitcoins fixes (#170)

* OpenPosition

* AddOrder

* strict json schema

* localbitcoins DashBoard

* specific txid for OpenPositions

* catch exchange (not http) errors

* exchange errors: more informative

* proper API error handling

* strict AddOrder params/options encoding/validating

* TradeVolume and CancelOrder

* QueryLedgers

* GetLedgers

* GetTradesHistory

* QueryTrades

* GetClosedOrders

* GetClosedOrders: strict params

* QueryOrdersInfo

* UserRef is int32 according to doc

* CancelOrder

* GetOpenOrders

* GetTradeBalance

* GetBalance

* GetAssetPairs

* GetAsset

* GetServerTime

* no need for GeneralResponse

* TestGetServerTime fix
This commit is contained in:
soxipy
2018-08-06 14:38:41 +03:00
committed by Adrian Gallagher
parent 391e81b00e
commit efc6c8d31e
5 changed files with 648 additions and 195 deletions

View File

@@ -341,37 +341,57 @@ func (l *LocalBitcoins) GetCurrencies() error {
// view contacts where the token owner is either buying or selling, respectively.
// E.g. /api/dashboard/buyer/. All contacts where the token owner is
// participating are returned.
func (l *LocalBitcoins) GetDashboardInfo() (DashBoardInfo, error) {
resp := DashBoardInfo{}
func (l *LocalBitcoins) GetDashboardInfo() ([]DashBoardInfo, error) {
var resp struct {
Data struct {
ContactList []DashBoardInfo `json:"contact_list"`
ContactCount int `json:"contact_count"`
}
}
return resp,
return resp.Data.ContactList,
l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIDashboard, nil, &resp)
}
// GetDashboardReleasedTrades returns a list of all released trades where the
// token owner is either a buyer or seller.
func (l *LocalBitcoins) GetDashboardReleasedTrades() (DashBoardInfo, error) {
resp := DashBoardInfo{}
func (l *LocalBitcoins) GetDashboardReleasedTrades() ([]DashBoardInfo, error) {
var resp struct {
Data struct {
ContactList []DashBoardInfo `json:"contact_list"`
ContactCount int `json:"contact_count"`
}
}
return resp,
return resp.Data.ContactList,
l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIDashboardReleased, nil, &resp)
}
// GetDashboardCancelledTrades returns a list of all canceled trades where the
// token owner is either a buyer or seller.
func (l *LocalBitcoins) GetDashboardCancelledTrades() (DashBoardInfo, error) {
resp := DashBoardInfo{}
func (l *LocalBitcoins) GetDashboardCancelledTrades() ([]DashBoardInfo, error) {
var resp struct {
Data struct {
ContactList []DashBoardInfo `json:"contact_list"`
ContactCount int `json:"contact_count"`
}
}
return resp,
return resp.Data.ContactList,
l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIDashboardCancelled, nil, &resp)
}
// GetDashboardClosedTrades returns a list of all closed trades where the token
// owner is either a buyer or seller.
func (l *LocalBitcoins) GetDashboardClosedTrades() (DashBoardInfo, error) {
resp := DashBoardInfo{}
func (l *LocalBitcoins) GetDashboardClosedTrades() ([]DashBoardInfo, error) {
var resp struct {
Data struct {
ContactList []DashBoardInfo `json:"contact_list"`
ContactCount int `json:"contact_count"`
}
}
return resp,
return resp.Data.ContactList,
l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIDashboardClosed, nil, &resp)
}

View File

@@ -189,7 +189,7 @@ type DashBoardInfo struct {
Buyer struct {
Username string `json:"username"`
TradeCount string `json:"trade_count"`
FeedbackScore string `json:"feedback_score"`
FeedbackScore int `json:"feedback_score"`
Name string `json:"name"`
LastOnline string `json:"last_online"`
RealName string `json:"real_name"`
@@ -200,7 +200,7 @@ type DashBoardInfo struct {
Seller struct {
Username string `json:"username"`
TradeCount string `json:"trade_count"`
FeedbackScore string `json:"feedback_score"`
FeedbackScore int `json:"feedback_score"`
Name string `json:"name"`
LastOnline string `json:"last_online"`
} `json:"seller"`
@@ -216,7 +216,7 @@ type DashBoardInfo struct {
Advertiser struct {
Username string `json:"username"`
TradeCount string `json:"trade_count"`
FeedbackScore string `json:"feedback_score"`
FeedbackScore int `json:"feedback_score"`
Name string `json:"name"`
LastOnline string `json:"last_online"`
} `json:"advertiser"`