Class: WhosGotDirt::Requests::Entity::Poderopedia

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

Overview

Requests for entities from the Poderopedia API.

The Poderopedia API returns 10 results only, without pagination.

The entity filter is required.

Examples:

Supply an API key.

"poderopedia_api_key": "..."

Find entities of the class Person or Organization.

"entity": "Person"

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.

Returns:

  • (Hash)

    API-specific parameters

See Also:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/whos_got_dirt/requests/entity/poderopedia.rb', line 29

def convert
  match('alias', 'name')

  # API-specific parameters.
  equal('user_key', 'poderopedia_api_key')
  equal('entity', 'type', valid: ['Person', 'Organization'], transform: lambda{|v|
    case v
    when 'Person'
      'persona'
    when 'Organization'
      'organizacion'
    end
  })

  output
end

#to_sString

Returns the URL to request.

Returns:

  • (String)

    the URL to request



21
22
23
# File 'lib/whos_got_dirt/requests/entity/poderopedia.rb', line 21

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