Skip to content

Commit 732fca4

Browse files
committed
added callbackUrl
1 parent 69c81a0 commit 732fca4

File tree

6 files changed

+39
-5
lines changed

6 files changed

+39
-5
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ Check our other projects here - `RedPandaDev group <https://red-panda-dev.xyz/bl
3838
:maxdepth: 2
3939
:caption: Additional modules
4040

41+
modules/core/info.rst
4142
modules/enum/info.rst
4243
modules/serializer/info.rst

docs/modules/core/info.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Core
2+
====
3+
4+
To import this module:
5+
6+
.. code-block:: python
7+
8+
from python3_anticaptcha.core import base
9+
10+
11+
.. autoclass:: core.base.CaptchaParams
12+
:members:

src/python3_anticaptcha/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
66

7-
callbackUrl: str = ""
8-
97

108
# Connection retry generator
119
def attempts_generator(amount: int = 5) -> Generator:

src/python3_anticaptcha/core/base.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class CaptchaParams(SIOContextManager, AIOContextManager):
1111
"""
12-
Basic Captcha solving class
12+
Basic Captcha params class
1313
1414
Args:
1515
api_key: Capsolver API key
@@ -29,6 +29,20 @@ def __init__(self, api_key: str, sleep_time: int = 15, *args, **kwargs):
2929

3030
self._captcha_handling_instrument = CaptchaInstrument()
3131

32+
def set_callback_url(self, callbackUrl: str) -> None:
33+
"""
34+
Method for `callbackUrl` param set.
35+
36+
Args:
37+
callbackUrl: Optional web address where we can send the results of captcha task processing.
38+
Contents are sent by AJAX POST request and are identical
39+
to the contents of getTaskResult method.
40+
41+
Notes:
42+
https://anti-captcha.com/apidoc/methods/createTask
43+
"""
44+
self.create_task_payload.callbackUrl = callbackUrl
45+
3246
def captcha_handler(self, **additional_params) -> dict:
3347
"""
3448
Synchronous method for captcha solving

src/python3_anticaptcha/core/serializer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from .enum import ResponseStatusEnm
66
from .const import APP_KEY
7-
from ..config import callbackUrl
87

98

109
class MyBaseModel(Struct):
@@ -24,7 +23,7 @@ class BaseAPIRequestSer(MyBaseModel):
2423
class CreateTaskBaseSer(BaseAPIRequestSer):
2524
task: Dict = {}
2625
softId: Literal[APP_KEY] = APP_KEY
27-
callbackUrl: str = callbackUrl
26+
callbackUrl: str = ""
2827

2928

3029
class BaseAPIResponseSer(MyBaseModel):

tests/test_core.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ async def test_aio_create_base_context(self):
4545
) as instance:
4646
pass
4747

48+
def test_set_callback_url(self):
49+
callback_string = self.get_random_string()
50+
instance = CaptchaParams(
51+
api_key=self.get_random_string(32),
52+
sleep_time=self.sleep_time,
53+
)
54+
instance.set_callback_url(callbackUrl=callback_string)
55+
56+
assert instance.create_task_payload.callbackUrl == callback_string
57+
4858

4959
class TestConfig(BaseTest):
5060
def test_attempts_generator(self):

0 commit comments

Comments
 (0)