Class: WhosGotDirt::Requests::Entity::LittleSis

Inherits:
WhosGotDirt::Request show all
Defined in:
lib/whos_got_dirt/requests/entity/little_sis.rb

Overview

Requests for entities from the LittleSis API.

Tokens less than two characters long will be ignored by LittleSis' q filter. The q parameter matches names and aliases. If search_all is 1, it also matches descriptions and summaries.

Examples:

Supply an API key.

"little_sis_api_key": "..."

Match descriptions and summaries on name~= queries.

"search_all": 1

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from WhosGotDirt::Request

Instance Method Details

#convertHash

Converts the MQL parameters to API-specific parameters.



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/whos_got_dirt/requests/entity/little_sis.rb', line 38

def convert
  match('q', 'name')
  one_of('type_ids', 'classification')
  equal('num', 'limit') # default 20, maximum 1000?
  equal('page', 'page')

  # API-specific parameters.
  equal('_key', 'little_sis_api_key')
  equal('search_all', 'search_all', valid: [1])

  output
end

#or_operatorString

Returns the "OR" operator's serialization.

Returns:

  • (String)

    the "OR" operator's serialization



29
30
31
# File 'lib/whos_got_dirt/requests/entity/little_sis.rb', line 29

def or_operator
  ','
end

#to_sString

Returns the URL to request.

Returns:

  • (String)

    the URL to request



22
23
24
# File 'lib/whos_got_dirt/requests/entity/little_sis.rb', line 22

def to_s
  "#{base_url}?#{to_query(convert)}"
end