Class: EmailHunter::LeadEnrichment
- Inherits:
-
Object
- Object
- EmailHunter::LeadEnrichment
- Defined in:
- lib/email_hunter/lead_enrichment.rb
Constant Summary collapse
- API_URL =
'https://api.hunter.io/v2/people/find'
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#linkedin ⇒ Object
readonly
Returns the value of attribute linkedin.
Instance Method Summary collapse
- #hunt ⇒ Object
-
#initialize(key, email: nil, linkedin: nil) ⇒ LeadEnrichment
constructor
A new instance of LeadEnrichment.
Constructor Details
#initialize(key, email: nil, linkedin: nil) ⇒ LeadEnrichment
Returns a new instance of LeadEnrichment.
13 14 15 16 17 18 19 |
# File 'lib/email_hunter/lead_enrichment.rb', line 13 def initialize(key, email: nil, linkedin: nil) @key = key @email = email @linkedin = linkedin raise ArgumentError, 'Either email or linkedin must be provided' if email.nil? && linkedin.nil? end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
11 12 13 |
# File 'lib/email_hunter/lead_enrichment.rb', line 11 def email @email end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/email_hunter/lead_enrichment.rb', line 11 def key @key end |
#linkedin ⇒ Object (readonly)
Returns the value of attribute linkedin.
11 12 13 |
# File 'lib/email_hunter/lead_enrichment.rb', line 11 def linkedin @linkedin end |
Instance Method Details
#hunt ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/email_hunter/lead_enrichment.rb', line 21 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 |