class Cryptoexchange::Exchanges::Forkdelta::Market

Constants

API_URL
NAME
TOKEN_URL

Public Class Methods

fetch_symbol() click to toggle source
# File lib/cryptoexchange/exchanges/forkdelta/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={}) click to toggle source
# File lib/cryptoexchange/exchanges/forkdelta/market.rb, line 8
def self.trade_page_url(args={})
  "https://forkdelta.app/#!/trade/#{args[:base]}-#{args[:target]}"
end

Private Class Methods

http_get(endpoint) click to toggle source
# File lib/cryptoexchange/exchanges/forkdelta/market.rb, line 41
def http_get(endpoint)
  HTTP.timeout(:write => 2, :connect => 15, :read => 18).follow.get(endpoint)
end