Sha256: 4e63286dedf1c73612e8dccacc9a5b7614365f37d12e2e89a5a8c6f76f38a9ad

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

module MediaWiktory::Wikipedia
  module Modules
    # Get a summary of logged API feature usages for a user agent.
    #
    # The "submodule" (MediaWiki API term) is included in action after setting some param, providing
    # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and
    # its submodules):
    #
    # ```ruby
    # api.query             # returns Actions::Query
    #    .prop(:revisions)  # adds prop=revisions to action URL, and includes Modules::Revisions into action
    #    .limit(10)         # method of Modules::Revisions, adds rvlimit=10 to URL
    # ```
    #
    # All submodule's parameters are documented as its public methods, see below.
    #
    module Featureusage

      # Start of date range to query.
      #
      # @param value [Time]
      # @return [self]
      def start(value)
        merge(afustart: value.iso8601)
      end

      # End of date range to query.
      #
      # @param value [Time]
      # @return [self]
      def end(value)
        merge(afuend: value.iso8601)
      end

      # User agent to query. If not specified, the agent in the request will be queried.
      #
      # @param value [String]
      # @return [self]
      def agent(value)
        merge(afuagent: value.to_s)
      end

      # If specified, return details on only these features.
      #
      # @param values [Array<String>]
      # @return [self]
      def features(*values)
        values.inject(self) { |res, val| res._features(val) }
      end

      # @private
      def _features(value)
        merge(afufeatures: value.to_s, replace: false)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mediawiktory-0.1.3 lib/mediawiktory/wikipedia/modules/featureusage.rb
mediawiktory-0.1.2 lib/mediawiktory/wikipedia/modules/featureusage.rb
mediawiktory-0.1.1 lib/mediawiktory/wikipedia/modules/featureusage.rb
mediawiktory-0.1.0 lib/mediawiktory/wikipedia/modules/featureusage.rb