Пример #1
0
    def get(self, request, latlong, format=None):
        """Return a list of all places nearby our coordinates."""
        # Define data.
        places_api_key = os.environ['RYR_COLLECTOR_GOOGLE_PLACES_API_KEY']

        # Prepare client.
        gmap = GoogleCollector()
        gmap.authenticate(api_key=places_api_key)

        # Retrieve nearby places.
        places_nearby = gmap.search_places_nearby(latlong)
        return Response(places_nearby)
Пример #2
0
def integration_test_full_google_yelp_workflow_with_generic():
    """"""
    places_api_key = os.environ['RYR_COLLECTOR_GOOGLE_PLACES_API_KEY']
    yelp_api_key = os.environ['RYR_COLLECTOR_YELP_API_KEY']

    # Simulate a click Epoch Coffee Shop - Northloop on the map.
    epoch_latlong = (30.3186037, -97.72454019999999)
    epoch_latlong = (30.319136, -97.724303)
    # Retrieve the places nearby the location clicked on the map.
    gmap = GoogleCollector()
    gmap.authenticate(api_key=places_api_key)
    places_nearby = gmap.search_places_nearby(epoch_latlong)

    # Act like a user chose Epoch Coffee Shop - Northloop in the result list.
    epoch_search_summary = gmap.retrieve_search_summary(1)
    print(epoch_search_summary)

    # Lookup the place on Google Maps.
    google = CollectorClient('google', api_key=places_api_key)
    google.authenticate()
    google_place_details = google.lookup_place(epoch_search_summary.id)
    gb = google.to_business_info()
    print('*** Google:')
    print(gb)

    # Lookup the place on Yelp.
    yelp = CollectorClient('yelp', api_key=yelp_api_key, weight=10)
    yelp.authenticate()
    yelp_place_details = yelp.lookup_place(None, epoch_search_summary.name,
                                           epoch_search_summary.address)
    yb = yelp.to_business_info()
    print('*** Yelp:')
    print(yb)

    # Merge the results.
    print('*** Merged:')
    print(gb.merge(yb))