Example #1
0
def get_time_estimate():

    credentials = import_oauth2_credentials()
    api_client = create_uber_client(credentials)
    time = estimate_ride(api_client)

    return time
Example #2
0
def get_ride_details():

    credentials = import_oauth2_credentials()
    api_client = create_uber_client(credentials)

    ride_details = request_ride(api_client)

    return ride_details
def on_button():
    """Run the example.

    Create an UberRidesClient from OAuth 2.0 Credentials, update a sandbox
    product's surge, request and complete a ride.
    """
    credentials = import_oauth2_credentials()
    api_client = create_uber_client(credentials)

    # ride request with upfront pricing flow
    api_client.cancel_current_ride()

    verbose = True

    print("Frage Koordinaten ab...")

    start = get_latlng(START_NAME)
    end = get_latlng(END_NAME)

    # Manually set coordinates
    #UberLocation = namedtuple('UberLocation', 'latitude longitude')
    #start = UberLocation(48, 11)
    #end = UberLocation(48, 10)

    if start is None:
        print("Bitte gültige Startadresse eingeben")
        return
    if end is None:
        print("Bitte gültige Endadresse eingeben")

    print("Start (%s, %s)" % (start.latitude, start.longitude))
    print("Ende (%s, %s)" % (end.latitude, end.longitude))

    #Request a ride with upfront pricing product
    paragraph_print("Anfrage einer Fahrt...\nVon: %s\nNach: %s" % (start, end))
    ride_id, pickup_estimate, fare = request_ufp_ride(api_client,
                                                      start.latitude,
                                                      start.longitude,
                                                      end.latitude,
                                                      end.longitude)

    paragraph_print("Akzeptiere Fahrt...")
    update_ride(api_client, 'accepted', ride_id, verbose=verbose)

    paragraph_print("Warten bis Fahrer da ist...")
    show_ui(pickup_estimate, fare)

    paragraph_print("Einsteigen und losfahren...")
    update_ride(api_client, 'in_progress', ride_id, verbose=verbose)
    time.sleep(5)

    paragraph_print("Am Ziel angekommen...")
    update_ride(api_client, 'completed', ride_id, verbose=verbose)
Example #4
0
        ride_id (str)
            Unique ride identifier.
    """
    try:
        ride_details = api_client.get_ride_details(ride_id)

    except (ClientError, ServerError) as error:
        fail_print(error)

    else:
        success_print(ride_details.json)

if __name__ == '__main__':
    
    credentials = import_oauth2_credentials()
    api_client = create_uber_client(credentials)

    paragraph_print("Ride estimates.")
    estimate_ride(api_client)

    paragraph_print("Request a ride.")
    ride_id = request_ride(api_client)

    paragraph_print("Update ride status to accepted.")
    update_ride(api_client, 'accepted', ride_id)

    paragraph_print("Updated ride details.")
    get_ride_details(api_client, ride_id)

    paragraph_print("Update ride status to completed.")
    update_ride(api_client, 'in_progress', ride_id)
    except (ClientError, ServerError) as error:
        fail_print(error)

    else:
        success_print(ride_details.json)


if __name__ == '__main__':
    """Run the example.

    Create an UberRidesClient from OAuth 2.0 Credentials, update a sandbox
    product's surge, request and complete a ride.
    """
    credentials = import_oauth2_credentials()
    api_client = create_uber_client(credentials)

    # ride request with upfront pricing flow

    paragraph_print("Request a ride with upfront pricing product.")
    ride_id = request_ufp_ride(api_client)

    paragraph_print("Update ride status to accepted.")
    update_ride(api_client, 'accepted', ride_id)

    paragraph_print("Updated ride details.")
    get_ride_details(api_client, ride_id)
    update_ride(api_client, 'in_progress', ride_id)

    paragraph_print("Updated ride details.")
    get_ride_details(api_client, ride_id)