Class: Cryptoexchange::Exchanges::Aex::Services::Pairs

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

Constant Summary collapse

PAIRS_URLS =
[
  "#{Cryptoexchange::Exchanges::Aex::Market::API_URL}/ticker.php?c=all&mk_type=btc",
  "#{Cryptoexchange::Exchanges::Aex::Market::API_URL}/ticker.php?c=all&mk_type=bitcny",
  "#{Cryptoexchange::Exchanges::Aex::Market::API_URL}/ticker.php?c=all&mk_type=bitusd"
]

Constants inherited from Services::Pairs

Services::Pairs::HTTP_METHOD, Services::Pairs::MARKET, Services::Pairs::PAIRS_URL, 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(output, target) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cryptoexchange/exchanges/aex/services/pairs.rb', line 19

def adapt(output, target)
  pairs = []
  output.each do |key, value|
    pairs << Cryptoexchange::Models::MarketPair.new(
      base: key,
      target: target,
      market: Aex::Market::NAME
    )
  end
  pairs 
end

#fetchObject



11
12
13
14
15
16
17
# File 'lib/cryptoexchange/exchanges/aex/services/pairs.rb', line 11

def fetch
  PAIRS_URLS.map do |endpoint|
    output = fetch_via_api(endpoint)
    target = endpoint.split("=").last
    adapt(output, target)
  end.flatten
end