module ReCaptcha::API
Public Instance Methods
post(path, params, options: {}, end_point: api_endpoint)
click to toggle source
# File lib/re_captcha/api.rb, line 5 def post(path, params, options: {}, end_point: api_endpoint) http_request do uri = URI(end_point).merge(path).to_s resource = RestClient::Resource.new(uri, options.merge(default_options)) response = resource.post params.merge(default_params) JSON.parse response end end
Private Instance Methods
default_options()
click to toggle source
# File lib/re_captcha/api.rb, line 20 def default_options { read_timeout: 3, open_timeout: 3 } end
default_params()
click to toggle source
# File lib/re_captcha/api.rb, line 16 def default_params { secret: private_key } end
http_request(&block)
click to toggle source
# File lib/re_captcha/api.rb, line 24 def http_request(&block) block.call rescue RestClient::RequestTimeout, RestClient::ExceptionWithResponse, RestClient::RequestFailed { 'success' => !deny_on_error } end