Updated API types and base URL changes.

Signed-off-by: imi415 <imi415@imi.moe>
This commit is contained in:
imi415 2022-10-03 15:57:11 +08:00
parent 5a08ea60b4
commit 4a56f6ccda
Signed by: imi415
GPG Key ID: 17F01E106F9F5E0A
2 changed files with 26 additions and 6 deletions

View File

@ -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
end

View File

@ -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
end