Example #1
0
def retrieve_uber_3km_pricing(location_dict):
    """
    :type location_dict: dict
    :rtype: list[dict]
    """
    location = Location.from_serializable(location_dict)
    uber_client = build_uber_client_using_env_variables()
    uber_pricing_list = uber_client.estimate_3km_price(location)
    return [p.to_serializable() for p in uber_pricing_list]
Example #2
0
def retrieve_weather(location_dict):
    """
    :type location_dict: dict
    :rtype: list[dict]
    """
    location = Location.from_serializable(location_dict)
    client = build_open_weather_client_using_env_variables()
    forecasts = client.get_5_days_forecast(location)
    return [f.to_serializable() for f in forecasts]
Example #3
0
def retrieve_weather(event, context):
    """
    :type event: dict[str, str]
    :rtype: list[dict]
    """
    location = Location.from_serializable(read_payload(event))
    print("Resolving weather for: {}...".format(location))
    client = build_open_weather_client_using_env_variables()
    forecasts = client.get_5_days_forecast(location)
    print("Resolved {} forecasts for: {}!".format(len(forecasts), location))
    return build_response(payload=[f.to_serializable() for f in forecasts])
Example #4
0
def retrieve_uber_3km_pricing(event, context):
    """
    :type event: dict
    :rtype: list[dict]
    """
    location = Location.from_serializable(read_payload(event))
    print("Resolving Uber pricing for: {}...".format(location))
    uber_client = build_uber_client_using_env_variables()
    uber_pricing_list = uber_client.estimate_3km_price(location)
    print("Resolving {} Uber pricing for: {}!".format(len(uber_pricing_list),
                                                      location))
    return build_response([p.to_serializable() for p in uber_pricing_list])
 def test_model_should_recreate_object_from_serializable(self):
     serializable = self.location.to_serializable()
     recreated = Location.from_serializable(serializable)
     self.assertIsNotNone(recreated)
     self.assertEqual(self.location, recreated)