Class: WhosGotDirt::Requests::Relation::OpenCorporates
- Inherits:
-
WhosGotDirt::Request
- Object
- WhosGotDirt::Request
- WhosGotDirt::Requests::Relation::OpenCorporates
- Defined in:
- lib/whos_got_dirt/requests/relation/open_corporates.rb
Overview
Requests for corporate officerships from the OpenCorporates API.
OpenCorporates' date_of_birth
and address
filters require an API
key. Its order
parameter is not supported.
Instance Method Summary collapse
-
#convert ⇒ Hash
Converts the MQL parameters to API-specific parameters.
-
#or_operator ⇒ String
Returns the "OR" operator's serialization.
-
#to_s ⇒ String
Returns the URL to request.
Constructor Details
This class inherits a constructor from WhosGotDirt::Request
Instance Method Details
#convert ⇒ Hash
Converts the MQL parameters to API-specific parameters.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/whos_got_dirt/requests/relation/open_corporates.rb', line 47 def convert equal('per_page', 'limit', default: input['open_corporates_api_key'] && 100) input['subject'] && input['subject'].each do |subject| match('q', 'name', input: subject) date_range('date_of_birth', 'birth_date', input: subject) subject['contact_details'] && subject['contact_details'].each do |contact_detail| if contact_detail['type'] == 'address' && (contact_detail['value'] || contact_detail['value~=']) output['address'] = contact_detail['value'] || contact_detail['value~='] end end end # API-specific parameters. equal('api_token', 'open_corporates_api_key') one_of('jurisdiction_code', 'jurisdiction_code', transform: lambda{|v| v.downcase}) equal('position', 'role') equal('inactive', 'inactive', valid: [true, false]) output end |
#or_operator ⇒ String
Returns the "OR" operator's serialization.
39 40 41 |
# File 'lib/whos_got_dirt/requests/relation/open_corporates.rb', line 39 def or_operator '|' end |
#to_s ⇒ String
Returns the URL to request.
32 33 34 |
# File 'lib/whos_got_dirt/requests/relation/open_corporates.rb', line 32 def to_s "#{base_url}?#{to_query(convert.merge(order: 'score'))}" end |