<commit_before>module Cryptoexchange::Exchanges
  module DoveWallet
    module Services
      class Market < Cryptoexchange::Services::Market
        class << self
          def supports_individual_ticker_query?
            true
          end
        end

        def fetch(market_pair)
          output = super(ticker_url(market_pair))
          adapt(output['result'][0],market_pair)
        end

        def ticker_url(market_pair)
          "#{Cryptoexchange::Exchanges::DoveWallet::Market::API_URL}/getmarketsummary?market=#{market_pair.target}-#{market_pair.base}"
        end

        def adapt(output, market_pair)
          ticker = Cryptoexchange::Models::Ticker.new
          ticker.base      = market_pair.base
          ticker.target    = market_pair.target
          ticker.market    = DoveWallet::Market::NAME
          ticker.last      = NumericHelper.to_d(output['Last'])
          ticker.high      = NumericHelper.to_d(output['High'])
          ticker.low       = NumericHelper.to_d(output['Low'])
          ticker.bid       = NumericHelper.to_d(output['Bid'])
          ticker.ask       = NumericHelper.to_d(output['Ask'])
          ticker.volume    = NumericHelper.to_d(output['Volume']) / ticker.last
          ticker.timestamp = nil
          ticker.payload   = output
          ticker
        end
      end
    end
  end
end<commit_msg>[#hotfix] Dove volume and error return error handling (#2064)<commit_after>module Cryptoexchange::Exchanges
  module DoveWallet
    module Services
      class Market < Cryptoexchange::Services::Market
        class << self
          def supports_individual_ticker_query?
            true
          end
        end

        def fetch(market_pair)
          output = super(ticker_url(market_pair))
          handle_invalid(output)
          adapt(output['result'].first, market_pair)
        end

        def ticker_url(market_pair)
          "#{Cryptoexchange::Exchanges::DoveWallet::Market::API_URL}/getmarketsummary?market=#{market_pair.target}-#{market_pair.base}"
        end

        def adapt(output, market_pair)
          ticker = Cryptoexchange::Models::Ticker.new
          ticker.base      = market_pair.base
          ticker.target    = market_pair.target
          ticker.market    = DoveWallet::Market::NAME
          ticker.last      = NumericHelper.to_d(output['Last'])
          ticker.high      = NumericHelper.to_d(output['High'])
          ticker.low       = NumericHelper.to_d(output['Low'])
          ticker.bid       = NumericHelper.to_d(output['Bid'])
          ticker.ask       = NumericHelper.to_d(output['Ask'])
          ticker.volume    = NumericHelper.to_d(output['BaseVolume'])
          ticker.timestamp = nil
          ticker.payload   = output
          ticker
        end

        def handle_invalid(output)
          if output['message'] == 'INVALID_MARKET'
            raise Cryptoexchange::ResultParseError, { response: output }
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.099026518966096, 'fraction_numerical': 0.0016784155756965425, 'mean_word_length': 2.1803628601921026, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2979352', 'n_tokens_mistral': 877, 'n_tokens_neox': 852, 'n_words': 139}