Class: Cryptoexchange::Exchanges::Ercdex::Services::IdFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptoexchange/exchanges/ercdex/services/id_fetcher.rb

Constant Summary collapse

PAIR_SYMBOLS_URL =
"#{Cryptoexchange::Exchanges::Ercdex::Market::API_URL}/token-pair-summaries/1"
PAIR_SYMBOLS =
[]

Class Method Summary collapse

Class Method Details

.get_id(base, target) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/cryptoexchange/exchanges/ercdex/services/id_fetcher.rb', line 9

def self.get_id(base, target)
  if PAIR_SYMBOLS.empty?
   pairs_response = HTTP.get(PAIR_SYMBOLS_URL)
   PAIR_SYMBOLS << pairs_response.parse(:json)
  end
    # filtering through asset dictionary to find market_pair and obtaining the market_pair base and target's ID
    pair = PAIR_SYMBOLS[0].select{ |s| s["tokenPair"]["tokenA"]["symbol"] == base && s["tokenPair"]["tokenB"]["symbol"] == target }
  pair
end