File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -1502,8 +1502,8 @@ public static class WeatherTools
1502
1502
HttpClient client ,
1503
1503
[Description (" The US state to get alerts for." )] string state )
1504
1504
{
1505
- var jsonElement = await client .GetFromJsonAsync <JsonElement >($" /alerts/active/area/{state }" );
1506
- var alerts = jsonElement .GetProperty (" features" ).EnumerateArray ();
1505
+ var stateData = await client .GetFromJsonAsync <JsonElement >($" /alerts/active/area/{state }" );
1506
+ var alerts = stateData .GetProperty (" features" ).EnumerateArray ();
1507
1507
1508
1508
if (! alerts .Any ())
1509
1509
{
@@ -1529,8 +1529,16 @@ public static class WeatherTools
1529
1529
[Description (" Latitude of the location." )] double latitude ,
1530
1530
[Description (" Longitude of the location." )] double longitude )
1531
1531
{
1532
- var jsonElement = await client .GetFromJsonAsync <JsonElement >($" /points/{latitude },{longitude }" );
1533
- var periods = jsonElement .GetProperty (" properties" ).GetProperty (" periods" ).EnumerateArray ();
1532
+ var pointData = await client .GetFromJsonAsync <JsonElement >($" /points/{latitude },{longitude }" );
1533
+ var forecastUrl = pointData .GetProperty (" properties" ).GetProperty (" forecast" ).GetString ();
1534
+
1535
+ if (string .IsNullOrEmpty (forecastUrl ))
1536
+ {
1537
+ return " Forecast URL not found." ;
1538
+ }
1539
+
1540
+ var forecastData = await client .GetFromJsonAsync <JsonElement >(forecastUrl );
1541
+ var periods = forecastData .GetProperty (" properties" ).GetProperty (" periods" ).EnumerateArray ();
1534
1542
1535
1543
return string .Join (" \n ---\n " , periods .Select (period => $"""
1536
1544
{period .GetProperty (" name" ).GetString ()}
You can’t perform that action at this time.
0 commit comments