Unified client for making OpenWeatherMap API requests.
This module replaces the old Coordinator/Worker pattern with a simpler approach using direct function calls and Task.async_stream for batching.
Summary
Functions
Fetches weather data for a single location.
Fetches weather data for multiple locations concurrently.
Types
@type endpoint() ::
:current_weather
| :one_call
| :forecast_5day
| :forecast_hourly
| :forecast_16day
| :historical
| :air_pollution
| :air_pollution_forecast
| :air_pollution_history
| :geocode
| :reverse_geocode
@type options() :: keyword()
Functions
@spec fetch(endpoint(), ExOwm.Location.t() | map(), options()) :: result()
Fetches weather data for a single location.
Parameters
endpoint- The API endpoint to call (:current_weather,:one_call, etc.)location- A%ExOwm.Location{}struct or location mapopts- Request options (units, lang, cnt, etc.)
Returns
{:ok, data}- Successfully fetched weather data{:error, reason}- API error (not_found, bad_request, etc.){:error, reason, details}- API error with response details
@spec fetch_batch(endpoint(), [ExOwm.Location.t() | map()], options()) :: [result()]
Fetches weather data for multiple locations concurrently.
Parameters
endpoint- The API endpoint to calllocations- List of%ExOwm.Location{}structs or location mapsopts- Request options
Returns
List of results, each being {:ok, data} or {:error, reason}.