From 4a56f6ccdad4b2cef66c0e6262aa9a9e36eabbad Mon Sep 17 00:00:00 2001 From: imi415 Date: Mon, 3 Oct 2022 15:57:11 +0800 Subject: [PATCH] Updated API types and base URL changes. Signed-off-by: imi415 --- lib/moji_weather/api/constants.rb | 16 +++++++++++++--- lib/moji_weather/api/rest_client.rb | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/moji_weather/api/constants.rb b/lib/moji_weather/api/constants.rb index 6b7631a..76b3286 100644 --- a/lib/moji_weather/api/constants.rb +++ b/lib/moji_weather/api/constants.rb @@ -1,16 +1,22 @@ module MojiWeather module Api module ApiType + ALERT = 'alert' + AQI = 'aqi' CONDITION = 'condition' FORECAST_24HRS = 'forecast24hours' + FORECAST_6DAYS = 'briefforecast6days' FORECAST_15DAYS = 'forecast15days' - AQI = 'aqi' - LIMIT = 'limit' LIFE_INDEX = 'index' + LIMIT = 'limit' end module Constants API_TOKENS = { + MojiWeather::Api::ApiType::ALERT => { + city_id: '7ebe966ee2e04bbd8cdbc0b84f7f3bc7', + location: 'd01246ac6284b5a591f875173e9e2a18' + }, MojiWeather::Api::ApiType::CONDITION => { city_id: '50b53ff8dd7d9fa320d3d3ca32cf8ed1', location: 'ff826c205f8f4a59701e64e9e64e01c4' @@ -31,6 +37,10 @@ module MojiWeather city_id: '5944a84ec4a071359cc4f6928b797f91', location: '42b0c7e2e8d00d6e80d92797fe5360fd' }, + MojiWeather::Api::ApiType::FORECAST_6DAYS => { + city_id: '073854b56a84f8a4956ba3e273f6c9d7', + location: '0f9d7e535dfbfad15b8fd2a84fee3e36', + }, MojiWeather::Api::ApiType::FORECAST_15DAYS => { city_id: 'f9f212e1996e79e0e602b08ea297ffb0', location: '7538f7246218bdbf795b329ab09cc524' @@ -38,4 +48,4 @@ module MojiWeather } end end -end \ No newline at end of file +end diff --git a/lib/moji_weather/api/rest_client.rb b/lib/moji_weather/api/rest_client.rb index 1d863a3..6743bad 100644 --- a/lib/moji_weather/api/rest_client.rb +++ b/lib/moji_weather/api/rest_client.rb @@ -9,8 +9,17 @@ module MojiWeather end @app_code = options[:app_code] - @cityid_base = "http://aliv18.data.moji.com/whapi/json/alicityweather" - @location_base = "http://aliv8.data.moji.com/whapi/json/aliweather" + if options[:cityid_base].nil? + @cityid_base = "http://aliv18.data.moji.com/whapi/json/alicityweather" + else + @cityid_base = options[:cityid_base] + end + + if options[:location_base].nil? + @location_base = "http://aliv8.data.moji.com/whapi/json/aliweather" + else + @location_base = options[:location_base] + end end def query(api_type, options = {}) @@ -69,4 +78,5 @@ module MojiWeather end end end -end \ No newline at end of file +end +