<commit_before>require 'openssl'
require 'base64'
require 'rexml/document'

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    # The base class for all iDEAL response classes.
    #
    # Note that if the iDEAL system is under load it will _not_ allow more
    # then two retries per request.
    class IdealResponse < Response
      def initialize(response_body, options = {})
        @response = REXML::Document.new(response_body).root
        @success = !error_occured?
        @test = options[:test]
        #@params = Hash.from_xml(response_body)
      end

      # Returns a technical error message.
      def error_message
        text('//Error/errorMessage') unless success?
      end

      # Returns a consumer friendly error message.
      def consumer_error_message
        text('//Error/consumerMessage') unless success?
      end

      # Returns details on the error if available.
      def error_details
        text('//Error/errorDetail') unless success?
      end

      # Returns an error type inflected from the first two characters of the
      # error code. See error_code for a full list of errors.
      #
      # Error code to type mappings:
      #
      # * +IX+ - <tt>:xml</tt>
      # * +SO+ - <tt>:system</tt>
      # * +SE+ - <tt>:security</tt>
      # * +BR+ - <tt>:value</tt>
      # * +AP+ - <tt>:application</tt>
      def error_type
        unless success?
          case error_code[0,2]
          when 'IX' then :xml<commit_msg>setting the params variable in the Response initializer. fixing the unit test.<commit_after>require 'openssl'
require 'base64'
require 'rexml/document'

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    # The base class for all iDEAL response classes.
    #
    # Note that if the iDEAL system is under load it will _not_ allow more
    # then two retries per request.
    class IdealResponse < Response
      def initialize(response_body, options = {})
        @response = REXML::Document.new(response_body).root
        @success = !error_occured?
        @test = options[:test]
        @params = Hash.from_xml(response_body)
      end

      # Returns a technical error message.
      def error_message
        text('//Error/errorMessage') unless success?
      end

      # Returns a consumer friendly error message.
      def consumer_error_message
        text('//Error/consumerMessage') unless success?
      end

      # Returns details on the error if available.
      def error_details
        text('//Error/errorDetail') unless success?
      end

      # Returns an error type inflected from the first two characters of the
      # error code. See error_code for a full list of errors.
      #
      # Error code to type mappings:
      #
      # * +IX+ - <tt>:xml</tt>
      # * +SO+ - <tt>:system</tt>
      # * +SE+ - <tt>:security</tt>
      # * +BR+ - <tt>:value</tt>
      # * +AP+ - <tt>:application</tt>
      def error_type
        unless success?
          case error_code[0,2]
          when 'IX' then :xml
{'fraction_non_alphanumeric': 0.10119442601194426, 'fraction_numerical': 0.0026542800265428003, 'mean_word_length': 2.35, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '4668200', 'n_tokens_mistral': 877, 'n_tokens_neox': 862, 'n_words': 284}