-- |
-- Use this module instead of @Network.Wreq.Session@ to use string-like datatypes.
--
-- see https://hackage.haskell.org/package/wreq/docs/Network-Wreq-Session.html
--
module Network.Wreq.StringLess.Session
    (
    -- * Session creation
      WreqS.Session
    , WreqS.withSession
    , WreqS.withAPISession
    -- ** More control-oriented session creation
    , WreqS.withSessionWith
    , WreqS.withSessionControl
    -- * HTTP verbs
    , get
    , post
    , head_
    , options
    , put
    , delete
    , customMethod
    -- ** Configurable verbs
    , getWith
    , postWith
    , headWith
    , optionsWith
    , putWith
    , deleteWith
    , customMethodWith
    -- * Extending a session
    , WreqS.seshRun
    ) where

import qualified Data.ByteString.Lazy as LBS
import qualified Network.Wreq         as Wreq
import qualified Network.Wreq.Session as WreqS
import           Network.Wreq.Types
import Network.Wreq.StringLess.StringLike
    
get :: StringLike s => WreqS.Session -> s -> IO (Wreq.Response LBS.ByteString)
get sesh = WreqS.get sesh . toString


getWith :: StringLike s => Wreq.Options -> WreqS.Session -> s -> IO (Wreq.Response LBS.ByteString)
getWith opts sesh = WreqS.getWith opts sesh . toString


post :: StringLike s => Postable a => WreqS.Session -> s -> a -> IO (Wreq.Response LBS.ByteString)
post sesh = WreqS.post sesh . toString


postWith :: StringLike s => Postable a => Wreq.Options -> WreqS.Session -> s -> a -> IO (Wreq.Response LBS.ByteString)
postWith opts sesh = WreqS.postWith opts sesh . toString


head_ :: StringLike s => WreqS.Session -> s -> IO (Wreq.Response ())
head_ sesh = WreqS.head_ sesh . toString


headWith :: StringLike s => Wreq.Options -> WreqS.Session -> s -> IO (Wreq.Response ())
headWith opts sesh = WreqS.headWith opts sesh . toString


options :: StringLike s => WreqS.Session -> s -> IO (Wreq.Response ())
options sesh = WreqS.options sesh . toString


optionsWith :: StringLike s => Wreq.Options -> WreqS.Session -> s -> IO (Wreq.Response ())
optionsWith opts sesh = WreqS.optionsWith opts sesh . toString


put :: StringLike s => Putable a => WreqS.Session -> s -> a -> IO (Wreq.Response LBS.ByteString)
put sesh = WreqS.put sesh . toString


putWith :: StringLike s => Putable a => Wreq.Options -> WreqS.Session -> s -> a -> IO (Wreq.Response LBS.ByteString)
putWith opts sesh = WreqS.putWith opts sesh . toString


delete :: StringLike s => WreqS.Session -> s -> IO (Wreq.Response LBS.ByteString)
delete sesh = WreqS.delete sesh . toString


customMethod :: StringLike s => s -> WreqS.Session -> s -> IO (Wreq.Response LBS.ByteString)
customMethod = flip customMethodWith Wreq.defaults


deleteWith :: StringLike s => Wreq.Options -> WreqS.Session -> s -> IO (Wreq.Response LBS.ByteString)
deleteWith opts sesh = WreqS.deleteWith opts sesh . toString


customMethodWith :: StringLike s => s -> Wreq.Options -> WreqS.Session -> s -> IO (Wreq.Response LBS.ByteString)
customMethodWith method opts sesh url = WreqS.customMethodWith (toString method) opts sesh (toString url)