示例#1
0
        static void Main(string[] args)
        {
            //https://openweathermap.org/data/2.5/forecast/daily/?appid=b6907d289e10d714a6e88b30761fae22&id=2147714&units=metric
            var baseUrl  = "https://openweathermap.org";
            var endPoint = "data/2.5";
            var appId    = "b6907d289e10d714a6e88b30761fae22";
            var apiType  = "forecast/daily";
            var cityId   = 2147714;
            var degree   = 20;

            //Set URL
            RestApiHelper.baseUrl = baseUrl;
            RestApiHelper.SetUrl(endPoint);

            //Create Request GET
            //RestApiHelper.CreateRequest(apiType, appid, cityId);
            //RestApiHelper.CreateRequest(apiType, appId, cityId);
            RestApiHelper.CreateRequest();


            //Get Response
            RestResponse response = RestApiHelper.GetResponse();

            //Assert that the page loaded successfully
            AssertAPI.AssertPageLoaded(response);

            //Analize the response
            ForecastDailyResponse forecastDailyResponse = new JsonDeserializer().Deserialize <ForecastDailyResponse>(response);

            //PredictAboveCertainDegree(forecastDailyResponse, degree);
        }
        public void ParseForecastDailyResponse()
        {
            //Get Response
            response = RestApiHelper.GetResponse();

            //Verify the page loaded successfully
            AssertAPI.AssertPageLoaded(response);

            //Parse the response
            forecastDailyResponse = new JsonDeserializer().Deserialize <ForecastDailyResponse>(response);
        }