Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // CoinNames maps long name to short names of exchangers CoinNames = map[string]string{}/* 214 elements not displayed */ )
var (
ErrBestchange = errors.New("bcapi")
)
var (
ErrMarketsParsing = errors.New("markets parsing")
)
var (
ErrRatesParsing = errors.New("rates parsing")
)
Functions ¶
func GenerateLinkCustom ¶ added in v0.2.5
GenerateLinkCustom generates link to bestchange site custom
Types ¶
type Bestchange ¶
Bestchange is a main object of api that provides the way to get the best rates for coins
func NewBestchange ¶
func NewBestchange(client *http.Client) (*Bestchange, error)
NewBestchange returns the Bestchange object with which we can find the best price for coins
As argument you should pass your specified http.Client or just pass http.DefaultClient
func (*Bestchange) GetRatesFromTo ¶
func (b *Bestchange) GetRatesFromTo(from, to string) ([]Rate, error)
GetRatesFromTo return rates
You can pass to this function either the ID, full-name, short-name.
But ID is preferable, because it will 100% work
func (*Bestchange) UpdateCoins ¶
func (b *Bestchange) UpdateCoins(client *http.Client) error
UpdateCoins again download the zip file and updates exactly Coins
func (*Bestchange) UpdateMarktes ¶
func (b *Bestchange) UpdateMarktes(client *http.Client) error
UpdateMarktes again download the zip file and updates exactly Markets
func (*Bestchange) UpdateRates ¶
func (b *Bestchange) UpdateRates(client *http.Client) error
UpdateRates again download the zip file and updates exactly Rates
type Coin ¶
type Coin struct { ID string `json:"coin_id"` FullName string `json:"coin_full_name"` ShortName string `json:"coin_short_name"` }
Coin has id, FullName and ShortName
type Rate ¶
type Rate struct { // CoinFrom is coin from where to where we want // to convert the coin CoinFrom Coin `json:"coin_from"` // CoinTo this is the coin we want // to convert to CoinTo Coin `json:"coin_to"` // Price is a cost per 1 coinTo in coinTo currency // // for example we want to convert QIWI_RUB -> BTC // we will got price 4 448 698 QIWI_RUB per 1 BTC Price string `json:"price"` // PriceFrom is a price starting from how many we can purchase PriceFrom string `json:"price_from"` // PriceTill is a price till to we can purchase PriceTill string `json:"price_till"` // Market is a market Market Market `json:"market"` // Rating is a rating of market in format negative/positive // // for example "WW-Pay" has 0/8467 rating, // 0 - negative, 8467 postive Rating string `json:"rating"` // Receive is number of coins that customer will get for the price Receive string `json:"receive"` }
Rate contains information for coinFrom -> coinTo transaction
func SortRatesByPrice ¶
SortRatesByPrice sorts the rates ([]Rate) by their Price value
This function does not modify the data, it returns the sorted one
func SortRatesByReceive ¶
SortRatesByReceive sorts the rates ([]Rate) by their Recieve value
This function does not modify the data, it returns the sorted one
func (*Rate) GenerateLink ¶
GenerateLink generates link to bestchange site
Unfortunately, works incorrectly sometimes
func (*Rate) GenerateMarketLink ¶
GenerateMarketLink generates the link to the market of this offer