Class: EmailHunter::CompanyEnrichment
- Inherits:
-
Object
- Object
- EmailHunter::CompanyEnrichment
- Defined in:
- lib/email_hunter/company_enrichment.rb
Constant Summary collapse
- API_URL =
'https://api.hunter.io/v2/companies/find'
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #hunt ⇒ Object
-
#initialize(domain, key) ⇒ CompanyEnrichment
constructor
A new instance of CompanyEnrichment.
Constructor Details
#initialize(domain, key) ⇒ CompanyEnrichment
13 14 15 16 |
# File 'lib/email_hunter/company_enrichment.rb', line 13 def initialize(domain, key) @domain = domain @key = key end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
11 12 13 |
# File 'lib/email_hunter/company_enrichment.rb', line 11 def domain @domain end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/email_hunter/company_enrichment.rb', line 11 def key @key end |
Instance Method Details
#hunt ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/email_hunter/company_enrichment.rb', line 18 def hunt response_data = fetch_enrichment_data return nil if response_data.empty? # Convert nested data structure to OpenStruct data = response_data[:data] = response_data[:meta] result = OpenStruct.new( data: OpenStruct.new(data), meta: OpenStruct.new() ) # Recursively convert nested hashes to OpenStructs for deeper access convert_hash_to_struct(result.data, data) result end |