Class: PartyResearch::Adapters::GooglePlaces
- Defined in:
- app/services/party_research/adapters/google_places.rb
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 |