main.rb
##
# Makes a /weather or a /forecast GET request to the OpenWeatherMap API.
# Either (q) or (lat, lon) are mandatory.
# By giving the parameter _future a /forecast request is executed.
Makes a /weather or a /forecast GET request to the OpenWeatherMap API.
Either (q) or (lat, lon) are mandatory.
By giving the parameter _future a /forecast request is executed.
Makes a / weather or a / forecast GET request to the OpenWeatherMap API . Either ( q ) or ( lat lon ) are mandatory . By giving the parameter _future a / forecast request is executed .
def doWeatherRequest(_params, _future)
  cityParam = ["q"]
  coordParam = ["lat","lon"]
  definedParams = (cityParam + coordParam)
  parm = _params.length > 0 ? _params : {"q" => "Neuchatel"}
  if hasAllParams(parm, cityParam) and hasOneParam(parm, coordParam)
    return doError('Request contains too many parameters ('+definedParams.join(",")+')')
  elsif hasAllParams(parm, cityParam) or hasAllParams(parm, coordParam)
    url = WEATHER_EP + "/" + (_future ? "forecast" : "weather") + "?" + WEATHER_APPID + "&" + URI.encode_www_form(parm)
    return forwardRequest(url)
  else
    return doError('Request does not contain one of the correct parameters ('+definedParams.join(",")+')')
  end
end
def doWeatherRequest ( _params , _future ) cityParam = [ "q" ] coordParam = [ "lat" , "lon" ] definedParams = ( cityParam + coordParam ) parm = _params . length > 0 ? _params : { "q" => "Neuchatel" } if hasAllParams ( parm , cityParam ) and hasOneParam ( parm , coordParam ) return doError ( 'Request contains too many parameters (' + definedParams . join ( "," ) + ')' ) elsif hasAllParams ( parm , cityParam ) or hasAllParams ( parm , coordParam ) url = WEATHER_EP + "/" + ( _future ? "forecast" : "weather" ) + "?" + WEATHER_APPID + "&" + URI . encode_www_form ( parm ) return forwardRequest ( url ) else return doError ( 'Request does not contain one of the correct parameters (' + definedParams . join ( "," ) + ')' ) end end
Makes a /weather or a /forecast GET request to the OpenWeatherMap API.
Makes a / weather or a / forecast GET request to the OpenWeatherMap API .
_params
<not_specific>
_future
<not_specific>