@@ -60,10 +60,13 @@ sendRequest' :: HttpResponse resp => Proxy resp -> Text -> [Pair] -> ConnexpayM
6060sendRequest' resp endpoint body =
6161 do tok <- bearerToken
6262 host <- asks (.url)
63+ tls <- asks (.useTLS)
6364 let auth = header "Authorization" ("Bearer " <> Text.encodeUtf8 tok)
64− url = https host /: "api" /: "v1" /: endpoint
65+ url s = s host /: "api" /: "v1" /: endpoint
6566 jbody <- ReqBodyJson . object <$> addGuid body
66− req POST url jbody resp auth
67+ if tls
68+ then req POST (url https) jbody resp auth
69+ else req POST (url http) jbody resp auth
6770 where addGuid b = do guid <- asks (.deviceGuid)
6871 return (b <> [ "DeviceGuid" .= show guid ])
6972