Copyright | (c) 2022 Edward Yang |
---|---|
License | MIT |
Safe Haskell | None |
Language | Haskell2010 |
This module is for internal-use and does not follow pvp versioning policies.
Synopsis
- class Monad m => MonadCaptcha api r m where
- type CaptchaError api r m
- createTask :: CaptchaRequest api ctx r m => ctx -> m (Either (CaptchaError api r m) (CaptchaId ctx))
- getTask :: CaptchaResponse api ctx => Text -> CaptchaId ctx -> m (Either (CaptchaError api r m) Text)
- solve :: (CaptchaRequest api ctx r m, CaptchaResponse api ctx, HasApiKey ctx Text, HasPollingInterval ctx (Maybe (Time Millisecond)), HasTimeoutDuration ctx (Maybe (Time Millisecond))) => ctx -> m (Either (CaptchaError api r m) Text)
- class CaptchaRequest api ctx r m where
- request :: ctx -> Text -> m (Response ByteString)
- class CaptchaResponse api ctx where
- parseResult :: Value -> Maybe Value
- newtype CaptchaId ctx = CaptchaId {}
Documentation
class Monad m => MonadCaptcha api r m where Source #
Abstracts over a captcha solving service.
type CaptchaError api r m Source #
An error specific to the captcha solving service.
:: CaptchaRequest api ctx r m | |
=> ctx | The captcha to be solved. |
-> m (Either (CaptchaError api r m) (CaptchaId ctx)) | Captcha id to be used with |
Submit a task to be solved by the api service.
:: CaptchaResponse api ctx | |
=> Text | The captcha service's API key. |
-> CaptchaId ctx | The captcha to check the answer of. |
-> m (Either (CaptchaError api r m) Text) | The captcha's solution. |
Attempt to retrieve the answer of the captcha.
:: (CaptchaRequest api ctx r m, CaptchaResponse api ctx, HasApiKey ctx Text, HasPollingInterval ctx (Maybe (Time Millisecond)), HasTimeoutDuration ctx (Maybe (Time Millisecond))) | |
=> ctx | Captcha to be solved. |
-> m (Either (CaptchaError api r m) Text) | The captcha's solution. |
Solves a captcha by submitting it with createTask
and then polling with getTask
until the answer is ready.
This will poll until the configured timeout duration is past. Its default value depends on the captcha service.
class CaptchaRequest api ctx r m where Source #
Different captcha services have different request formats. This abstracts over it and sends the correct HTTP request.
class CaptchaResponse api ctx where Source #
Different captcha services have different response formats. This abstracts over it and provides the captcha result.
newtype CaptchaId ctx Source #
Identifier for retrieving a captcha's answer.
Instances
Eq (CaptchaId ctx) Source # | |
Ord (CaptchaId ctx) Source # | |
Defined in Captcha.Internal.Monad.Class compare :: CaptchaId ctx -> CaptchaId ctx -> Ordering # (<) :: CaptchaId ctx -> CaptchaId ctx -> Bool # (<=) :: CaptchaId ctx -> CaptchaId ctx -> Bool # (>) :: CaptchaId ctx -> CaptchaId ctx -> Bool # (>=) :: CaptchaId ctx -> CaptchaId ctx -> Bool # | |
Show (CaptchaId ctx) Source # | |