Class: DeathByCaptcha::Client::HTTP
- Inherits:
-
DeathByCaptcha::Client
- Object
- DeathByCaptcha::Client
- DeathByCaptcha::Client::HTTP
- Defined in:
- lib/deathbycaptcha/client/http.rb
Overview
HTTP client for DeathByCaptcha API.
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.
12 13 14 15 |
# File 'lib/deathbycaptcha/client/http.rb', line 12 def captcha(captcha_id) response = perform("captcha/#{captcha_id}") DeathByCaptcha::Captcha.new(response) end |
#report!(captcha_id) ⇒ DeathByCaptcha::Captcha
Report incorrectly solved captcha for refund.
23 24 25 26 |
# File 'lib/deathbycaptcha/client/http.rb', line 23 def report!(captcha_id) response = perform("captcha/#{captcha_id}/report", :post) DeathByCaptcha::Captcha.new(response) end |
#status ⇒ DeathByCaptcha::ServerStatus
Retrieve DeathByCaptcha server status.
41 42 43 44 |
# File 'lib/deathbycaptcha/client/http.rb', line 41 def status response = perform('status') DeathByCaptcha::ServerStatus.new(response) 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.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/deathbycaptcha/client/http.rb', line 53 def upload( = {}) payload = {} payload[:captchafile] = "base64:#{[:raw64]}" payload[:type] = [:type] if [:type].to_i > 0 if [:type].to_i == 3 = load_captcha([:banner]) raise DeathByCaptcha::InvalidCaptcha if .to_s.empty? payload[:banner] = "base64:#{}" payload[:banner_text] = [:banner_text].to_s elsif [:type].to_i == 4 payload = { type: 4, token_params: [:token_params].to_json, } end response = perform('captcha', :post_multipart, payload) DeathByCaptcha::Captcha.new(response) end |
#user ⇒ DeathByCaptcha::User
Retrieve your user information (which has the current credit balance)
32 33 34 35 |
# File 'lib/deathbycaptcha/client/http.rb', line 32 def user response = perform('user') DeathByCaptcha::User.new(response) end |