Sha256: 22ba5634ef283d426cbe828271c0fb49d8e792b31612a46e1959b572a10c963b

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module WhosGotDirt
  module Requests
    module List
      # Requests for lists from the LittleSis API.
      #
      # The `q` parameter matches names and descriptions.
      #
      # @example Supply an API key.
      #   "little_sis_api_key": "..."
      class LittleSis < Request
        # The JSON response has less metadata, e.g. number of results.
        @base_url = 'https://api.littlesis.org/lists.xml'

        # Returns the URL to request.
        #
        # @return [String] the URL to request
        def to_s
          "#{base_url}?#{to_query(convert)}"
        end

        # Converts the MQL parameters to API-specific parameters.
        #
        # @return [Hash] API-specific parameters
        # @see http://api.littlesis.org/documentation#lists
        def convert
          match('q', 'name')
          equal('num', 'limit') # default 100, maximum 100
          equal('page', 'page')

          # API-specific parameters.
          equal('_key', 'little_sis_api_key')

          output
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whos_got_dirt-0.0.5 lib/whos_got_dirt/requests/list/little_sis.rb