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