module BomApi
BomApi — shared BOM public API client (no API key; browser Referer).
Constants
- BASE_URL
- REFERER
- USER_AGENT
Public Instance Methods
Source
# File lib/bom_api.rb, line 14 def api_url(path) path = path.to_s path.start_with?("http") ? path : "#{BASE_URL}#{path.start_with?("/") ? path : "/#{path}"}" end
Source
# File lib/bom_api.rb, line 23 def fetch_json(path, fetch:) url = api_url(path) body = fetch.call(url) JSON.parse(body) end
Source
# File lib/bom_api.rb, line 19 def request_headers { "User-Agent" => USER_AGENT, "Referer" => REFERER } end