<commit_before>module Spree
  module Adyen
    class ApiResponse
      attr_reader :gateway_response

      def initialize gateway_response
        @gateway_response = gateway_response
      end

      def success?
        !error_response? && gateway_response.success?
      end

      def psp_reference
        return nil if error_response?
        @gateway_response[:psp_reference]
      end

      def attributes
        if error_response?
          {}
        else
          @gateway_response.attributes
        end
      end

      def message<commit_msg>Add method for determining if adyen response is for a redirect<commit_after>module Spree
  module Adyen
    class ApiResponse
      attr_reader :gateway_response

      def initialize gateway_response
        @gateway_response = gateway_response
      end

      def success?
        !error_response? && gateway_response.success?
      end

      def redirect?
        @gateway_response.is_a?(::Adyen::REST::AuthorisePayment::Response) &&
          @gateway_response.attributes["paymentResult.resultCode"] == "RedirectShopper"
      end

      def psp_reference
        return nil if error_response?
        @gateway_response[:psp_reference]
      end

      def attributes
        if error_response?
          {}
        else
          @gateway_response.attributes
        end
      end

      def message
{'fraction_non_alphanumeric': 0.053440702781844804, 'fraction_numerical': 0.0, 'mean_word_length': 2.1864801864801864, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3928356', 'n_tokens_mistral': 373, 'n_tokens_neox': 357, 'n_words': 89}