Module: RedditKit::Client::Captcha
- Included in:
- RedditKit::Client
- Defined in:
- lib/redditkit/client/captcha.rb
Overview
Methods for retrieving and submitting CAPTCHAs.
Instance Method Summary collapse
-
#captcha_url(captcha_identifier) ⇒ String
Returns the URL for a CAPTCHA image with a given identifier.
-
#needs_captcha? ⇒ Boolean
Whether the current user will need to answer a CAPTCHA for methods which may require one.
-
#new_captcha_identifier ⇒ String
Returns a new CATPCHA identifier.
Instance Method Details
#captcha_url(captcha_identifier) ⇒ String
Returns the URL for a CAPTCHA image with a given identifier.
30 31 32 |
# File 'lib/redditkit/client/captcha.rb', line 30 def captcha_url(captcha_identifier) "http://reddit.com/captcha/#{captcha_identifier}.png" end |
#needs_captcha? ⇒ Boolean
Whether the current user will need to answer a CAPTCHA for methods which may require one.
10 11 12 13 14 15 |
# File 'lib/redditkit/client/captcha.rb', line 10 def needs_captcha? response = get 'api/needs_captcha.json' needs_captcha = response[:body] needs_captcha.to_s == 'true' end |
#new_captcha_identifier ⇒ String
Returns a new CATPCHA identifier.
20 21 22 23 24 25 |
# File 'lib/redditkit/client/captcha.rb', line 20 def new_captcha_identifier response = post 'api/new_captcha', :api_type => :json data = response[:body][:json][:data] data[:iden] end |