captcha-core-0.1.0.0: A package for integrating a variety of captcha solving services.
Copyright(c) 2022 Edward Yang
LicenseMIT
Safe HaskellNone
LanguageHaskell2010

Captcha.Internal.Monad.Class

Description

This module is for internal-use and does not follow pvp versioning policies.

Synopsis

Documentation

class Monad m => MonadCaptcha api r m where Source #

Abstracts over a captcha solving service.

Associated Types

type CaptchaError api r m Source #

An error specific to the captcha solving service.

Methods

createTask Source #

Arguments

:: 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 getTask.

Submit a task to be solved by the api service.

getTask Source #

Arguments

:: 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.

solve Source #

Arguments

:: (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.

Methods

request Source #

Arguments

:: ctx

The captcha to be solved.

-> Text

The url to send the request to.

-> m (Response ByteString) 

Send a request using the given captcha context.

class CaptchaResponse api ctx where Source #

Different captcha services have different response formats. This abstracts over it and provides the captcha result.

Methods

parseResult :: Value -> Maybe Value Source #

Parse the captcha result from the given json.

newtype CaptchaId ctx Source #

Identifier for retrieving a captcha's answer.

Constructors

CaptchaId 

Fields

Instances

Instances details
Eq (CaptchaId ctx) Source # 
Instance details

Defined in Captcha.Internal.Monad.Class

Methods

(==) :: CaptchaId ctx -> CaptchaId ctx -> Bool #

(/=) :: CaptchaId ctx -> CaptchaId ctx -> Bool #

Ord (CaptchaId ctx) Source # 
Instance details

Defined in Captcha.Internal.Monad.Class

Methods

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 #

max :: CaptchaId ctx -> CaptchaId ctx -> CaptchaId ctx #

min :: CaptchaId ctx -> CaptchaId ctx -> CaptchaId ctx #

Show (CaptchaId ctx) Source # 
Instance details

Defined in Captcha.Internal.Monad.Class

Methods

showsPrec :: Int -> CaptchaId ctx -> ShowS #

show :: CaptchaId ctx -> String #

showList :: [CaptchaId ctx] -> ShowS #