uber / rides-java-sdk

Uber Rides Java SDK (beta)
https://developer.uber.com/docs
MIT License
104 stars 57 forks source link

JsonDataException in GET products #32

Closed MarianoTucat closed 7 years ago

MarianoTucat commented 7 years ago

I'm getting the following exception:

com.squareup.moshi.JsonDataException: Expected a double but was NULL at path $.products[4].price_details.minimum

When doing a GET on, for example, https://sandbox-api.uber.com/v1.2/products?latitude=41.87811&longitude=-87.6298 and also in prod url https://api.uber.com/v1.2/products\?latitude\=41.87811\&longitude\=-87.6298

Seems to be a parsing error, PriceDetail has minimum field as float and the returned JSON contains a null value:

"price_details": {
        "service_fees": [],
        "cost_per_minute": 0.33,
        "distance_unit": "mile",
        "minimum": null,
        "cost_per_distance": 2.25,
        "base": 3.25,
        "cancellation_fee": 5,
        "currency_code": "USD"
      },

This is using 0.6.0 version of the SDK

tyvsmith commented 7 years ago

Hey @MarianoTucat, thanks for reporting.

Please give us an indicator of how you're using the SDK. We don't support PriceDetails model in our base Product model currently. Is this a custom implementation?

MarianoTucat commented 7 years ago

Sorry, my bad, I did added priceDetail field to Product class to be able to get that info returned from the API that was being lost and required extra calls.

I have forked this repo a while ago, made that change and forgot about it.

Somehow, this issue appeared after I rebased the fork from 0.5.2 to 0.6.0, so, is it possible that something changed in the response of the API and started getting null for minimum values for PriceDetail? or maybe it was just a coincidence. Anyway, it is either an API issue or an expected value, but not an issue of this SDK implementation, sorry again about this.

itstexter commented 7 years ago

Hey @MarianoTucat,

When the SDK updated to 0.6.0 we moved all our endpoints to hit API version 1.2, which deprecated price_detail. API 1.2 added support for upfront pricing, which for all upfront pricing products removed the PriceDetail as an object. You're probably getting a product that supports upfront pricing and so it no longer has the PriceDetail object you were getting in 0.5.2, which hit API 1.0.

MarianoTucat commented 7 years ago

ok, good to know, thanks for the info @itstexter !