<commit_before>module Spree::Chimpy
  module Interface
    class List
      delegate :log, to: Spree::Chimpy

      def initialize(list_name, segment_name, double_opt_in, list_id)
        @api           = Spree::Chimpy.api
        @list_id       = list_id
        @segment_name  = segment_name
        @double_opt_in = double_opt_in
        @list_name     = list_name
      end

      def api_call
        @api.lists
      end

      def subscribe(email, merge_vars = {}, options = {})
        log "Subscribing #{email} to #{@list_name}"

        api_call.subscribe(list_id, { email: email }, merge_vars, 'html', @double_opt_in, true)

        segment([email]) if options[:customer]
      rescue Mailchimp::ListInvalidImportError
        log "#{email} unable to be signed up"
      end

      def unsubscribe(email)
        log "Unsubscribing #{email} from #{@list_name}"

        begin
          api_call.unsubscribe(list_id, { email: email })
        rescue Mailchimp::EmailNotExistsError
        end
      end

      def info(email_or_id)
        log "Checking member info for #{email_or_id} from #{@list_name}"

        #maximum of 50 emails allowed to be passed in
        response = api_call.member_info(list_id, [{email: email_or_id}])
        if response['success_count'] && response['success_count'] > 0
          record = response['data'].first.symbolize_keys
        end

        record.nil? ? {} : record
      end
<commit_msg>Return true is exception occurs<commit_after>module Spree::Chimpy
  module Interface
    class List
      delegate :log, to: Spree::Chimpy

      def initialize(list_name, segment_name, double_opt_in, list_id)
        @api           = Spree::Chimpy.api
        @list_id       = list_id
        @segment_name  = segment_name
        @double_opt_in = double_opt_in
        @list_name     = list_name
      end

      def api_call
        @api.lists
      end

      def subscribe(email, merge_vars = {}, options = {})
        log "Subscribing #{email} to #{@list_name}"

        api_call.subscribe(list_id, { email: email }, merge_vars, 'html', @double_opt_in, true)

        segment([email]) if options[:customer]
      rescue Mailchimp::ListInvalidImportError
        log "#{email} unable to be signed up"
      end

      def unsubscribe(email)
        log "Unsubscribing #{email} from #{@list_name}"

        begin
          api_call.unsubscribe(list_id, { email: email })
        rescue Mailchimp::EmailNotExistsError
          true
        end
      end

      def info(email_or_id)
        log "Checking member info for #{email_or_id} from #{@list_name}"

        #maximum of 50 emails allowed to be passed in
        response = api_call.member_info(list_id, [{email: email_or_id}])
        if response['success_count'] && response['success_count'] > 0
          record = response['data'].first.symbolize_keys
        end

        record.nil? ? {} : record
      end

{'fraction_non_alphanumeric': 0.09824802473376847, 'fraction_numerical': 0.0020611473720371005, 'mean_word_length': 2.3703703703703702, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1192423', 'n_tokens_mistral': 894, 'n_tokens_neox': 867, 'n_words': 219}