Class: PartyResearch::Adapters::Apollo

Inherits:
Base
  • Object
show all
Defined in:
app/services/party_research/adapters/apollo.rb

Constant Summary collapse

BASE_URL =
'https://api.apollo.io/api/v1'
TIMEOUT_SECONDS =
20
PERSONAL_EMAIL_DOMAINS =
%w[
  gmail.com yahoo.com hotmail.com outlook.com aol.com icloud.com
  me.com mac.com live.com msn.com proton.me protonmail.com
  ymail.com rocketmail.com att.net comcast.net verizon.net
  sbcglobal.net cox.net charter.net bellsouth.net juno.net
  earthlink.net optonline.net mindspring.net netzero.net
].to_set.freeze

Constants inherited from Base

Base::ALL

Instance Attribute Summary

Attributes inherited from Base

#party, #raw_findings

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

adapter_name, arbiter?, #finding, #initialize, lookup, registered

Constructor Details

This class inherits a constructor from PartyResearch::Adapters::Base

Class Method Details

.configured?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'app/services/party_research/adapters/apollo.rb', line 50

def configured?
  Heatwave::Configuration.fetch(:apollo, :api_key).present?
end

.relevant_for?(party) ⇒ Boolean

Apollo is B2B-only. Useful for Customer companies and Contacts;
not useful for homeowners (Apollo has no consumer index).

Returns:

  • (Boolean)


56
57
58
59
60
# File 'app/services/party_research/adapters/apollo.rb', line 56

def relevant_for?(party)
  return false if party.try(:homeowner?)

  party.is_a?(Customer) || party.is_a?(Contact)
end

Instance Method Details

#findings_forObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/services/party_research/adapters/apollo.rb', line 63

def findings_for
  unless self.class.configured?
    raise ConfigurationError, 'Apollo api_key is not configured in Heatwave::Configuration'
  end

  return [] if party.full_name.blank?
  return [] if party.try(:homeowner?)

  case party
  when Contact then enrich_contact
  when Customer then enrich_company
  else []
  end
end