Class: Cryptoexchange::Exchanges::Idex::Services::Pairs

Inherits:
Services::Pairs show all
Defined in:
lib/cryptoexchange/exchanges/idex/services/pairs.rb

Constant Summary collapse

PAIRS_URL =
"#{Cryptoexchange::Exchanges::Idex::Market::API_URL}/returnTicker"
HTTP_METHOD =
'POST'

Constants inherited from Services::Pairs

Services::Pairs::MARKET, Services::Pairs::POST_PARAMS

Instance Method Summary collapse

Methods inherited from Services::Pairs

#default_override_exist?, #default_override_path, #exchange_class, #fetch_via_api, #fetch_via_api_using_post, #fetch_via_override, #http_get, #http_post, #user_override_exist?, #user_override_path

Instance Method Details

#adapt(pair_list) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/cryptoexchange/exchanges/idex/services/pairs.rb', line 27

def adapt(pair_list)
  pair_list.map do |pair|
    target, base = pair.split("_")
    Cryptoexchange::Models::MarketPair.new(
      base: base,
      target: target,
      market: Idex::Market::NAME
    )
  end
end

#fetchObject



8
9
10
11
12
# File 'lib/cryptoexchange/exchanges/idex/services/pairs.rb', line 8

def fetch
  output = super
  pair_list = filter_nil_pair(output)
  adapt(pair_list)
end

#filter_nil_pair(output) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cryptoexchange/exchanges/idex/services/pairs.rb', line 14

def filter_nil_pair(output)
  pair_list = []
  output.map do |k, v|
    i = 0
    v.select do |key, value|
      i += 1 if value == "N/A"
    end
    next if i >= 5
    pair_list << k
  end
  pair_list
end