<commit_before>module BungieClient::Wrappers
  class User < Default
    attr_reader :membership_type, :display_name

    # Initialize wrapper with user's preset
    #
    # @note maybe add the `destiny_membership_id` as an alternative to `display_name`
    #
    # @option options [Integer] :membership_type Platform type number (xbox - 1, playstation - 2, all - 256)
    # @option options [String] :display_name Simple user name
    def initialize(options)
      super

      # set membershipType
      if %w(1 2 256).include? options[:membership_type].to_s
        @membership_type = options[:membership_type].to_s
      else
        @membership_type = '256'
      end

      # set displayName
      if options[:display_name].is_a? String
        @display_name = options[:display_name]
      else
        raise 'You must set user display name'
      end
    end

    # Get DestinyMembershipId of selected user
    def destiny_membership_id
      return @destiny_membership_id unless @destiny_membership_id.nil?

      @destiny_membership_id = call_service(
        'get_membership_id_by_display_name',
        {
          :displayName =>  @display_name,
          :membershipType => @membership_type
        }
      )
    end

    def fill_url(url, params)
      params = {} unless params.is_a? Hash

      params[:displayName] = @display_name
      params[:membershipType] = @membership_type
      params[:destinyMembershipId] = destiny_membership_id if url.include? '{destinyMembershipId}'
      params[:membershipId] = destiny_membership_id if url.include? '{membershipId}'

      super
    end
  end
end<commit_msg>set destiny membership id in user wrapper<commit_after>module BungieClient::Wrappers
  class User < Default
    attr_reader :membership_type, :display_name

    # Initialize wrapper with user's preset
    #
    # @note maybe add the `destiny_membership_id` as an alternative to `display_name`
    #
    # @option options [Integer] :membership_type Platform type number (xbox - 1, playstation - 2, all - 256)
    # @option options [String] :display_name Simple user name
    def initialize(options)
      super

      # set membershipType
      if %w(1 2 256).include? options[:membership_type].to_s
        @membership_type = options[:membership_type].to_s
      else
        @membership_type = '256'
      end

      # set displayName
      if options[:display_name].is_a? String
        @display_name = options[:display_name]
      else
        raise 'You must set user display name'
      end

      # set destinyMembershipId if needed
      @destiny_membership_id = options[:destiny_membership_id] unless options[:destiny_membership_id].nil?
    end

    # Get DestinyMembershipId of selected user
    def destiny_membership_id
      return @destiny_membership_id unless @destiny_membership_id.nil?

      @destiny_membership_id = call_service(
        'get_membership_id_by_display_name',
        {
          :displayName =>  @display_name,
          :membershipType => @membership_type
        }
      )
    end

    def fill_url(url, params)
      params = {} unless params.is_a? Hash

      params[:displayName] = @display_name
      params[:membershipType] = @membership_type
      params[:destinyMembershipId] = destiny_membership_id if url.include? '{destinyMembershipId}'
      params[:membershipId] = destiny_membership_id if url.include? '{membershipId}'

      super
    end
  end
end
{'fraction_non_alphanumeric': 0.0804093567251462, 'fraction_numerical': 0.00760233918128655, 'mean_word_length': 3.0105509964830013, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7640047', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1010, 'n_words': 253}