Class: Capsolver::Client
- Inherits:
-
Object
- Object
- Capsolver::Client
- Defined in:
- lib/capsolver/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#request_url ⇒ Object
readonly
Returns the value of attribute request_url.
-
#sleep_time ⇒ Object
readonly
Returns the value of attribute sleep_time.
Instance Method Summary collapse
- #aws_waf(captcha_type, payload = {}) ⇒ Object
- #balance ⇒ Object (also: #get_balance, #aio_get_balance)
- #cloudflare(payload = {}) ⇒ Object
-
#create_task(task_payload) ⇒ Object
Low-level control delegates.
- #datadome_slider(payload = {}) ⇒ Object
- #feedback_task(task_id, result_payload) ⇒ Object
- #friendly_captcha(payload = {}) ⇒ Object
- #gee_test(payload = {}) ⇒ Object
- #get_task_result(task_id) ⇒ Object
- #get_token(task_payload) ⇒ Object
- #image_to_text(payload = {}) ⇒ Object
-
#initialize(api_key: nil, sleep_time: nil, request_url: nil) ⇒ Client
constructor
A new instance of Client.
- #mt_captcha(captcha_type, payload = {}) ⇒ Object
- #recaptcha(captcha_type, payload = {}) ⇒ Object
- #vision_engine(payload = {}) ⇒ Object
- #yandex_captcha(payload = {}) ⇒ Object
Constructor Details
#initialize(api_key: nil, sleep_time: nil, request_url: nil) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 |
# File 'lib/capsolver/client.rb', line 7 def initialize(api_key: nil, sleep_time: nil, request_url: nil) @api_key = api_key || Capsolver.configuration.api_key raise ArgumentError, "api_key is required (either configure it globally via Capsolver.configure or pass it to initialize)" if @api_key.nil? @sleep_time = sleep_time || Capsolver.configuration.sleep_time @request_url = request_url || Capsolver.configuration.request_url end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/capsolver/client.rb', line 5 def api_key @api_key end |
#request_url ⇒ Object (readonly)
Returns the value of attribute request_url.
5 6 7 |
# File 'lib/capsolver/client.rb', line 5 def request_url @request_url end |
#sleep_time ⇒ Object (readonly)
Returns the value of attribute sleep_time.
5 6 7 |
# File 'lib/capsolver/client.rb', line 5 def sleep_time @sleep_time end |
Instance Method Details
#aws_waf(captcha_type, payload = {}) ⇒ Object
50 51 52 |
# File 'lib/capsolver/client.rb', line 50 def aws_waf(captcha_type, payload = {}) AwsWaf.new(api_key: @api_key, captcha_type: captcha_type, sleep_time: @sleep_time, request_url: @request_url).captcha_handler(payload) end |
#balance ⇒ Object Also known as: get_balance, aio_get_balance
15 16 17 |
# File 'lib/capsolver/client.rb', line 15 def balance control.get_balance end |
#cloudflare(payload = {}) ⇒ Object
22 23 24 |
# File 'lib/capsolver/client.rb', line 22 def cloudflare(payload = {}) Cloudflare.new(api_key: @api_key, sleep_time: @sleep_time, request_url: @request_url).captcha_handler(payload) end |
#create_task(task_payload) ⇒ Object
Low-level control delegates
63 64 65 |
# File 'lib/capsolver/client.rb', line 63 def create_task(task_payload) control.create_task(task_payload) end |
#datadome_slider(payload = {}) ⇒ Object
34 35 36 |
# File 'lib/capsolver/client.rb', line 34 def (payload = {}) DatadomeSlider.new(api_key: @api_key, sleep_time: @sleep_time, request_url: @request_url).captcha_handler(payload) end |
#feedback_task(task_id, result_payload) ⇒ Object
75 76 77 |
# File 'lib/capsolver/client.rb', line 75 def feedback_task(task_id, result_payload) control.feedback_task(task_id, result_payload) end |
#friendly_captcha(payload = {}) ⇒ Object
38 39 40 |
# File 'lib/capsolver/client.rb', line 38 def friendly_captcha(payload = {}) FriendlyCaptcha.new(api_key: @api_key, sleep_time: @sleep_time, request_url: @request_url).captcha_handler(payload) end |
#gee_test(payload = {}) ⇒ Object
42 43 44 |
# File 'lib/capsolver/client.rb', line 42 def gee_test(payload = {}) GeeTest.new(api_key: @api_key, sleep_time: @sleep_time, request_url: @request_url).captcha_handler(payload) end |
#get_task_result(task_id) ⇒ Object
67 68 69 |
# File 'lib/capsolver/client.rb', line 67 def get_task_result(task_id) control.get_task_result(task_id) end |
#get_token(task_payload) ⇒ Object
71 72 73 |
# File 'lib/capsolver/client.rb', line 71 def get_token(task_payload) control.get_token(task_payload) end |
#image_to_text(payload = {}) ⇒ Object
30 31 32 |
# File 'lib/capsolver/client.rb', line 30 def image_to_text(payload = {}) ImageToText.new(api_key: @api_key, sleep_time: @sleep_time, request_url: @request_url).captcha_handler(payload) end |
#mt_captcha(captcha_type, payload = {}) ⇒ Object
46 47 48 |
# File 'lib/capsolver/client.rb', line 46 def mt_captcha(captcha_type, payload = {}) MtCaptcha.new(api_key: @api_key, captcha_type: captcha_type, sleep_time: @sleep_time, request_url: @request_url).captcha_handler(payload) end |
#recaptcha(captcha_type, payload = {}) ⇒ Object
26 27 28 |
# File 'lib/capsolver/client.rb', line 26 def recaptcha(captcha_type, payload = {}) ReCaptcha.new(api_key: @api_key, captcha_type: captcha_type, sleep_time: @sleep_time, request_url: @request_url).captcha_handler(payload) end |
#vision_engine(payload = {}) ⇒ Object
58 59 60 |
# File 'lib/capsolver/client.rb', line 58 def vision_engine(payload = {}) VisionEngine.new(api_key: @api_key, sleep_time: @sleep_time, request_url: @request_url).captcha_handler(payload) end |
#yandex_captcha(payload = {}) ⇒ Object
54 55 56 |
# File 'lib/capsolver/client.rb', line 54 def yandex_captcha(payload = {}) YandexCaptcha.new(api_key: @api_key, sleep_time: @sleep_time, request_url: @request_url).captcha_handler(payload) end |