<commit_before>module Clearbit
  module Slack
    class Notifier
      attr_reader :company, :first_name, :last_name, :message, :person

      def initialize(attrs = {})
        @company = attrs[:company]
        @first_name = attrs[:first_name]
        @last_name = attrs[:last_name]
        @message = attrs[:message]
        @person = attrs[:person]
      end

      def ping
        notifier = ::Slack::Notifier.new(
          Slack.slack_url,
          channel: Slack.slack_channel,
          icon_url: icon_url,
          username: username
        )

        if person
          attachments << Attachments::Person.new(person).as_json
        end

        if company
          attachments << Attachments::Company.new(company).as_json
        end

        notifier.ping message, attachments: attachments
      end

      private

      def icon_url
        person && person.avatar || ''
      end

      def username
        if person
          if person.name.full_name
            person.name.full_name
          elsif person.name.given_name && person.name.family_name
            [person.name.given_name, person.name.family_name].join(' ')
          end
        elsif first_name || last_name
          [first_name, last_name].join(' ')
        else
          'Unknown'
        end
      end

      def attachments
        @attachments ||= []
      end
    end
  end
end<commit_msg>Rename params to given/family name<commit_after>module Clearbit
  module Slack
    class Notifier
      attr_reader :company, :given_name, :family_name, :message, :person

      def initialize(attrs = {})
        @company = attrs[:company]
        @family_name = attrs[:family_name]
        @given_name = attrs[:given_name]
        @message = attrs[:message]
        @person = attrs[:person]
      end

      def ping
        notifier = ::Slack::Notifier.new(
          Slack.slack_url,
          channel: Slack.slack_channel,
          icon_url: icon_url,
          username: username
        )

        if person
          attachments << Attachments::Person.new(person).as_json
        end

        if company
          attachments << Attachments::Company.new(company).as_json
        end

        notifier.ping message, attachments: attachments
      end

      private

      def icon_url
        person && person.avatar || ''
      end

      def username
        if person
          if person.name.full_name
            person.name.full_name
          elsif person.name.given_name && person.name.family_name
            [person.name.given_name, person.name.family_name].join(' ')
          end
        elsif given_name || family_name
          [given_name, family_name].join(' ')
        else
          'Unknown'
        end
      end

      def attachments
        @attachments ||= []
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08870680441752761, 'fraction_numerical': 0.0, 'mean_word_length': 1.796812749003984, 'pattern_counts': {'":': 0, '<': 11, '<?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': '5191832', 'n_tokens_mistral': 812, 'n_tokens_neox': 789, 'n_words': 175}