Class: DeathByCaptcha::Client::Socket
- Inherits:
-
DeathByCaptcha::Client
- Object
- DeathByCaptcha::Client
- DeathByCaptcha::Client::Socket
- Defined in:
- lib/deathbycaptcha/client/socket.rb
Overview
Socket client for DeathByCaptcha API.
Constant Summary collapse
- PORTS =
(8123..8130).to_a
Instance Attribute Summary
Attributes inherited from DeathByCaptcha::Client
#hostname, #password, #polling, #timeout, #username
Instance Method Summary collapse
-
#captcha(captcha_id) ⇒ DeathByCaptcha::Captcha
Retrieve information from an uploaded captcha.
-
#report!(captcha_id) ⇒ DeathByCaptcha::Captcha
Report incorrectly solved captcha for refund.
-
#status ⇒ DeathByCaptcha::ServerStatus
Retrieve DeathByCaptcha server status.
-
#upload(options = {}) ⇒ DeathByCaptcha::Captcha
Upload a captcha to DeathByCaptcha.
-
#user ⇒ DeathByCaptcha::User
Retrieve your user information (which has the current credit balance).
Methods inherited from DeathByCaptcha::Client
create, #decode, #decode!, #initialize
Constructor Details
This class inherits a constructor from DeathByCaptcha::Client
Instance Method Details
#captcha(captcha_id) ⇒ DeathByCaptcha::Captcha
Retrieve information from an uploaded captcha.
15 16 17 18 |
# File 'lib/deathbycaptcha/client/socket.rb', line 15 def captcha(captcha_id) response = perform('captcha', captcha: captcha_id) DeathByCaptcha::Captcha.new(response) end |
#report!(captcha_id) ⇒ DeathByCaptcha::Captcha
Report incorrectly solved captcha for refund.
26 27 28 29 |
# File 'lib/deathbycaptcha/client/socket.rb', line 26 def report!(captcha_id) response = perform('report', captcha: captcha_id) DeathByCaptcha::Captcha.new(response) end |
#status ⇒ DeathByCaptcha::ServerStatus
Retrieve DeathByCaptcha server status. This method won’t use a Socket connection, it will use an HTTP connection.
45 46 47 |
# File 'lib/deathbycaptcha/client/socket.rb', line 45 def status http_client.status end |
#upload(options = {}) ⇒ DeathByCaptcha::Captcha
Upload a captcha to DeathByCaptcha.
This method will not return the solution. It’s only useful if you want to implement your own “decode” function.
56 57 58 59 60 61 62 63 |
# File 'lib/deathbycaptcha/client/socket.rb', line 56 def upload( = {}) if [:type] && [:type].to_i != 1 # Socket client implementation currently supports only text captchas. raise DeathByCaptcha::InvalidCaptcha end response = perform('upload', captcha: [:raw64]) DeathByCaptcha::Captcha.new(response) end |
#user ⇒ DeathByCaptcha::User
Retrieve your user information (which has the current credit balance)
35 36 37 38 |
# File 'lib/deathbycaptcha/client/socket.rb', line 35 def user response = perform('user') DeathByCaptcha::User.new(response) end |