Class: PartyResearch::Adapters::GooglePlaces
- Defined in:
- app/services/party_research/adapters/google_places.rb
Overview
Google Places API (New) adapter — cheapest enrichment signal for a
Customer (company) where we have a name and ideally a city/state but
nothing else. Resolves "Bob Electric, Aurora IL" into a place record
with phone, formatted address, structured locality components, and a
website URL.
Why this exists: ~70% of the 7-day non-guest business leads come in
with only a name + state from CRM entry. Apollo's company search has
fuzzy-match noise (e.g. matched "Bob Dooley Electric Inc" for "Bob
Electric") and skews enterprise-y; Google Places indexes small/local
businesses far better and is essentially free at this volume.
Auth: X-Goog-Api-Key header. Reuses the project's existing
Heatwave::Configuration.fetch(:google, :api_key) (same key the
geocoder uses) — the Places API needs to be enabled on that project,
which it should be since Geocoding API works.
Skipped for homeowners and Contact parties — Places is a business
directory.
Constant Summary collapse
- ENDPOINT =
'https://places.googleapis.com/v1/places:searchText'- TIMEOUT_SECONDS =
15- FIELD_MASK =
%w[ places.displayName places.formattedAddress places.addressComponents places.nationalPhoneNumber places.internationalPhoneNumber places.websiteUri places.types places.businessStatus ].join(',').freeze
Constants inherited from Base
Base::ALL, Base::PERSONAL_EMAIL_DOMAINS
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .configured? ⇒ Boolean
-
.relevant_for?(party) ⇒ Boolean
Google Places is a business directory.
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
41 42 43 |
# File 'app/services/party_research/adapters/google_places.rb', line 41 def configured? Heatwave::Configuration.fetch(:google, :api_key).present? end |
.relevant_for?(party) ⇒ Boolean
Google Places is a business directory. Useful for Customer
companies; not useful for homeowners (Places doesn't index
residences) or Contacts (a Contact is a person, not a business).
48 49 50 51 52 53 |
# File 'app/services/party_research/adapters/google_places.rb', line 48 def relevant_for?(party) return false if party.try(:homeowner?) return false if party.is_a?(Contact) party.is_a?(Customer) end |
Instance Method Details
#findings_for ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/services/party_research/adapters/google_places.rb', line 56 def findings_for unless self.class.configured? raise ConfigurationError, 'Google api_key is not configured (Heatwave::Configuration[:google, :api_key])' end return [] if party.full_name.blank? return [] if party.try(:homeowner?) # Places is a business directory — Contact rows are people, skip. return [] if party.is_a?(Contact) place = lookup return [] unless place transform(place) end |