uber / uber-ios-sdk

Uber iOS SDK (beta)
https://developer.uber.com/docs
MIT License
376 stars 125 forks source link

Enable `button.loadRideInformation()` to display estimates based on cheapest product #99

Open chardane opened 8 years ago

chardane commented 8 years ago

Right now, this is how you would get a time estimate based on cheapest product and pickup location:

let button = RideRequestButton()
let pickupLocation = CLLocation(latitude: 37.775159, longitude: -122.417907)

let builder = RideParametersBuilder().setPickupLocation(pickupLocation)

let ridesClient = RidesClient()
// get cheapest product id separately
ridesClient.fetchCheapestProduct(pickupLocation: pickupLocation, completion: {
    product, response in
    if let productID = product?.productID {
        builder.setProductID(productID)
        button.rideParameters = builder.build()
        button.loadRideInformation()
    }
})

I would love for this to be boiled down to:

let button = RideRequestButton()
let pickupLocation = CLLocation(latitude: 37.775159, longitude: -122.417907)

let builder = RideParametersBuilder().setPickupLocation(pickupLocation)

button.rideParameters = builder.build()
button.loadRideInformation() //cheapest product ID is used magic whoa

So we can fetch the cheapest product ID automatically when we call loadRideInformation() and there is a pickupLocation set. 😄 🎉

jbrophy17 commented 8 years ago

I agree :)