Class: EmailHunter::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/email_hunter/search.rb

Constant Summary collapse

API_URL =
'https://api.hunter.io/v2/domain-search'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain, key, params = {}) ⇒ Search

Returns a new instance of Search.



12
13
14
15
16
# File 'lib/email_hunter/search.rb', line 12

def initialize(domain, key, params = {})
  @domain = domain
  @key = key
  @params = params
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



10
11
12
# File 'lib/email_hunter/search.rb', line 10

def domain
  @domain
end

#keyObject (readonly)

Returns the value of attribute key.



10
11
12
# File 'lib/email_hunter/search.rb', line 10

def key
  @key
end

#paramsObject (readonly)

Returns the value of attribute params.



10
11
12
# File 'lib/email_hunter/search.rb', line 10

def params
  @params
end

Instance Method Details

#huntObject



18
19
20
21
22
23
# File 'lib/email_hunter/search.rb', line 18

def hunt
  response_data = fetch_search_data
  return nil if response_data.empty?

  Struct.new(*response_data.keys).new(*response_data.values)
end