Skip to content

Commit

Permalink
feat: rename post_ to post' to match post_ function from Affjax
Browse files Browse the repository at this point in the history
  • Loading branch information
srghma committed Nov 18, 2020
1 parent c29e049 commit c8dfbf1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
44 changes: 22 additions & 22 deletions src/Lunapark/API.purs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ jsonWireActions inp = case _ of
pure next
DoubleClick btn next → do
_ ← case btn of
LT.LeftBtnpost_ (LP.DoubleClick : Nil)
LT.LeftBtnpost' (LP.DoubleClick : Nil)
other → do
_ ← post (LP.Click : Nil) (LT.encodeButton btn)
post (LP.Click : Nil) (LT.encodeButton btn)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/Lunapark/Endpoint.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit c8dfbf1

Please sign in to comment.