module Web.OpenWeatherMap.API (
weatherByName,
weatherByCoord
) where
import Data.Proxy (Proxy(..))
import Servant.API ((:>), (:<|>)(..), JSON, Get, QueryParam)
import Servant.Client (client)
import Servant.Common.Req (ClientM)
import Web.OpenWeatherMap.Types.CurrentWeather (CurrentWeather)
type GetCurrentWeather = AppId :> Get '[JSON] CurrentWeather
type AppId = QueryParam "appid" String
type API
= "weather" :> QueryParam "q" String :> GetCurrentWeather
:<|> "weather" :> QueryParam "lat" Double :> QueryParam "lon" Double
:> GetCurrentWeather
weatherByName
:: Maybe String
-> Maybe String
-> ClientM CurrentWeather
weatherByCoord
:: Maybe Double
-> Maybe Double
-> Maybe String
-> ClientM CurrentWeather
weatherByName :<|> weatherByCoord = client (Proxy :: Proxy API)