Class: OrbDef::OpenWeatherApi::WeatherByCoordinates
- Inherits:
-
Object
- Object
- OrbDef::OpenWeatherApi::WeatherByCoordinates
- Defined in:
- app/services/orb_def/open_weather_api/weather_by_coordinates.rb
Constant Summary collapse
- API_THROTTLE_TIME =
(ENV['API_THROTTLE_TIME'] || 0.02).freeze
Class Method Summary collapse
Class Method Details
.fetch(latitude:, longitude:) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'app/services/orb_def/open_weather_api/weather_by_coordinates.rb', line 8 def fetch(latitude:, longitude:) response = open_weather_client.get do |req| req.url "/data/2.5/weather?lat=#{latitude}&lon=#{longitude}&appid=#{open_weather_key}" end sleep API_THROTTLE_TIME JSON.parse(response.body) if response.success? end |