diff --git a/src/Lunapark/API.purs b/src/Lunapark/API.purs index a868b2c..5cb8447 100644 --- a/src/Lunapark/API.purs +++ b/src/Lunapark/API.purs @@ -232,7 +232,7 @@ jsonWireActions inp = case _ of pure next DoubleClick btn next → do _ ← case btn of - LT.LeftBtn → post_ (LP.DoubleClick : Nil) + LT.LeftBtn → post' (LP.DoubleClick : Nil) other → do _ ← post (LP.Click : Nil) (LT.encodeButton btn) post (LP.Click : Nil) (LT.encodeButton btn) @@ -253,16 +253,16 @@ jsonWireActions inp = case _ of pure next InTouch tch → case tch of Tap next → do - _ ← post_ (LP.Touch : LP.Click : Nil) + _ ← post' (LP.Touch : LP.Click : Nil) pure next TouchDown next → do - _ ← post_ (LP.Touch : LP.Down : Nil) + _ ← post' (LP.Touch : LP.Down : Nil) pure next TouchUp next → do - _ ← post_ (LP.Touch : LP.Up : Nil) + _ ← post' (LP.Touch : LP.Up : Nil) pure next LongClick next → do - _ ← post_ (LP.Touch : LP.LongClick : Nil) + _ ← post' (LP.Touch : LP.LongClick : Nil) pure next Flick move next → do element ← case move.origin of @@ -281,11 +281,11 @@ jsonWireActions inp = case _ of _ ← post (LP.Touch : LP.Scroll : Nil) (LT.encodeMoveToRequest req) pure next DoubleTap next → do - _ ← post_ (LP.Touch : LP.DoubleClick : Nil) + _ ← post' (LP.Touch : LP.DoubleClick : Nil) pure next where post a b = liftAndRethrow $ LP.post inp.uri (inSession : a) b - post_ a = liftAndRethrow $ LP.post_ inp.uri (inSession : a) + post' a = liftAndRethrow $ LP.post' inp.uri (inSession : a) inSession ∷ LP.EndpointPart inSession = LP.InSession inp.session @@ -316,13 +316,13 @@ handleLunapark inp = case _ of res ← get $ inSession : LP.Url : Nil map cont $ throwLeftJsonDecodeError $ J.decodeJson res Back next → do - _ ← post_ (inSession : LP.Back : Nil) + _ ← post' (inSession : LP.Back : Nil) pure next Forward next → do - _ ← post_ (inSession : LP.Forward : Nil) + _ ← post' (inSession : LP.Forward : Nil) pure next Refresh next → do - _ ← post_ (inSession : LP.Refresh : Nil) + _ ← post' (inSession : LP.Refresh : Nil) pure next GetTitle cont → do res ← get (inSession : LP.Title : Nil) @@ -349,7 +349,7 @@ handleLunapark inp = case _ of _ ← post (inSession : LP.Frame : Nil) (LT.encodeFrameId fid) pure next SwitchToParentFrame next → do - _ ← post_ (inSession : LP.Frame : LP.Parent : Nil) + _ ← post' (inSession : LP.Frame : LP.Parent : Nil) pure next GetWindowRectangle cont → do res ← tryAndCache "get window rectangle" @@ -369,13 +369,13 @@ handleLunapark inp = case _ of ] pure next MaximizeWindow next → do - _ ← post_ (inSession : LP.Window : LP.Maximize : Nil) + _ ← post' (inSession : LP.Window : LP.Maximize : Nil) pure next MinimizeWindow next → do - _ ← post_ (inSession : LP.Window : LP.Minimize : Nil) + _ ← post' (inSession : LP.Window : LP.Minimize : Nil) pure next FullscreenWindow next → do - _ ← post_ (inSession : LP.Window : LP.Fullscreen : Nil) + _ ← post' (inSession : LP.Window : LP.Fullscreen : Nil) pure next ExecuteScript script cont → do map cont $ tryAndCache "execute script" @@ -404,14 +404,14 @@ handleLunapark inp = case _ of pure next DismissAlert next → do _ ← tryAndCache "dismiss alert" - [ post_ (inSession : LP.Alert : LP.Dismiss : Nil) - , post_ (inSession : LP.DismissAlert : Nil) + [ post' (inSession : LP.Alert : LP.Dismiss : Nil) + , post' (inSession : LP.DismissAlert : Nil) ] pure next AcceptAlert next → do _ ← tryAndCache "accept alert" - [ post_ (inSession : LP.Alert : LP.Accept : Nil) - , post_ (inSession : LP.AcceptAlert : Nil) + [ post' (inSession : LP.Alert : LP.Accept : Nil) + , post' (inSession : LP.AcceptAlert : Nil) ] pure next GetAlertText cont → do @@ -495,13 +495,13 @@ handleLunapark inp = case _ of map cont $ throwLeftJsonDecodeError $ J.decodeJson res ClickEl next → do _ ← tryAndCache "chromedriver75 update clickElement" - [ post_ (inSession : inElement : LP.Click : Nil) + [ post' (inSession : inElement : LP.Click : Nil) , post (inSession : inElement : LP.Click : Nil) $ LT.encodeElement el ] pure next ClearEl next → do _ ← tryAndCache "chromedriver75 update clearElement" - [ post_ (inSession : inElement : LP.Clear : Nil) + [ post' (inSession : inElement : LP.Clear : Nil) , post (inSession : inElement : LP.Click : Nil) $ LT.encodeElement el ] pure next @@ -524,7 +524,7 @@ handleLunapark inp = case _ of map cont $ throwLeftJsonDecodeError $ J.decodeJson res Submit next → do _ ← tryAndCache "chromedriver75 update submit form" - [ post_ (inSession : inElement : LP.Submit : Nil) + [ post' (inSession : inElement : LP.Submit : Nil) , post (inSession: inElement : LP.Submit : Nil) $ LT.encodeElement el ] pure next @@ -533,7 +533,7 @@ handleLunapark inp = case _ of delete a = liftAndRethrow $ LP.delete inp.uri a post a b = liftAndRethrow $ LP.post inp.uri a b get a = liftAndRethrow $ LP.get inp.uri a - post_ a = liftAndRethrow $ LP.post_ inp.uri a + post' a = liftAndRethrow $ LP.post' inp.uri a tryAndCache ∷ ∀ a. String → Array (BaseRun r a) → BaseRun r a tryAndCache key actions = do diff --git a/src/Lunapark/Endpoint.purs b/src/Lunapark/Endpoint.purs index d32facf..66c80bd 100644 --- a/src/Lunapark/Endpoint.purs +++ b/src/Lunapark/Endpoint.purs @@ -186,8 +186,11 @@ get uri ep = map handleAPIError $ N.get NR.json (uri <> print ep) post ∷ String → Endpoint → Json → Aff (Either LE.Error Json) post uri ep obj = map handleAPIError $ N.post NR.json (uri <> print ep) $ Just (NQ.json obj) -post_ ∷ String → Endpoint → Aff (Either LE.Error Json) -post_ uri ep = map handleAPIError $ N.post NR.json (uri <> print ep) Nothing +post' ∷ String → Endpoint → Aff (Either LE.Error Json) +post' uri ep = map handleAPIError $ N.post NR.json (uri <> print ep) Nothing + +-- | post_ ∷ String → Endpoint → Aff (Either LE.Error Unit) +-- | post_ uri ep = map handleAPIErrorWithoutJson $ N.post_ (uri <> print ep) Nothing delete ∷ String → Endpoint → Aff (Either LE.Error Json) delete uri ep = map handleAPIError $ N.delete NR.json (uri <> print ep)