Module: Yext::Api::Concerns::ApiFinder
- Included in:
- Utils::ApiRateLimits, Utils::ResponseParser
- Defined in:
- lib/yext/api/concerns/api_finder.rb
Overview
This module add the ‘find_api` method to a class to allow the searching of the base api category module for a particular route.
Instance Method Summary collapse
Instance Method Details
#find_api(url, method) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/yext/api/concerns/api_finder.rb', line 9 def find_api(url, method) return if url.nil? || method.nil? return Yext::Api::LiveApi if url.host.include?("liveapi") hash = YAML.load_file(Yext::Api::Engine.root.join("lib/config/api.yml")) hash.each_key do |hash_key| guess_api = api_from_key(hash_key) next if guess_api.blank? return guess_api if found_route?(hash[hash_key], url.path, method.to_s) end nil end |