<commit_before># https://github.com/mailgun/mailgun-ruby

module Mailkick
  class Service
    class Mailgun < Mailkick::Service
      def initalize(options = {})
        require "mailgun"
        mailgun_client = ::Mailgun::Client.new(options[:api_key] || ENV["MAILGUN_API_KEY"])
        domain = options[:domain] || ActionMailer::Base.default_url_options[:host]
        @mailgun_events = ::Mailgun::Events.new(mailgun_client, domain)
      end

      def opt_outs
        unsubscribes + spam_reports + bounces
      end

      def unsubscribes
        fetch(@mailgun_events.get(event: "unsubscribed"), "unsubscribe")
      end

      def spam_reports
        fetch(@mailgun_events.get(event: "complained"), "spam")
      end

      def bounces
        fetch(@mailgun_events.get(event: "failed"), "bounce")
      end

      def self.discoverable?
        !!(defined?(::Mailgun) && ENV["MAILGUN_API_KEY"])
      end

      protected

      def fetch(response, reason)<commit_msg>Fixed initialize error<commit_after># https://github.com/mailgun/mailgun-ruby

module Mailkick
  class Service
    class Mailgun < Mailkick::Service
      def initialize(options = {})
        require "mailgun"
        mailgun_client = ::Mailgun::Client.new(options[:api_key] || ENV["MAILGUN_API_KEY"])
        domain = options[:domain] || ActionMailer::Base.default_url_options[:host]
        @mailgun_events = ::Mailgun::Events.new(mailgun_client, domain)
      end

      def opt_outs
        unsubscribes + spam_reports + bounces
      end

      def unsubscribes
        fetch(@mailgun_events.get(event: "unsubscribed"), "unsubscribe")
      end

      def spam_reports
        fetch(@mailgun_events.get(event: "complained"), "spam")
      end

      def bounces
        fetch(@mailgun_events.get(event: "failed"), "bounce")
      end

      def self.discoverable?
        !!(defined?(::Mailgun) && ENV["MAILGUN_API_KEY"])
      end

      protected

      def fetch(response, reason)
{'fraction_non_alphanumeric': 0.12004069175991862, 'fraction_numerical': 0.0, 'mean_word_length': 2.9261477045908184, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '7225431', 'n_tokens_mistral': 631, 'n_tokens_neox': 603, 'n_words': 113}