class TransparentData::Actions::Search
Constants
- COUNTRY_TO_KEY_MAP
Attributes
client[R]
country[R]
query_str[R]
Public Class Methods
new(client, country, query_str)
click to toggle source
# File lib/transparent_data/actions/search.rb, line 15 def initialize(client, country, query_str) @client = client @country = country @query_str = query_str end
Public Instance Methods
call()
click to toggle source
# File lib/transparent_data/actions/search.rb, line 21 def call search_method = "#{fetch_country_id(country)}Search" TransparentData::Request.call(client, search_method, query: build_query(query_str)) end
Private Instance Methods
build_query(query_str)
click to toggle source
# File lib/transparent_data/actions/search.rb, line 29 def build_query(query_str) { q: query_str } end
fetch_country_id(country)
click to toggle source
# File lib/transparent_data/actions/search.rb, line 33 def fetch_country_id(country) COUNTRY_TO_KEY_MAP.fetch(country.to_s.downcase.to_sym) do raise TransparentData::UnknownCountryError, "Unknown country: #{country.inspect}" end end