Sha256: 45938370930e6819b52986a5fe11a529e54f45ca864203ff9f7fad5fe1d6bc8f

Contents?: true

Size: 1.63 KB

Versions: 4

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

module MediaWiktory::Wikipedia
  module Actions
    # Check the validity of a token from action=query&meta=tokens.
    #
    # Usage:
    #
    # ```ruby
    # api.checktoken.type(value).perform # returns string with raw output
    # # or
    # api.checktoken.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 Checktoken < MediaWiktory::Wikipedia::Actions::Get

      # Type of token being tested.
      #
      # @param value [String] One of "createaccount", "csrf", "deleteglobalaccount", "login", "patrol", "rollback", "setglobalaccountstatus", "userrights", "watch".
      # @return [self]
      def type(value)
        _type(value) or fail ArgumentError, "Unknown value for type: #{value}"
      end

      # @private
      def _type(value)
        defined?(super) && super || ["createaccount", "csrf", "deleteglobalaccount", "login", "patrol", "rollback", "setglobalaccountstatus", "userrights", "watch"].include?(value.to_s) && merge(type: value.to_s)
      end

      # Token to test.
      #
      # @param value [String]
      # @return [self]
      def token(value)
        merge(token: value.to_s)
      end

      # Maximum allowed age of the token, in seconds.
      #
      # @param value [Integer]
      # @return [self]
      def maxtokenage(value)
        merge(maxtokenage: 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/checktoken.rb
mediawiktory-0.1.2 lib/mediawiktory/wikipedia/actions/checktoken.rb
mediawiktory-0.1.1 lib/mediawiktory/wikipedia/actions/checktoken.rb
mediawiktory-0.1.0 lib/mediawiktory/wikipedia/actions/checktoken.rb