<commit_before>module Spree::Conekta
  class Exchange
    
    EXCHANCE_SERVICES = 'http://rate-exchange.appspot.com/'
    
    def initialize(amount, currency_from)
      @amount = (amount.to_i)
      @currency_from = currency_from
      get_exchange_rate
    end
    
    def amount_exchanged
      @amount_exchanged ||= (@amount * @exchange_rate).round
    end
    
    private
    
    def get_exchange_rate
      response = JSON.parse(connection.get("currency?from=#{@currency_from}&to=MXN").body)
      @exchange_rate = response['rate'].nil? ? 0 : response['rate'].to_f
    end
    
    def connection
      Faraday.new(url: EXCHANCE_SERVICES) do |faraday|
        faraday.request :url_encoded
        faraday.adapter :typhoeus
      end
    end
  end
end<commit_msg>Change currency exchange service<commit_after>module Spree::Conekta
  class Exchange
    
    EXCHANCE_SERVICES = 'https://currency-api.appspot.com/api/'
    
    def initialize(amount, currency_from)
      @amount = (amount.to_i)
      @currency_from = currency_from
      get_exchange_rate
    end
    
    def amount_exchanged
      @amount_exchanged ||= (@amount * @exchange_rate).round
    end
    
    private
    
    def get_exchange_rate
      response = JSON.parse(connection.get("#{@currency_from}/MXN.json?amount=#{@amount}").body)
      @exchange_rate = response['rate'].nil? ? 0 : response['rate'].to_f
    end
    
    def connection
      Faraday.new(url: EXCHANCE_SERVICES) do |faraday|
        faraday.request :url_encoded
        faraday.adapter :typhoeus
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10222222222222223, 'fraction_numerical': 0.0012698412698412698, 'mean_word_length': 2.7434679334916865, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '2619841', 'n_tokens_mistral': 526, 'n_tokens_neox': 502, 'n_words': 92}