uber / rides-java-sdk

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

Getting exeption while retrivin prices #13

Closed chandrayya closed 8 years ago

chandrayya commented 8 years ago

Code snippet used:

`// Create or load a credential for the user. Credential credential = authenticate(System.getProperty("user.name")); // Create session for the user Session session = new Session.Builder().setCredential(credential).setEnvironment(Session.Environment.PRODUCTION).build(); // Create the Uber API service object once the User is authenticated UberRidesSyncService uberRidesService = UberRidesServices.createSync(session); // Fetch the user's profile. System.out.println("Calling API to get the user's profile"); UserProfile userProfile = uberRidesService.getUserProfile().getBody(); System.out.printf("Logged in as %s%n", userProfile.getEmail()); ProductsResponse products = uberRidesService.getProducts(12.960325f, 77.643201f).getBody(); for (Product product : products.getProducts()) { System.out.println(product.getProductId() + ": " + product.getDisplayName()); }

    Response<PriceEstimatesResponse> fd = uberRidesService.getPriceEstimates(12.960325f, 77.643201f, 12.913017f, 77.589837f);
    List<PriceEstimate> prs = fd.getBody().getPrices();
    while (true) {
        for (Iterator iterator = prs.iterator(); iterator.hasNext();) {
            PriceEstimate priceEstimate = (PriceEstimate)iterator.next();
            System.out.println(priceEstimate.getDisplayName() + " " + priceEstimate.getEstimate());
            Thread.sleep(1000 * 60);
        }
    }`

After running getting exception like 2016-05-17 14:53:00.894:INFO::Logging to STDERR via org.mortbay.log.StdErrLog 2016-05-17 14:53:00.895:INFO::jetty-6.1.26 2016-05-17 14:53:00.911:INFO::Started SocketConnector@localhost:8181 2016-05-17 14:53:00.961:INFO::Stopped SocketConnector@localhost:8181 Calling API to get the user's profile Logged in as chandrayya.gk@gmail.com d7ecf694-0b83-40b1-ad7c-21f5682d98c4: uberMOTO 3eb15796-edd3-4297-80f1-02605442bb9e: uberPOOL db6779d6-d8da-479f-8ac7-8068f4dade6f: uberGO ed5e79f0-c124-4377-89eb-511cbdeb5fe2: POOL 0dfc35e0-b4be-49a1-b1bf-0bc7217e4b58: uberX 1cfdf145-9e9f-44d6-8f93-976e0252ca8d: uberXL Exception in thread "main" java.lang.RuntimeException: retrofit.converter.ConversionException: com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Expected an int but was 109.11 at line 1 column 338 path $.prices[1].high_estimate at com.google.common.base.Throwables.propagate(Throwables.java:160) at com.uber.sdk.rides.client.internal.RetrofitAdapter.transformFuture(RetrofitAdapter.java:611) at com.uber.sdk.rides.client.internal.RetrofitAdapter.getPriceEstimates(RetrofitAdapter.java:164) at ubertest.GetUserProfile.main(GetUserProfile.java:72) Caused by: retrofit.converter.ConversionException: com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Expected an int but was 109.11 at line 1 column 338 path $.prices[1].high_estimate at retrofit.converter.GsonConverter.fromBody(GsonConverter.java:67) at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:367) at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220) at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278) at retrofit.CallbackRunnable.run(CallbackRunnable.java:42) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at retrofit.Platform$Base$2$1.run(Platform.java:94) at java.lang.Thread.run(Thread.java:745) Caused by: com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Expected an int but was 109.11 at line 1 column 338 path $.prices[1].high_estimate at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:249) at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:239) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:116) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:216) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:116) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:216) at com.google.gson.Gson.fromJson(Gson.java:879) at com.google.gson.Gson.fromJson(Gson.java:844) at retrofit.converter.GsonConverter.fromBody(GsonConverter.java:63) ... 8 more Caused by: java.lang.NumberFormatException: Expected an int but was 109.11 at line 1 column 338 path $.prices[1].high_estimate at com.google.gson.stream.JsonReader.nextInt(JsonReader.java:1202) at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:247) ... 19 more

arogal commented 8 years ago

Hi chandrayya,

We will be updating our API to match the schema. After our change, the library should work with pool prices.

Thanks!

arogal commented 8 years ago

This should now be fixed. Let me know if you still have any issues.

chandrayya commented 8 years ago

@arogal Nice its working! Thanks!!