<commit_before>module HubbleObservatory
  # Provides methods to interact with the Hubble API talent-accounts endpoint
  # @see https://hubble.fullscreen.net/api/docs#talentaccounts-create-talent-account
  class TalentAccount

    def initialize(id:)
      @hubble_uuid = id
    end

    # @return [String] the hubble uuid associated with the email
    def self.create(email:)
      request = HubbleObservatory::Request.new(attrs: {body_attrs: {email: email}, request_type: :post, auth_header: true})
      @response = request.run_request
      process_account_data(@response)
    end

    # @return [String] the hubble uuid associated with the email
    def update(email:)
      request = HubbleObservatory::Request.new(attrs: {body_attrs: {email: email}, route: "talent-accounts/hubble-uuid/#{@hubble_uuid}", request_type: :patch, auth_header: true})
      @response = request.run_request
      self.class.process_account_data(@response)
    end

    private

    def self.process_account_data(account_data)
      hubble_uuid = if account_data
                      extract_attribute_from_data(data: account_data, attribute: :hubble_uuid) || extract_uuid_from_errors(data: account_data)
                    end
      hubble_uuid.to_s if !hubble_uuid.nil?
    end

    def self.extract_attribute_from_data(data:, attribute:)
      data.fetch(:data, {}).fetch(:attributes, {}).fetch(attribute, nil)
    end

    def self.extract_uuid_from_errors(data:)
      data.fetch(:errors, [{}])[0].fetch(:hubble_uuid, nil)
    end
  end
end<commit_msg>Change method name and signature for extract_...<commit_after>module HubbleObservatory
  # Provides methods to interact with the Hubble API talent-accounts endpoint
  # @see https://hubble.fullscreen.net/api/docs#talentaccounts-create-talent-account
  class TalentAccount

    def initialize(id:)
      @hubble_uuid = id
    end

    # @return [String] the hubble uuid associated with the email
    def self.create(email:)
      request = HubbleObservatory::Request.new(attrs: {body_attrs: {email: email}, request_type: :post, auth_header: true})
      @response = request.run_request
      process_account_data(@response)
    end

    # @return [String] the hubble uuid associated with the email
    def update(email:)
      request = HubbleObservatory::Request.new(attrs: {body_attrs: {email: email}, route: "talent-accounts/hubble-uuid/#{@hubble_uuid}", request_type: :patch, auth_header: true})
      @response = request.run_request
      self.class.process_account_data(@response)
    end

    private

    def self.process_account_data(account_data)
      hubble_uuid = if account_data
                      extract_hubble_uuid_from(account_data) || extract_uuid_from_errors(data: account_data)
                    end
      hubble_uuid.to_s if !hubble_uuid.nil?
    end

    def self.extract_hubble_uuid_from(data)
      data.fetch(:data, {}).fetch(:attributes, {})[:hubble_uuid]
    end

    def self.extract_uuid_from_errors(data:)
      data.fetch(:errors, [{}])[0].fetch(:hubble_uuid, nil)
    end
  end
end
{'fraction_non_alphanumeric': 0.10493625367767244, 'fraction_numerical': 0.0006538084341288003, 'mean_word_length': 3.6363636363636362, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4028825', 'n_tokens_mistral': 950, 'n_tokens_neox': 919, 'n_words': 208}