{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
module Web.OpenWeatherMap.API
( weatherByName
, weatherByCoord
) where
import Data.Proxy (Proxy(..))
import Servant.API ((:<|>)(..), (:>), Get, JSON, QueryParam)
import Servant.Client (ClientM, client)
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)