github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/v2/rest/currencies.go (about) 1 package rest 2 3 import ( 4 "path" 5 "strings" 6 7 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/currency" 8 ) 9 10 // CurrenciesService manages the conf endpoint. 11 type CurrenciesService struct { 12 requestFactory 13 Synchronous 14 } 15 16 // Conf - retreive currency and symbol service configuration data 17 // see https://docs.bitfinex.com/reference#rest-public-conf for more info 18 func (cs *CurrenciesService) Conf(label, symbol, unit, explorer, pairs bool) ([]currency.Conf, error) { 19 segments := make([]string, 0) 20 if label { 21 segments = append(segments, string(currency.LabelMap)) 22 } 23 if symbol { 24 segments = append(segments, string(currency.SymbolMap)) 25 } 26 if unit { 27 segments = append(segments, string(currency.UnitMap)) 28 } 29 if explorer { 30 segments = append(segments, string(currency.ExplorerMap)) 31 } 32 if pairs { 33 segments = append(segments, string(currency.ExchangeMap)) 34 } 35 36 req := NewRequestWithMethod(path.Join("conf", strings.Join(segments, ",")), "GET") 37 raw, err := cs.Request(req) 38 if err != nil { 39 return nil, err 40 } 41 42 // add mapping to raw data 43 parsedRaw := make([]currency.RawConf, len(raw)) 44 for index, d := range raw { 45 parsedRaw = append(parsedRaw, currency.RawConf{Mapping: segments[index], Data: d}) 46 } 47 48 // parse to config object 49 configs, err := currency.FromRaw(parsedRaw) 50 if err != nil { 51 return nil, err 52 } 53 54 return configs, nil 55 }