Remove unwanted wrapper name stuttering and standardise common error returns (#213)

This commit is contained in:
Ryan O'Hara-Reid
2018-11-23 12:55:00 +11:00
committed by Adrian Gallagher
parent c41f611d96
commit 92534249bf
154 changed files with 1362 additions and 1367 deletions

View File

@@ -71,7 +71,7 @@ if err != nil {
// set and AuthenticatedAPISupport is set to true
// Fetches current account information
accountInfo, err := y.GetExchangeAccountInfo()
accountInfo, err := y.GetAccountInfo()
if err != nil {
// Handle error
}

View File

@@ -159,8 +159,8 @@ func (y *Yobit) GetTrades(symbol string) ([]Trades, error) {
return response.Data[symbol], y.SendHTTPRequest(path, &response.Data)
}
// GetAccountInfo returns a users account info
func (y *Yobit) GetAccountInfo() (AccountInfo, error) {
// GetAccountInformation returns a users account info
func (y *Yobit) GetAccountInformation() (AccountInfo, error) {
result := AccountInfo{}
err := y.SendAuthenticatedHTTPRequest(privateAccountInfo, url.Values{}, &result)
@@ -203,8 +203,8 @@ func (y *Yobit) GetActiveOrders(pair string) (map[string]ActiveOrders, error) {
return result, y.SendAuthenticatedHTTPRequest(privateActiveOrders, req, &result)
}
// GetOrderInfo returns the order info for a specific order ID
func (y *Yobit) GetOrderInfo(OrderID int64) (map[string]OrderInfo, error) {
// GetOrderInformation returns the order info for a specific order ID
func (y *Yobit) GetOrderInformation(OrderID int64) (map[string]OrderInfo, error) {
req := url.Values{}
req.Add("order_id", strconv.FormatInt(OrderID, 10))
@@ -213,8 +213,8 @@ func (y *Yobit) GetOrderInfo(OrderID int64) (map[string]OrderInfo, error) {
return result, y.SendAuthenticatedHTTPRequest(privateOrderInfo, req, &result)
}
// CancelOrder cancels an order for a specific order ID
func (y *Yobit) CancelOrder(OrderID int64) (bool, error) {
// CancelExistingOrder cancels an order for a specific order ID
func (y *Yobit) CancelExistingOrder(OrderID int64) (bool, error) {
req := url.Values{}
req.Add("order_id", strconv.FormatInt(OrderID, 10))
@@ -247,8 +247,8 @@ func (y *Yobit) GetTradeHistory(TIDFrom, Count, TIDEnd int64, order, since, end,
return result, y.SendAuthenticatedHTTPRequest(privateTradeHistory, req, &result)
}
// GetDepositAddress returns the deposit address for a specific currency
func (y *Yobit) GetDepositAddress(coin string) (DepositAddress, error) {
// GetCryptoDepositAddress returns the deposit address for a specific currency
func (y *Yobit) GetCryptoDepositAddress(coin string) (DepositAddress, error) {
req := url.Values{}
req.Add("coinName", coin)

View File

@@ -95,7 +95,7 @@ func TestGetOrderInfo(t *testing.T) {
func TestCancelOrder(t *testing.T) {
t.Parallel()
_, err := y.CancelOrder(1337)
_, err := y.CancelExistingOrder(1337)
if err == nil {
t.Error("Test Failed - CancelOrder() error", err)
}
@@ -330,7 +330,7 @@ func TestSubmitOrder(t *testing.T) {
FirstCurrency: symbol.BTC,
SecondCurrency: symbol.USD,
}
response, err := y.SubmitExchangeOrder(pair, exchange.Buy, exchange.Market, 1, 10, "hi")
response, err := y.SubmitOrder(pair, exchange.Buy, exchange.Market, 1, 10, "hi")
if err != nil || !response.IsOrderPlaced {
t.Errorf("Order failed to be placed: %v", err)
}

View File

@@ -1,7 +1,6 @@
package yobit
import (
"errors"
"fmt"
"log"
"sync"
@@ -99,12 +98,12 @@ func (y *Yobit) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderboo
return orderbook.GetOrderbook(y.Name, p, assetType)
}
// GetExchangeAccountInfo retrieves balances for all enabled currencies for the
// GetAccountInfo retrieves balances for all enabled currencies for the
// Yobit exchange
func (y *Yobit) GetExchangeAccountInfo() (exchange.AccountInfo, error) {
func (y *Yobit) GetAccountInfo() (exchange.AccountInfo, error) {
var response exchange.AccountInfo
response.ExchangeName = y.GetName()
accountBalance, err := y.GetAccountInfo()
accountBalance, err := y.GetAccountInformation()
if err != nil {
return response, err
}
@@ -126,22 +125,22 @@ func (y *Yobit) GetExchangeAccountInfo() (exchange.AccountInfo, error) {
return response, nil
}
// GetExchangeFundTransferHistory returns funding history, deposits and
// GetFundingHistory returns funding history, deposits and
// withdrawals
func (y *Yobit) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) {
func (y *Yobit) GetFundingHistory() ([]exchange.FundHistory, error) {
var fundHistory []exchange.FundHistory
return fundHistory, errors.New("not supported on exchange")
return fundHistory, common.ErrFunctionNotSupported
}
// GetExchangeHistory returns historic trade data since exchange opening.
func (y *Yobit) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) {
var resp []exchange.TradeHistory
return resp, errors.New("trade history not yet implemented")
return resp, common.ErrNotYetImplemented
}
// SubmitExchangeOrder submits a new order
func (y *Yobit) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
// SubmitOrder submits a new order
func (y *Yobit) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
response, err := y.Trade(p.Pair().String(), orderType.ToString(), amount, price)
@@ -156,54 +155,54 @@ func (y *Yobit) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide
return submitOrderResponse, err
}
// ModifyExchangeOrder will allow of changing orderbook placement and limit to
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (y *Yobit) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
return 0, errors.New("not yet implemented")
func (y *Yobit) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
return 0, common.ErrNotYetImplemented
}
// CancelExchangeOrder cancels an order by its corresponding ID number
func (y *Yobit) CancelExchangeOrder(orderID int64) error {
return errors.New("not yet implemented")
// CancelOrder cancels an order by its corresponding ID number
func (y *Yobit) CancelOrder(orderID int64) error {
return common.ErrNotYetImplemented
}
// CancelAllExchangeOrders cancels all orders associated with a currency pair
func (y *Yobit) CancelAllExchangeOrders() error {
return errors.New("not yet implemented")
// CancelAllOrders cancels all orders associated with a currency pair
func (y *Yobit) CancelAllOrders() error {
return common.ErrNotYetImplemented
}
// GetExchangeOrderInfo returns information on a current open order
func (y *Yobit) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) {
// GetOrderInfo returns information on a current open order
func (y *Yobit) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
var orderDetail exchange.OrderDetail
return orderDetail, errors.New("not yet implemented")
return orderDetail, common.ErrNotYetImplemented
}
// GetExchangeDepositAddress returns a deposit address for a specified currency
func (y *Yobit) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) {
return "", errors.New("not yet implemented")
// GetDepositAddress returns a deposit address for a specified currency
func (y *Yobit) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) {
return "", common.ErrNotYetImplemented
}
// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (y *Yobit) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) {
return "", errors.New("not yet implemented")
func (y *Yobit) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) {
return "", common.ErrNotYetImplemented
}
// WithdrawFiatExchangeFunds returns a withdrawal ID when a
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (y *Yobit) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) {
return "", errors.New("not yet implemented")
func (y *Yobit) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) {
return "", common.ErrNotYetImplemented
}
// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (y *Yobit) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) {
return "", errors.New("not yet implemented")
func (y *Yobit) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) {
return "", common.ErrNotYetImplemented
}
// GetWebsocket returns a pointer to the exchange websocket
func (y *Yobit) GetWebsocket() (*exchange.Websocket, error) {
return nil, errors.New("not yet implemented")
return nil, common.ErrNotYetImplemented
}
// GetFeeByType returns an estimate of fee based on type of transaction