Class: EmailHunter::Discover
- Inherits:
-
Object
- Object
- EmailHunter::Discover
- Defined in:
- lib/email_hunter/discover.rb
Constant Summary collapse
- API_URL =
'https://api.hunter.io/v2/discover'
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #hunt ⇒ Object
-
#initialize(query, key, params = {}) ⇒ Discover
constructor
A new instance of Discover.
Constructor Details
#initialize(query, key, params = {}) ⇒ Discover
Returns a new instance of Discover.
12 13 14 15 16 |
# File 'lib/email_hunter/discover.rb', line 12 def initialize(query, key, params = {}) @query = query @key = key @params = params end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
10 11 12 |
# File 'lib/email_hunter/discover.rb', line 10 def key @key end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/email_hunter/discover.rb', line 10 def params @params end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
10 11 12 |
# File 'lib/email_hunter/discover.rb', line 10 def query @query end |
Instance Method Details
#hunt ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/email_hunter/discover.rb', line 18 def hunt response_data = fetch_discover_data return nil if response_data.empty? # Convert to OpenStruct for easy access result = OpenStruct.new(response_data) # Recursively convert nested hashes to OpenStructs convert_hash_to_struct(result, response_data) result end |