Class: PartyResearch::Adapters::Apollo

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

Overview

Apollo.io adapter — B2B people + organization data. Pulls structured
B2B firmographic + person info to complement Gemini's qualitative
Google-Search-grounded research.

Strategy for Customer (company) parties — two lookup paths in order of
precision:

  1. DOMAIN ENRICHMENT (POST /v1/organizations/enrich?domain=...)
    We scan the Customer's own emails plus its Contacts' emails for a
    non-personal domain (skip gmail.com, yahoo.com, etc.). If one is
    found, that's a high-confidence anchor — Apollo returns the exact
    company without fuzzy matching.

  2. NAME SEARCH (POST /v1/mixed_companies/search)
    Fallback when no domain is on file. Sends company name + state
    filter, then post-validates the match: if Apollo returns a
    company in a different state from ours, we lower the confidence
    and mark the rationale so reviewers immediately see it's a
    possible name collision rather than a true match.

Contact (person at Customer):
POST /v1/people/match — returns email (with confidence), address,
title note.

Homeowners are skipped — Apollo is B2B-only.

Endpoints intentionally NOT used:

  • /mixed_people/api_search — trial accounts get obfuscated data
  • reveal_phone_number — Apollo requires a webhook_url, async

Auth: X-Api-Key header. Credential at
Heatwave::Configuration.fetch(:apollo, :api_key).

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