main.rb
##
# Combines /stations and /weather GET requests.
#
# Takes an IP address as parameter and returns a list of pairs <destination, weather> 
# for the next 5 connections returned by the /stations route.
#
# Parameter IP is mandatory.
Combines /stations and /weather GET requests.
Takes an IP address as parameter and returns a list of pairs 
for the next 5 connections returned by the /stations route.

Parameter IP is mandatory.
Combines / stations and / weather GET requests . Takes an IP address as parameter and returns a list of pairs for the next 5 connections returned by the / stations route . Parameter IP is mandatory .
def doWeathersRequest(_params, _future)
  res = doStationsRequest(_params)
  station = JSON.parse(res)
  if station.key?("errors")
    return res
  else
    departing_station_name = station["departing_station_name"]
    stationboard = station["stationboard"]
    destinations = Array.new
    stationboard.each do |board|
      dest = (board["passList"].last)["station"]
      coord = dest["coordinate"]
      departure = board["stop"]["departure"]
      platform = board["stop"]["platform"]
      res = doWeatherRequest({"lat" => coord["x"].to_s, "lon" => coord["y"].to_s}, _future)
      weather = JSON.parse(res)
      destinations.push({"departing_station_name" => departing_station_name, "destination" => dest, "weather" => weather, "departure" => departure, "platform" => platform})
    end
    return destinations
  end
end
def doWeathersRequest ( _params , _future ) res = doStationsRequest ( _params ) station = JSON . parse ( res ) if station . key? ( "errors" ) return res else departing_station_name = station [ "departing_station_name" ] stationboard = station [ "stationboard" ] destinations = Array . new stationboard . each do | board | dest = ( board [ "passList" ] . last ) [ "station" ] coord = dest [ "coordinate" ] departure = board [ "stop" ] [ "departure" ] platform = board [ "stop" ] [ "platform" ] res = doWeatherRequest ( { "lat" => coord [ "x" ] . to_s , "lon" => coord [ "y" ] . to_s } , _future ) weather = JSON . parse ( res ) destinations . push ( { "departing_station_name" => departing_station_name , "destination" => dest , "weather" => weather , "departure" => departure , "platform" => platform } ) end return destinations end end
Combines /stations and /weather GET requests.
Combines / stations and / weather GET requests .
# check for error
_params
<not_specific>
_future
<not_specific>