class Phishtank::Scanner

Attributes

format[R]

Public Class Methods

new(api_key) click to toggle source
# File lib/phishtank/scanner.rb, line 5
def initialize(api_key)
  @api_key = api_key
  @format = 'json'
end

Public Instance Methods

scan(url) click to toggle source
# File lib/phishtank/scanner.rb, line 10
def scan(url)
  # Init parser
  client = Phishtank::Raw.new(@api_key, @format)
  response = JSON.parse(client.check_url(url), :symbolize_names => true)

  # Validate server response
  if response[:meta][:status] == 'success'
    # Request Succeeded
    return Phishtank::Parser.new(response)
  else
    raise Exception.new('Bad Response from Phishtank.')
  end
end