Class: ActsAsTextcaptcha::TextcaptchaApi

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_textcaptcha/textcaptcha_api.rb

Constant Summary collapse

BASE_URL =
"http://textcaptcha.com"

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, api_endpoint: nil, raise_errors: false) ⇒ TextcaptchaApi

Returns a new instance of TextcaptchaApi.



9
10
11
12
13
14
15
# File 'lib/acts_as_textcaptcha/textcaptcha_api.rb', line 9

def initialize(api_key: nil, api_endpoint: nil, raise_errors: false)
  self.uri = URI(api_endpoint || "#{BASE_URL}/#{api_key}.json")

  self.raise_errors = raise_errors || false
rescue URI::InvalidURIError => e
  raise ApiKeyError.new(api_key, e)
end

Instance Method Details

#fetchObject



17
18
19
# File 'lib/acts_as_textcaptcha/textcaptcha_api.rb', line 17

def fetch
  parse(get.to_s)
end