diff --git a/lib/open_weather/api.rb b/lib/open_weather/api.rb index 62aaa3f..15589f0 100644 --- a/lib/open_weather/api.rb +++ b/lib/open_weather/api.rb @@ -34,7 +34,7 @@ def cities(ids, options = {}) raise LocationsLimitExceeded end - url = 'http://api.openweathermap.org/data/2.5/group' + url = Base::API_URL + '/group' ids = encode_array ids new(options.merge(id: ids)).retrieve url end @@ -44,7 +44,7 @@ def cities(ids, options = {}) def rectangle_zone(top_left_lat, top_left_lon, bottom_right_lat, bottom_right_lon, map_zoom, options = {}) - url = 'http://api.openweathermap.org/data/2.5/box/city' + url = Base::API_URL + '/box/city' bbox = encode_array [top_left_lat, top_left_lon, bottom_right_lat, bottom_right_lon, map_zoom] new(options.merge(bbox: bbox)).retrieve url @@ -53,7 +53,7 @@ def rectangle_zone(top_left_lat, top_left_lon, # Circle zone (lat, lon and count of cities to return) # Usage: OpenWeather::Current.circle_zone(55.5, 37.5, 10) def circle_zone(lat, lon, count, options = {}) - url = 'http://api.openweathermap.org/data/2.5/find' + url = Base::API_URL + '/find' new(options.merge(lat: lat, lon: lon, cnt: count)).retrieve url end diff --git a/lib/open_weather/base.rb b/lib/open_weather/base.rb index f34cf94..5e50782 100644 --- a/lib/open_weather/base.rb +++ b/lib/open_weather/base.rb @@ -3,7 +3,8 @@ module OpenWeather class Base - + API_URL = 'https://api.openweathermap.org/data/2.5' + attr_reader :url, :options, :weather_info, :status, :message def initialize(url, options) diff --git a/lib/open_weather/current.rb b/lib/open_weather/current.rb index 76ccaf2..05a7f49 100644 --- a/lib/open_weather/current.rb +++ b/lib/open_weather/current.rb @@ -1,7 +1,7 @@ module OpenWeather class Current < Base def initialize(options = {}) - super('http://api.openweathermap.org/data/2.5/weather', options) + super(API_URL + '/weather', options) end end end diff --git a/lib/open_weather/find.rb b/lib/open_weather/find.rb index 608f23c..80bf236 100644 --- a/lib/open_weather/find.rb +++ b/lib/open_weather/find.rb @@ -1,7 +1,7 @@ module OpenWeather class Find < Base def initialize(options = {}) - super('http://api.openweathermap.org/data/2.5/find', options) + super(API_URL + '/find', options) end def self.like(q, options = {}) diff --git a/lib/open_weather/forecast.rb b/lib/open_weather/forecast.rb index 5911314..d4d6f4f 100644 --- a/lib/open_weather/forecast.rb +++ b/lib/open_weather/forecast.rb @@ -1,7 +1,7 @@ module OpenWeather class Forecast < Base def initialize options = {} - super('http://api.openweathermap.org/data/2.5/forecast', options) + super(API_URL + '/forecast', options) end end end diff --git a/lib/open_weather/forecast_daily.rb b/lib/open_weather/forecast_daily.rb index 06a26a7..694bfe2 100644 --- a/lib/open_weather/forecast_daily.rb +++ b/lib/open_weather/forecast_daily.rb @@ -1,7 +1,7 @@ module OpenWeather class ForecastDaily < Base def initialize options = {} - super('http://api.openweathermap.org/data/2.5/forecast/daily', options) + super(API_URL + '/forecast/daily', options) end end end