Module: Auth::Centric::Captcha::Delete

Included in:
SecurityCaptcha
Defined in:
lib/auth/centric/captcha/delete.rb

Instance Method Summary collapse

Instance Method Details

#delete_captcha(id) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/auth/centric/captcha/delete.rb', line 7

def delete_captcha(id)
  return true unless enabled?

  http = HTTP
           .timeout(timeout_seconds)
           .headers(apikey:)
           .delete(delete_path(id))

  case http.status
    when 204
      true
    else
      raise Error, "#{http.status}: #{http.body}"
  end
rescue HTTP::TimeoutError
  false
end

#delete_path(id) ⇒ Object



25
26
27
# File 'lib/auth/centric/captcha/delete.rb', line 25

def delete_path(id)
  [host, "api/v1/security_captchas/#{id}"].join('/')
end