'Get the latest product info and estimates from the Uber API.'

@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):

    from uber_rides.client import UberRidesClient
    client = UberRidesClient(self._session)
    self.products = {}
    products_response = client.get_products(self.start_latitude, self.start_longitude)
    products = products_response.json.get('products')
    for product in products:
        self.products[product['product_id']] = product
    if ((self.end_latitude is not None) and (self.end_longitude is not None)):
        price_response = client.get_price_estimates(self.start_latitude, self.start_longitude, self.end_latitude, self.end_longitude)
        prices = price_response.json.get('prices', [])
        for price in prices:
            product = self.products[price['product_id']]
            product['duration'] = price.get('duration', '0')
            product['distance'] = price.get('distance', '0')
            price_details = product.get('price_details')
            if (product.get('price_details') is None):
                price_details = {}
            price_details['estimate'] = price.get('estimate', '0')
            price_details['high_estimate'] = price.get('high_estimate', '0')
            price_details['low_estimate'] = price.get('low_estimate', '0')
            price_details['currency_code'] = price.get('currency_code')
            surge_multiplier = price.get('surge_multiplier', '0')
            price_details['surge_multiplier'] = surge_multiplier
            product['price_details'] = price_details
    estimate_response = client.get_pickup_time_estimates(self.start_latitude, self.start_longitude)
    estimates = estimate_response.json.get('times')
    for estimate in estimates:
        self.products[estimate['product_id']]['time_estimate_seconds'] = estimate.get('estimate', '0')
