module API.WebMoney.Internal.Https where

import qualified Data.ByteString.Lazy.Char8 as LB
import           Network.Connection
import           Network.HTTP.Conduit

-- | Get a new Manager that doesn't verify SSL certificates
noSSLVerifyManager :: IO Manager
noSSLVerifyManager =
    let tlsSettings = TLSSettingsSimple {
        settingDisableCertificateValidation = True,
        settingDisableSession = False,
        settingUseServerName = True}
    in newManager $ mkManagerSettings tlsSettings Nothing

-- | Download like with simpleHttp, but using an existing manager for the task
simpleHttpWithManager :: Manager -> String -> IO LB.ByteString
simpleHttpWithManager manager url = do
  url' <- parseUrl url
  fmap responseBody $ httpLbs url' manager

x1 = do
  manager <- noSSLVerifyManager
  simpleHttpWithManager manager "https://wmeng.exchanger.ru/asp/XMLWMList.asp?exchtype=1"
