Sha256: 126c042c2ee341e35eb7464e03f998e413b7a246096be1a2fcaab04e2dbd2877

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

module MediaWiktory::Wikipedia
  module Actions
    # Get configuration of the Zero extension.
    #
    # Usage:
    #
    # ```ruby
    # api.zeroconfig.type(value).perform # returns string with raw output
    # # or
    # api.zeroconfig.type(value).response # returns output parsed and wrapped into Response object
    # ```
    #
    # See {Base} for generic explanation of working with MediaWiki actions and
    # {MediaWiktory::Wikipedia::Response} for working with action responses.
    #
    # All action's parameters are documented as its public methods, see below.
    #
    class Zeroconfig < MediaWiktory::Wikipedia::Actions::Get

      # What kind of Zero info is needed:
      #
      # @param value [String] One of "config" (Get a trimmed-down carrier configuration based on the X-CS header), "message" (Get language-appropriate verbiage based on X-CS header; requires agent param).
      # @return [self]
      def type(value)
        _type(value) or fail ArgumentError, "Unknown value for type: #{value}"
      end

      # @private
      def _type(value)
        defined?(super) && super || ["config", "message"].include?(value.to_s) && merge(type: value.to_s)
      end

      # When setting type to message, include a source agent value as well.
      #
      # @param value [String]
      # @return [self]
      def agent(value)
        merge(agent: value.to_s)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mediawiktory-0.1.3 lib/mediawiktory/wikipedia/actions/zeroconfig.rb
mediawiktory-0.1.2 lib/mediawiktory/wikipedia/actions/zeroconfig.rb
mediawiktory-0.1.1 lib/mediawiktory/wikipedia/actions/zeroconfig.rb
mediawiktory-0.1.0 lib/mediawiktory/wikipedia/actions/zeroconfig.rb