From ca278061d3d6ba64dffa15f1bb58f2b104856fc6 Mon Sep 17 00:00:00 2001 From: PBadicean Date: Thu, 25 May 2023 18:17:31 +0300 Subject: [PATCH] fix method solve --- README.md | 4 ++-- lib/api_2captcha/client.rb | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bad7154..2941f55 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,13 @@ To use the api2captcha gem, you'll need to import the module and create a Client ```ruby require 'api-2captcha' -client = Api2Captcha.new(api_key: "YOUR_API_KEY") +client = Api2Captcha.new("YOUR_API_KEY") ``` There are a few options that can be configured using the Client instance: ```ruby -client.apy_key = "YOUR_API_KEY" +client.api_key = "YOUR_API_KEY" ``` ### Client instance options diff --git a/lib/api_2captcha/client.rb b/lib/api_2captcha/client.rb index 205d3ed..746a4b0 100644 --- a/lib/api_2captcha/client.rb +++ b/lib/api_2captcha/client.rb @@ -31,10 +31,16 @@ def solve(method, params = {}, file_path = nil, return_id: false) params["key"] = @api_key params["soft_id"] = @soft_id params["json"] = 1 - + if @callback + params["pingback"] = @callback + return_id = true + else + return_id + end complete_params = get_params(params) captcha_id = send_request(complete_params) - return_id ? get_result(captcha_id) : captcha_id + + return_id ? captcha_id : get_result(captcha_id) end def send(*args) @@ -184,7 +190,6 @@ def send_request(params) req.content_type = 'application/json' req.body = params.to_json captcha_id = get_captcha_id(make_request(uri, req)) - handle_response(captcha_id) end def get_params(params)