Class: EmailHunter::CombinedEnrichment
- Inherits:
-
Object
- Object
- EmailHunter::CombinedEnrichment
- Defined in:
- lib/email_hunter/combined_enrichment.rb
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) ⇒ CombinedEnrichment
constructor
A new instance of CombinedEnrichment.
Constructor Details
#initialize(key, email: nil, linkedin: nil) ⇒ CombinedEnrichment
Returns a new instance of CombinedEnrichment.
11 12 13 14 15 16 17 |
# File 'lib/email_hunter/combined_enrichment.rb', line 11 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.
9 10 11 |
# File 'lib/email_hunter/combined_enrichment.rb', line 9 def email @email end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
9 10 11 |
# File 'lib/email_hunter/combined_enrichment.rb', line 9 def key @key end |
#linkedin ⇒ Object (readonly)
Returns the value of attribute linkedin.
9 10 11 |
# File 'lib/email_hunter/combined_enrichment.rb', line 9 def linkedin @linkedin end |
Instance Method Details
#hunt ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/email_hunter/combined_enrichment.rb', line 19 def hunt # First get lead enrichment data lead_data = LeadEnrichment.new(key, email: email, linkedin: linkedin).hunt return nil if lead_data.nil? # Extract domain from employment if available domain = lead_data.data.employment&.domain return lead_data if domain.nil? # Get company enrichment data company_data = CompanyEnrichment.new(domain, key).hunt # Combine the data OpenStruct.new( lead: lead_data, company: company_data, meta: OpenStruct.new( email: email, linkedin: linkedin, domain: domain ) ) rescue StandardError => e # If company enrichment fails, just return lead data OpenStruct.new( lead: lead_data, company: nil, meta: OpenStruct.new( email: email, linkedin: linkedin, error: e. ) ) end |