Class: Cryptoexchange::Exchanges::Coinchangex::Market

Inherits:
Models::Market
  • Object
show all
Defined in:
lib/cryptoexchange/exchanges/coinchangex/market.rb

Constant Summary collapse

NAME =
'coinchangex'
API_URL =
'https://api.coinchangex.com'
TOKEN_URL =
'https://www.coinchangex.com/config/main.json'

Class Method Summary collapse

Class Method Details

.fetch_symbolObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cryptoexchange/exchanges/coinchangex/market.rb', line 13

def fetch_symbol
  begin
    fetch_response = http_get(TOKEN_URL)
    if fetch_response.code == 200
      result  = JSON.parse(fetch_response)['tokens']
      symbols = {}
      result.map do |symbol|
        symbols[symbol['addr']] = symbol['name']
      end
      symbols
    elsif fetch_response.code == 400
      raise Cryptoexchange::HttpBadRequestError, { response: fetch_response }
    else
      raise Cryptoexchange::HttpResponseError, { response: fetch_response }
    end
  rescue HTTP::ConnectionError => e
    raise Cryptoexchange::HttpConnectionError, { error: e, response: fetch_response }
  rescue HTTP::TimeoutError => e
    raise Cryptoexchange::HttpTimeoutError, { error: e, response: fetch_response }
  rescue JSON::ParserError => e
    raise Cryptoexchange::JsonParseError, { error: e, response: fetch_response }
  rescue TypeError => e
    raise Cryptoexchange::TypeFormatError, { error: e, response: fetch_response }
  end
end

.trade_page_url(args = {}) ⇒ Object



8
9
10
# File 'lib/cryptoexchange/exchanges/coinchangex/market.rb', line 8

def self.trade_page_url(args={})
  "https://www.coinchangex.com/#!/trade/#{args[:base]}-#{args[:target]}"
end