class Whowas::MyAdapter

Private Instance Methods

format(input) click to toggle source

Transforms input one last time before API call. Will be called on input for all search_methods using this adapter. For search_method-specific transformations, use the format_input method in your search_method.

# File lib/generators/whowas/templates/adapter.rb, line 34
def format(input)
  input
end
search_api(input) click to toggle source

Sends a search query with provided input to your third-party API and returns results as a string.

# File lib/generators/whowas/templates/adapter.rb, line 16
def search_api(input)
  ""
end
validate(input) click to toggle source

Validates input to avoid unnecessary API calls. MUST return true or raise a Whowas::Errors::InvalidInput error. Replace “true” with your validation code.

# File lib/generators/whowas/templates/adapter.rb, line 25
def validate(input)
  true ||
  (raise Whowas::Errors::InvalidInput, "Invalid input for #{self.class.name}")
end