Esempio n. 1
0
    def __real_update(self):
        from lyft_rides.client import LyftRidesClient
        client = LyftRidesClient(self._session)

        self.products = {}

        products_response = client.get_ride_types(self.start_latitude,
                                                  self.start_longitude)

        products = products_response.json.get('ride_types')

        for product in products:
            self.products[product['ride_type']] = product

        if self.end_latitude is not None and self.end_longitude is not None:
            price_response = client.get_cost_estimates(self.start_latitude,
                                                       self.start_longitude,
                                                       self.end_latitude,
                                                       self.end_longitude)

            prices = price_response.json.get('cost_estimates', [])

            for price in prices:
                product = self.products[price['ride_type']]
                if price.get("is_valid_estimate"):
                    product['estimate'] = price

        eta_response = client.get_pickup_time_estimates(
            self.start_latitude, self.start_longitude)

        etas = eta_response.json.get('eta_estimates')

        for eta in etas:
            if eta.get("is_valid_estimate"):
                self.products[eta['ride_type']]['eta'] = eta
Esempio n. 2
0
    def fetch_data(self):
        """Get the latest product info and estimates from the Lyft API."""
        from lyft_rides.client import LyftRidesClient
        client = LyftRidesClient(self._session)

        self.products = {}

        products_response = client.get_ride_types(
            self.start_latitude, self.start_longitude)

        products = products_response.json.get('ride_types')

        for product in products:
            self.products[product['ride_type']] = product

        if self.end_latitude is not None and self.end_longitude is not None:
            price_response = client.get_cost_estimates(
                self.start_latitude, self.start_longitude,
                self.end_latitude, self.end_longitude)

            prices = price_response.json.get('cost_estimates', [])

            for price in prices:
                product = self.products[price['ride_type']]
                if price.get("is_valid_estimate"):
                    product['estimate'] = price

        eta_response = client.get_pickup_time_estimates(
            self.start_latitude, self.start_longitude)

        etas = eta_response.json.get('eta_estimates')

        for eta in etas:
            if eta.get("is_valid_estimate"):
                self.products[eta['ride_type']]['eta'] = eta
Esempio n. 3
0
def lyft():
    global client
    global credentials
    session = auth_flow.get_session(request.url)
    client = LyftRidesClient(session)
    credentials = session.oauth2credential
    response = client.get_ride_types(lyft_lat_start, lyft_lng_start)
    ride_types = response.json.get('ride_types')
    options = "Options: \n"
    print("Options: ")
    for x in range(0, len(ride_types)):
        print(ride_types[x]["ride_type"])
        options = options + "--" + ride_types[x]["ride_type"] + "--" + "\n"
    return options
Esempio n. 4
0
    def fetch_data(self):
        """Get the latest product info and estimates from the Lyft API."""
        from lyft_rides.client import LyftRidesClient

        client = LyftRidesClient(self._session)

        self.products = {}

        products_response = client.get_ride_types(
            self.start_latitude, self.start_longitude
        )

        products = products_response.json.get("ride_types")

        for product in products:
            self.products[product["ride_type"]] = product

        if self.end_latitude is not None and self.end_longitude is not None:
            price_response = client.get_cost_estimates(
                self.start_latitude,
                self.start_longitude,
                self.end_latitude,
                self.end_longitude,
            )

            prices = price_response.json.get("cost_estimates", [])

            for price in prices:
                product = self.products[price["ride_type"]]
                if price.get("is_valid_estimate"):
                    product["estimate"] = price

        eta_response = client.get_pickup_time_estimates(
            self.start_latitude, self.start_longitude
        )

        etas = eta_response.json.get("eta_estimates")

        for eta in etas:
            if eta.get("is_valid_estimate"):
                self.products[eta["ride_type"]]["eta"] = eta
Esempio n. 5
0
from lyft_rides.auth import ClientCredentialGrant
from lyft_rides.session import Session
from lyft_rides.client import LyftRidesClient

auth_flow = ClientCredentialGrant(
    'yM-_iRPCi4-f',
    'PyRA3zG4llCje6ZoBBqdpLr5ITTuu3qR',
    ['public', 'profile', 'rides.read', 'rides.request'],
)
session = auth_flow.get_session()
client = LyftRidesClient(session)
response = client.get_cost_estimates(start_latitude=42.299709,
                                     start_longitude=-71.351121,
                                     end_latitude=42.288493,
                                     end_longitude=-71.359711,
                                     ride_type='lyft_line')
print response.json
response = client.get_ride_types(42.299709, -71.351121)
ride_types = response.json.get('ride_types')
print ride_types