From 2066ff0381b309965af439140eec07a815fbfcce Mon Sep 17 00:00:00 2001 From: Ty Smith Date: Mon, 11 Jul 2016 15:24:39 -0700 Subject: [PATCH] [Gradle Release Plugin] - pre tag commit: 'v0.5.2'. --- CHANGELOG.md | 4 +- README.md | 14 +- gradle.properties | 2 +- sdk/build.gradle | 3 +- .../uber/sdk/rides/client/UberRidesApi.java | 8 +- .../client/internal/PrimitiveAdapter.java | 60 ------ .../uber/sdk/rides/client/model/Driver.java | 10 +- .../uber/sdk/rides/client/model/Location.java | 3 +- .../sdk/rides/client/model/PaymentMethod.java | 6 +- .../sdk/rides/client/model/PriceEstimate.java | 30 ++- .../uber/sdk/rides/client/model/Product.java | 5 + .../com/uber/sdk/rides/client/model/Ride.java | 22 +- .../sdk/rides/client/model/RideEstimate.java | 23 +- .../sdk/rides/client/model/RideReceipt.java | 7 +- .../client/model/RideRequestParameters.java | 198 ++++++++++++++---- .../sdk/rides/client/model/TimeEstimate.java | 10 +- .../sdk/rides/client/model/UserActivity.java | 11 +- .../uber/sdk/rides/client/model/Vehicle.java | 6 + .../test/java/com/uber/sdk/WireMockTest.java | 19 ++ .../core/auth/internal/OAuth2ServiceTest.java | 16 +- .../client/internal/PrimitiveAdapterTest.java | 57 ----- .../client/services/RidesServiceTest.java | 158 ++++++++++++++ sdk/src/test/resources/__files/products.json | 182 ++++++++++++++++ .../__files/request_estimate_UberPool.json | 21 ++ .../resources/__files/requests_current.json | 11 + .../__files/requests_current_UberPool.json | 11 + .../resources/__files/requests_estimate.json | 44 ++++ 27 files changed, 729 insertions(+), 212 deletions(-) delete mode 100644 sdk/src/main/java/com/uber/sdk/rides/client/internal/PrimitiveAdapter.java create mode 100644 sdk/src/test/java/com/uber/sdk/WireMockTest.java delete mode 100644 sdk/src/test/java/com/uber/sdk/rides/client/internal/PrimitiveAdapterTest.java create mode 100644 sdk/src/test/java/com/uber/sdk/rides/client/services/RidesServiceTest.java create mode 100644 sdk/src/test/resources/__files/products.json create mode 100644 sdk/src/test/resources/__files/request_estimate_UberPool.json create mode 100644 sdk/src/test/resources/__files/requests_current.json create mode 100644 sdk/src/test/resources/__files/requests_current_UberPool.json create mode 100644 sdk/src/test/resources/__files/requests_estimate.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fba1bc..f2608c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ -v0.5.2 - TBD +v0.5.2 - 7/11/2016 ------------ +### Added +- [Issue #22](https://github.com/uber/rides-java-sdk/issues/22) Support for Uber Pool v0.5.1 - 6/7/2016 ----------------- diff --git a/README.md b/README.md index a2de93f..9c45026 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This SDK helps your Java App make HTTP requests to the Uber Rides API. ### Installing #### Before you begin -Register your app in the [Uber developer dashboard](https://developer.uber.com/dashboard). Notice that the app gets a client ID, secret, and server token required for authenticating with the API. +Register your app in the [Uber developer dashboard](https://developer.uber.com/dashboard). Notice that the app gets a client ID, secret, and server token required for authenticating with the API. Note: Using Android? Be sure to checkout the [Uber Android SDK](github.com/uber/rides-android-sdk) in addition, which has native authentication mechanisms. @@ -14,7 +14,7 @@ Note: Using Android? Be sure to checkout the [Uber Android SDK](github.com/uber/ If using Gradle, add this to your project’s `build.gradle` file: ```gradle dependencies { - compile 'com.uber.sdk:rides:0.5.1' + compile 'com.uber.sdk:rides:0.5.2' } ``` @@ -24,7 +24,7 @@ If using Maven, add this to your project's `pom.xml` file: com.uber.sdk rides - 0.5.1 + 0.5.2 ``` @@ -44,7 +44,7 @@ ServerTokenSession session = new ServerTokenSession(config)); ``` #### Create a session using the OAuth 2 flow In an OAuth session, the app first asks the user to authorize and then exchanges the authorization code for an access token from Uber. -Note: Make sure the redirect URI matches the callback URI in the developer dashboard for the app. +Note: Make sure the redirect URI matches the callback URI in the developer dashboard for the app. **Step 1**. Create an OAuth2Credentials object with your client ID, client secret, scopes, and a redirect callback URI to capture the user’s authorization code. ```java @@ -54,13 +54,13 @@ SessionConfiguration config = new SessionConfiguration.Builder() .setScopes(yourScopes) .setRedirectUri(redirectUri) .build(); - + OAuth2Credentials credentials = new OAuth2Credentials.Builder() .setSessionConfiguration(config) .build(); - + ``` -**Step 2**. Navigate the user to the authorization URL from the OAuth2Credentials object. +**Step 2**. Navigate the user to the authorization URL from the OAuth2Credentials object. ```java String authorizationUrl = credentials.getAuthorizationUrl(); ``` diff --git a/gradle.properties b/gradle.properties index 0d12c10..5f69386 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,4 +24,4 @@ group=com.uber.sdk groupId=com.uber.sdk artifactId=rides githubDownloadPrefix=https://github.com/uber/rides-java-sdk/releases/download/ -version=0.5.2-SNAPSHOT +version=0.5.2 diff --git a/sdk/build.gradle b/sdk/build.gradle index 05a1ae0..3cffcb5 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -130,7 +130,6 @@ dependencies { testCompile 'org.assertj:assertj-core:1.7.1' testCompile 'org.hamcrest:hamcrest-library:1.3' testCompile 'org.mockito:mockito-core:1.10.8' - testCompile 'com.squareup.okhttp:mockwebserver:2.5.0' - testCompile 'com.github.tomakehurst:wiremock:1.57' + testCompile 'com.github.tomakehurst:wiremock:2.1.0-beta' } diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/UberRidesApi.java b/sdk/src/main/java/com/uber/sdk/rides/client/UberRidesApi.java index a45a646..e56c684 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/UberRidesApi.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/UberRidesApi.java @@ -24,17 +24,15 @@ import com.squareup.moshi.Moshi; import com.uber.sdk.rides.client.internal.ApiInterceptor; -import com.uber.sdk.rides.client.internal.PrimitiveAdapter; import com.uber.sdk.rides.client.internal.RefreshAuthenticator; import com.uber.sdk.rides.client.services.RidesService; - -import javax.annotation.Nonnull; - import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.moshi.MoshiConverterFactory; +import javax.annotation.Nonnull; + public class UberRidesApi { private final Retrofit retrofit; @@ -128,7 +126,7 @@ OkHttpClient createClient(OkHttpClient client, } Retrofit createRetrofit(OkHttpClient client, Session session) { - Moshi moshi = new Moshi.Builder().add(new PrimitiveAdapter()).build(); + Moshi moshi = new Moshi.Builder().build(); return new Retrofit.Builder() .addConverterFactory(MoshiConverterFactory.create(moshi)) diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/internal/PrimitiveAdapter.java b/sdk/src/main/java/com/uber/sdk/rides/client/internal/PrimitiveAdapter.java deleted file mode 100644 index 293f735..0000000 --- a/sdk/src/main/java/com/uber/sdk/rides/client/internal/PrimitiveAdapter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2016 Uber Technologies, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package com.uber.sdk.rides.client.internal; - -import com.squareup.moshi.FromJson; - -import javax.annotation.Nullable; - -/** - * Adapter used to adapt primitives coming back explicitly as null to 0; - */ -public class PrimitiveAdapter { - - @FromJson - public int intFromJson(@Nullable Integer value) { - if (value == null) { - return 0; - } - - return value; - } - - @FromJson - public float floatFromJson(@Nullable Float value) { - if (value == null) { - return 0; - } - - return value; - } - - @FromJson - public long longFromJson(@Nullable Long value) { - if (value == null) { - return 0; - } - - return value; - } -} diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/model/Driver.java b/sdk/src/main/java/com/uber/sdk/rides/client/model/Driver.java index af537b6..3ec52bf 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/model/Driver.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/model/Driver.java @@ -22,13 +22,17 @@ package com.uber.sdk.rides.client.model; +import javax.annotation.Nullable; + /** * The vehicle's driver. */ public class Driver { private String phone_number; - private float rating; + @Nullable + private Float rating; + @Nullable private String picture_url; private String name; @@ -42,13 +46,15 @@ public String getPhoneNumber() { /** * The driver's star rating out of 5 stars. */ - public float getRating() { + @Nullable + public Float getRating() { return rating; } /** * The URL to the photo of the driver. */ + @Nullable public String getPictureUrl() { return picture_url; } diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/model/Location.java b/sdk/src/main/java/com/uber/sdk/rides/client/model/Location.java index ad79d32..253c329 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/model/Location.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/model/Location.java @@ -31,7 +31,8 @@ public class Location { private float latitude; private float longitude; - @Nullable private Integer bearing; + @Nullable + private Integer bearing; /** * Location must be created with a non-null latitude and longitude. diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/model/PaymentMethod.java b/sdk/src/main/java/com/uber/sdk/rides/client/model/PaymentMethod.java index e04b6e0..baaec27 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/model/PaymentMethod.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/model/PaymentMethod.java @@ -22,15 +22,18 @@ package com.uber.sdk.rides.client.model; +import javax.annotation.Nullable; + /** * A user's Payment Method. See - * Payment Methods + * Payment Methods * for more information. */ public class PaymentMethod { private String payment_method_id; private String type; + @Nullable private String description; /** @@ -52,6 +55,7 @@ public String getType() { /** * Gets the description of a Payment Method. */ + @Nullable public String getDescription() { return description; } diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/model/PriceEstimate.java b/sdk/src/main/java/com/uber/sdk/rides/client/model/PriceEstimate.java index 4b2a56f..0fb63dd 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/model/PriceEstimate.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/model/PriceEstimate.java @@ -22,22 +22,29 @@ package com.uber.sdk.rides.client.model; +import javax.annotation.Nullable; + /** * An estimated price for a product on the Uber platform. See - * Price Estimates + * Price Estimates * for more information. */ public class PriceEstimate { private String product_id; + @Nullable private String currency_code; private String display_name; private String estimate; - private int low_estimate; - private int high_estimate; + @Nullable + private Integer low_estimate; + @Nullable + private Integer high_estimate; private float surge_multiplier; - private int duration; - private float distance; + @Nullable + private Integer duration; + @Nullable + private Float distance; /** * Unique identifier representing a specific product for a given latitude & longitude. For @@ -50,6 +57,7 @@ public String getProductId() { /** * ISO 4217 currency code. */ + @Nullable public String getCurrencyCode() { return currency_code; } @@ -72,14 +80,16 @@ public String getEstimate() { /** * Lower bound of the estimated price. */ - public int getLowEstimate() { + @Nullable + public Integer getLowEstimate() { return low_estimate; } /** * Upper bound of the estimated price. */ - public int getHighEstimate() { + @Nullable + public Integer getHighEstimate() { return high_estimate; } @@ -94,14 +104,16 @@ public float getSurgeMultiplier() { /** * Expected activity duration (in seconds). Always show duration in minutes. */ - public int getDuration() { + @Nullable + public Integer getDuration() { return duration; } /** * Expected activity distance (in miles). */ - public float getDistance() { + @Nullable + public Float getDistance() { return distance; } } \ No newline at end of file diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/model/Product.java b/sdk/src/main/java/com/uber/sdk/rides/client/model/Product.java index 7a24f0d..70d9d49 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/model/Product.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/model/Product.java @@ -34,6 +34,7 @@ public class Product { private String description; private int capacity; private String image; + private boolean shared; /** * A unique identifier representing a specific product for a given latitude & longitude. For @@ -70,5 +71,9 @@ public int getCapacity() { public String getImage() { return image; } + + public boolean isShared() { + return shared; + } } diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/model/Ride.java b/sdk/src/main/java/com/uber/sdk/rides/client/model/Ride.java index e63ef67..f9decca 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/model/Ride.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/model/Ride.java @@ -22,6 +22,8 @@ package com.uber.sdk.rides.client.model; +import javax.annotation.Nullable; + /** * An ongoing or completed ride. See * Requests @@ -32,10 +34,13 @@ public class Ride { private String request_id; private String status; private Driver driver; - private int eta; + @Nullable + private Integer eta; private float surge_multiplier; private Location location; private Vehicle vehicle; + private String product_id; + private boolean shared; /** * The unique ID of the ride. @@ -61,6 +66,7 @@ public Driver getDriver() { /** * The estimated time of vehicle arrival in minutes. */ + @Nullable public Integer getEta() { return eta; } @@ -86,4 +92,18 @@ public Vehicle getVehicle() { public Float getSurgeMultiplier() { return surge_multiplier; } + + /** + * The product ID associated to the Ride. + */ + public String getProductId() { + return product_id; + } + + /** + * Indicates whether the ride is a shared ride or not. UberPool is an example of a shared ride. + */ + public boolean isShared() { + return shared; + } } \ No newline at end of file diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/model/RideEstimate.java b/sdk/src/main/java/com/uber/sdk/rides/client/model/RideEstimate.java index d4dc644..de3fe96 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/model/RideEstimate.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/model/RideEstimate.java @@ -26,7 +26,7 @@ /** * An estimate for a ride. See - * Request Estimate + * Request Estimate * for more information. */ public class RideEstimate { @@ -34,14 +34,15 @@ public class RideEstimate { private Price price; @Nullable private Trip trip; - private int pickup_estimate; + @Nullable + private Integer pickup_estimate; /** * Details of the estimated fare. */ public static class Price { - - private int minimum; + @Nullable + private Integer minimum; @Nullable private String surge_confirmation_href; @Nullable @@ -56,11 +57,14 @@ public static class Price { private String display; @Nullable private String currency_code; + @Nullable + private String fare_id; /** * The minimum price of the ride. */ - public int getMinimum() { + @Nullable + public Integer getMinimum() { return minimum; } @@ -121,6 +125,15 @@ public String getDisplay() { public String getCurrencyCode() { return currency_code; } + + /** + * The fare ID assigned for this estimate. Must send this back when requesting a ride to ensure ride requested + * is based on this fare. + */ + @Nullable + public String getFareId() { + return fare_id; + } } /** diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/model/RideReceipt.java b/sdk/src/main/java/com/uber/sdk/rides/client/model/RideReceipt.java index 48a69f2..a305d71 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/model/RideReceipt.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/model/RideReceipt.java @@ -22,14 +22,13 @@ package com.uber.sdk.rides.client.model; -import java.util.List; - import javax.annotation.Nullable; +import java.util.List; /** * A receipt for a completed request. * See - * Ride Request Receipt + * Ride Request Receipt * for more information. */ public class RideReceipt { @@ -43,6 +42,7 @@ public class RideReceipt { private String total_charged; @Nullable private Float total_owed; + @Nullable private String currency_code; private String duration; private String distance; @@ -111,6 +111,7 @@ public Float getTotalOwed() { /** * Gets the ISO 4217 currency code. */ + @Nullable public String getCurrencyCode() { return currency_code; } diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/model/RideRequestParameters.java b/sdk/src/main/java/com/uber/sdk/rides/client/model/RideRequestParameters.java index 0fd5e7a..fed3642 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/model/RideRequestParameters.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/model/RideRequestParameters.java @@ -34,33 +34,52 @@ */ public class RideRequestParameters { - @Nullable private String product_id; - @Nullable private Float start_latitude; - @Nullable private Float start_longitude; - @Nullable private String start_nickname; - @Nullable private String start_address; - @Nullable private String start_place_id; - @Nullable private Float end_latitude; - @Nullable private Float end_longitude; - @Nullable private String end_nickname; - @Nullable private String end_address; - @Nullable private String end_place_id; - @Nullable private String surge_confirmation_id; - @Nullable private String payment_method_id; + @Nullable + private String product_id; + @Nullable + private Float start_latitude; + @Nullable + private Float start_longitude; + @Nullable + private String start_nickname; + @Nullable + private String start_address; + @Nullable + private String start_place_id; + @Nullable + private Float end_latitude; + @Nullable + private Float end_longitude; + @Nullable + private String end_nickname; + @Nullable + private String end_address; + @Nullable + private String end_place_id; + @Nullable + private String surge_confirmation_id; + @Nullable + private String payment_method_id; + @Nullable + private Integer seat_count; + @Nullable + private String fare_id; private RideRequestParameters(@Nullable String productId, - @Nullable Float startLatitude, - @Nullable Float startLongitude, - @Nullable String startNickname, - @Nullable String startAddress, - @Nullable String startPlaceId, - @Nullable Float endLatitude, - @Nullable Float endLongitude, - @Nullable String endNickname, - @Nullable String endAddress, - @Nullable String endPlaceId, - @Nullable String surgeConfirmationId, - @Nullable String paymentMethodId) { + @Nullable Float startLatitude, + @Nullable Float startLongitude, + @Nullable String startNickname, + @Nullable String startAddress, + @Nullable String startPlaceId, + @Nullable Float endLatitude, + @Nullable Float endLongitude, + @Nullable String endNickname, + @Nullable String endAddress, + @Nullable String endPlaceId, + @Nullable String surgeConfirmationId, + @Nullable String paymentMethodId, + @Nullable Integer seatCount, + @Nullable String fareId) { this.product_id = productId; this.start_latitude = startLatitude; this.start_longitude = startLongitude; @@ -74,6 +93,8 @@ private RideRequestParameters(@Nullable String productId, this.end_place_id = endPlaceId; this.surge_confirmation_id = surgeConfirmationId; this.payment_method_id = paymentMethodId; + this.seat_count = seatCount; + this.fare_id = fareId; } /** @@ -81,19 +102,72 @@ private RideRequestParameters(@Nullable String productId, */ public static class Builder { - @Nullable private String productId; - @Nullable private Float startLatitude; - @Nullable private Float startLongitude; - @Nullable private String startNickname; - @Nullable private String startAddress; - @Nullable private String startPlaceId; - @Nullable private Float endLatitude; - @Nullable private Float endLongitude; - @Nullable private String endNickname; - @Nullable private String endAddress; - @Nullable private String endPlaceId; - @Nullable private String surgeConfirmationId; - @Nullable private String paymentMethodId; + @Nullable + private String productId; + @Nullable + private Float startLatitude; + @Nullable + private Float startLongitude; + @Nullable + private String startNickname; + @Nullable + private String startAddress; + @Nullable + private String startPlaceId; + @Nullable + private Float endLatitude; + @Nullable + private Float endLongitude; + @Nullable + private String endNickname; + @Nullable + private String endAddress; + @Nullable + private String endPlaceId; + @Nullable + private String surgeConfirmationId; + @Nullable + private String paymentMethodId; + @Nullable + private Integer seatCount; + @Nullable + private String fareId; + + public Builder() { + } + + public Builder( + @Nullable String productId, + @Nullable Float startLatitude, + @Nullable Float startLongitude, + @Nullable String startNickname, + @Nullable String startAddress, + @Nullable String startPlaceId, + @Nullable Float endLatitude, + @Nullable Float endLongitude, + @Nullable String endNickname, + @Nullable String endAddress, + @Nullable String endPlaceId, + @Nullable String surgeConfirmationId, + @Nullable String paymentMethodId, + @Nullable Integer seatCount, + @Nullable String fareId) { + this.productId = productId; + this.startLatitude = startLatitude; + this.startLongitude = startLongitude; + this.startNickname = startNickname; + this.startAddress = startAddress; + this.startPlaceId = startPlaceId; + this.endLatitude = endLatitude; + this.endLongitude = endLongitude; + this.endNickname = endNickname; + this.endAddress = endAddress; + this.endPlaceId = endPlaceId; + this.surgeConfirmationId = surgeConfirmationId; + this.paymentMethodId = paymentMethodId; + this.seatCount = seatCount; + this.fareId = fareId; + } /** * Sets the unique ID of the product being requested. If none supplied, the cheapest product for the @@ -229,6 +303,26 @@ public Builder setPaymentMethodId(@Nullable String paymentMethodId) { return this; } + /** + * Sets the number of seats required for this request. + * + * @param seatCount + */ + public Builder setSeatCount(@Nullable Integer seatCount) { + this.seatCount = seatCount; + return this; + } + + /** + * Sets the fare Id requested for this ride. + * + * @param fareId + */ + public Builder setFareId(@Nullable String fareId) { + this.fareId = fareId; + return this; + } + private void validate() { if (startPlaceId != null) { if (startLatitude != null || startLongitude != null) { @@ -270,10 +364,19 @@ public RideRequestParameters build() { endAddress, endPlaceId, surgeConfirmationId, - paymentMethodId); + paymentMethodId, + seatCount, + fareId); } } + @Nonnull + public Builder newBuilder() { + return new Builder(product_id, start_latitude, start_longitude, start_nickname, start_address, start_place_id, + end_latitude, end_longitude, end_nickname, end_address, end_place_id, surge_confirmation_id, + payment_method_id, seat_count, fare_id); + } + /** * Gets the product Id for this Ride Request */ @@ -385,4 +488,21 @@ public void setSurgeConfirmationId(@Nullable String surgeConfirmationId) { public String getPaymentMethodId() { return payment_method_id; } + + /** + * Gets the number of seats required for this Ride Request. + */ + @Nullable + public Integer getSeatCount() { + return seat_count; + } + + /** + * Gets the fare ID to be used for this Ride Request, shared ride (Uber Pool) will return this + * otherwise it will be null. + */ + @Nullable + public String getFareId() { + return fare_id; + } } \ No newline at end of file diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/model/TimeEstimate.java b/sdk/src/main/java/com/uber/sdk/rides/client/model/TimeEstimate.java index dcf222a..64400f5 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/model/TimeEstimate.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/model/TimeEstimate.java @@ -22,16 +22,19 @@ package com.uber.sdk.rides.client.model; +import javax.annotation.Nullable; + /** * An estimated time for a product on the Uber platform. See - * Price Estimates + * Time Estimates * for more information. */ public class TimeEstimate { private String product_id; private String display_name; - private int estimate; + @Nullable + private Integer estimate; /** * Unique identifier representing a specific product for a given latitude & longitude. For @@ -51,7 +54,8 @@ public String getDisplayName() { /** * ETA for the product (in seconds). Always show estimate in minutes. */ - public int getEstimate() { + @Nullable + public Integer getEstimate() { return estimate; } } \ No newline at end of file diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/model/UserActivity.java b/sdk/src/main/java/com/uber/sdk/rides/client/model/UserActivity.java index a638564..d51b5bc 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/model/UserActivity.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/model/UserActivity.java @@ -26,7 +26,7 @@ /** * A user's activity. See - * User Activity for more + * User Activity for more * information. */ public class UserActivity { @@ -37,9 +37,13 @@ public class UserActivity { private long request_time; private long start_time; private long end_time; + @Nullable private String product_id; + @Nullable private City start_city; - private float fare; + @Nullable + private Float fare; + @Nullable private String currency_code; /** @@ -88,6 +92,7 @@ public long getEndTime() { * Unique identifier representing a specific product for a given latitude & longitude. For * example, uberX in San Francisco will have a different product_id than uberX in Los Angeles. */ + @Nullable public String getProductId() { return product_id; } @@ -124,6 +129,7 @@ public String getCurrencyCode() { */ public static class City { + @Nullable private String display_name; private float latitude; private float longitude; @@ -131,6 +137,7 @@ public static class City { /** * The display name of the city. */ + @Nullable public String getDisplayName() { return display_name; } diff --git a/sdk/src/main/java/com/uber/sdk/rides/client/model/Vehicle.java b/sdk/src/main/java/com/uber/sdk/rides/client/model/Vehicle.java index 0232dce..6f30d50 100644 --- a/sdk/src/main/java/com/uber/sdk/rides/client/model/Vehicle.java +++ b/sdk/src/main/java/com/uber/sdk/rides/client/model/Vehicle.java @@ -22,6 +22,8 @@ package com.uber.sdk.rides.client.model; +import javax.annotation.Nullable; + /** * An Uber vehicle. */ @@ -29,7 +31,9 @@ public class Vehicle { private String make; private String model; + @Nullable private String license_plate; + @Nullable private String picture_url; /** @@ -49,6 +53,7 @@ public String getModel() { /** * The license plate number of the vehicle. */ + @Nullable public String getLicensePlate() { return license_plate; } @@ -56,6 +61,7 @@ public String getLicensePlate() { /** * The URL to the photo of the vehicle. */ + @Nullable public String getPictureUrl() { return picture_url; } diff --git a/sdk/src/test/java/com/uber/sdk/WireMockTest.java b/sdk/src/test/java/com/uber/sdk/WireMockTest.java new file mode 100644 index 0000000..60f83ea --- /dev/null +++ b/sdk/src/test/java/com/uber/sdk/WireMockTest.java @@ -0,0 +1,19 @@ +package com.uber.sdk; + +import com.github.tomakehurst.wiremock.common.ConsoleNotifier; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; +import com.github.tomakehurst.wiremock.junit.WireMockRule; + +import org.junit.Rule; + +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; + +public class WireMockTest { + + protected static WireMockConfiguration WIRE_MOCK_CONFIG = wireMockConfig() + .notifier(new ConsoleNotifier(true)) + .dynamicPort(); + + @Rule + public WireMockRule wireMockRule = new WireMockRule(WIRE_MOCK_CONFIG); +} diff --git a/sdk/src/test/java/com/uber/sdk/core/auth/internal/OAuth2ServiceTest.java b/sdk/src/test/java/com/uber/sdk/core/auth/internal/OAuth2ServiceTest.java index 391e70d..603cd87 100644 --- a/sdk/src/test/java/com/uber/sdk/core/auth/internal/OAuth2ServiceTest.java +++ b/sdk/src/test/java/com/uber/sdk/core/auth/internal/OAuth2ServiceTest.java @@ -22,14 +22,11 @@ package com.uber.sdk.core.auth.internal; -import com.github.tomakehurst.wiremock.common.ConsoleNotifier; -import com.github.tomakehurst.wiremock.core.WireMockConfiguration; -import com.github.tomakehurst.wiremock.junit.WireMockRule; import com.squareup.moshi.Moshi; +import com.uber.sdk.WireMockTest; import com.uber.sdk.core.auth.AccessToken; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import okhttp3.OkHttpClient; @@ -42,22 +39,15 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.assertj.core.api.Assertions.assertThat; -public class OAuth2ServiceTest { +public class OAuth2ServiceTest extends WireMockTest { + private static final String REFRESH_TOKEN = "RANDOM1234REFRESHTOKEN"; private static final String CLIENT_ID = "MYCLIENTID123"; private static final String REQUEST_BODY = "refresh_token=" + REFRESH_TOKEN + "&client_id=" + CLIENT_ID; - private static WireMockConfiguration WIRE_MOCK_CONFIG = wireMockConfig() - .notifier(new ConsoleNotifier(true)) - .dynamicPort(); - - @Rule - public WireMockRule wireMockRule = new WireMockRule(WIRE_MOCK_CONFIG); - private OAuth2Service oAuth2Service; @Before diff --git a/sdk/src/test/java/com/uber/sdk/rides/client/internal/PrimitiveAdapterTest.java b/sdk/src/test/java/com/uber/sdk/rides/client/internal/PrimitiveAdapterTest.java deleted file mode 100644 index 6a93921..0000000 --- a/sdk/src/test/java/com/uber/sdk/rides/client/internal/PrimitiveAdapterTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2016 Uber Technologies, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package com.uber.sdk.rides.client.internal; - -import com.squareup.moshi.JsonAdapter; -import com.squareup.moshi.Moshi; - -import org.junit.Test; - -import java.io.IOException; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PrimitiveAdapterTest { - - @Test - public void fromJson_whenNull_shouldGoToZero() throws IOException { - Moshi moshi = new Moshi.Builder().add(new PrimitiveAdapter()).build(); - - JsonAdapter adapter = moshi.adapter(PrimitiveModel.class); - PrimitiveModel model = adapter.fromJson("{\"someint\":null,\"somefloat\":null,\"somelong\":null}"); - assertThat(model.getSomeint()).isZero(); - assertThat(model.getSomefloat()).isZero(); - assertThat(model.getSomelong()).isZero(); - } - - @Test - public void fromJson_whenValueProvided_shouldReturnValue() throws IOException { - Moshi moshi = new Moshi.Builder().add(new PrimitiveAdapter()).build(); - - JsonAdapter adapter = moshi.adapter(PrimitiveModel.class); - PrimitiveModel model = adapter.fromJson("{\"someint\":1,\"somefloat\":1.0,\"somelong\":11}"); - assertThat(model.getSomeint()).isEqualTo(1); - assertThat(model.getSomefloat()).isEqualTo(1.0f); - assertThat(model.getSomelong()).isEqualTo(11l); - } -} diff --git a/sdk/src/test/java/com/uber/sdk/rides/client/services/RidesServiceTest.java b/sdk/src/test/java/com/uber/sdk/rides/client/services/RidesServiceTest.java new file mode 100644 index 0000000..e539a0e --- /dev/null +++ b/sdk/src/test/java/com/uber/sdk/rides/client/services/RidesServiceTest.java @@ -0,0 +1,158 @@ +package com.uber.sdk.rides.client.services; + +import com.squareup.moshi.Moshi; +import com.uber.sdk.WireMockTest; +import com.uber.sdk.rides.client.model.Product; +import com.uber.sdk.rides.client.model.Ride; +import com.uber.sdk.rides.client.model.RideEstimate; +import com.uber.sdk.rides.client.model.RideRequestParameters; +import okhttp3.OkHttpClient; +import okhttp3.logging.HttpLoggingInterceptor; +import org.junit.Before; +import org.junit.Test; +import retrofit2.Retrofit; +import retrofit2.converter.moshi.MoshiConverterFactory; + +import java.util.List; + +import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static org.assertj.core.api.Assertions.assertThat; + +public class RidesServiceTest extends WireMockTest { + + private static final float PICKUP_LATITUDE = 37.7753f; + private static final float PICKUP_LONGITUDE = -122.418f; + private static final float DROPOFF_LATITUDE = 37.787654f; + private static final float DROPOFF_LONGITUDE = -122.40276f; + private static final String UBER_POOL_PRODUCT_ID = "26546650-e557-4a7b-86e7-6a3942445247"; + private static final String UBER_X_PRODUCT_ID = "a1111c8c-c720-46c3-8534-2fcdd730040d"; + private static final String RIDE_REQUEST_UBER_POOL = "{\"end_latitude\":37.787655,\"end_longitude\":-122.40276,\"product_id\":\"26546650-e557-4a7b-86e7-6a3942445247\",\"seat_count\":2,\"start_latitude\":37.7753,\"start_longitude\":-122.418}"; + private static final String RIDE_REQUEST = "{\"end_latitude\":37.787655,\"end_longitude\":-122.40276,\"seat_count\":2,\"start_latitude\":37.7753,\"start_longitude\":-122.418}"; + private static final String FARE_ID = "2455e0e040da58e77babe4e32e4c771f89faf87778a95bc5aec2be406865ad30"; + + private RidesService service; + + @Before + public void setUp() throws Exception { + + service = new Retrofit.Builder() + .addConverterFactory(MoshiConverterFactory.create(new Moshi.Builder().build())) + .client(new OkHttpClient.Builder() + .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) + .build()) + .baseUrl("http://localhost:" + wireMockRule.port()) + .build() + .create(RidesService.class); + + + } + + private static RideRequestParameters createRideRequest() { + return new RideRequestParameters.Builder() + .setPickupCoordinates(PICKUP_LATITUDE, PICKUP_LONGITUDE) + .setDropoffCoordinates(DROPOFF_LATITUDE, DROPOFF_LONGITUDE) + .setSeatCount(2) + .build(); + } + + private static RideRequestParameters createUberPoolRideRequest() { + return new RideRequestParameters.Builder() + .setPickupCoordinates(PICKUP_LATITUDE, PICKUP_LONGITUDE) + .setDropoffCoordinates(DROPOFF_LATITUDE, DROPOFF_LONGITUDE) + .setProductId(UBER_POOL_PRODUCT_ID) + .setSeatCount(2) + .build(); + } + + @Test + public void testGetProducts() throws Exception { + stubFor(get(urlPathEqualTo("/v1/products")) + .willReturn(aResponse().withBodyFile("products.json"))); + + final List products = service.getProducts(PICKUP_LATITUDE, PICKUP_LONGITUDE) + .execute() + .body() + .getProducts(); + + assertThat(products.size()).isEqualTo(9); + + final Product uberPool = products.get(0); + assertThat(uberPool.getDisplayName()).isEqualTo("uberPOOL"); + assertThat(uberPool.getCapacity()).isEqualTo(2); + assertThat(uberPool.getProductId()).isEqualTo(UBER_POOL_PRODUCT_ID); + assertThat(uberPool.isShared()).isTrue(); + + final Product uberX = products.get(1); + assertThat(uberX.getDisplayName()).isEqualTo("uberX"); + assertThat(uberX.getCapacity()).isEqualTo(4); + assertThat(uberX.getProductId()).isEqualTo(UBER_X_PRODUCT_ID); + assertThat(uberX.isShared()).isFalse(); + } + + @Test + public void testGetRideEstimate_withUberPoolProductId() throws Exception { + stubFor(post(urlPathEqualTo("/v1/requests/estimate")) + .withRequestBody(equalToJson(RIDE_REQUEST_UBER_POOL, true, false)) + .willReturn(aResponse().withBodyFile("request_estimate_UberPool.json"))); + + final RideEstimate rideEstimate = service.estimateRide(createUberPoolRideRequest()).execute().body(); + + assertThat(rideEstimate.getPrice().getFareId()).isEqualTo(FARE_ID); + assertThat(rideEstimate.getPickupEstimate()).isEqualTo(4); + assertThat(rideEstimate.getPrice().getHighEstimate()).isEqualTo(5); + assertThat(rideEstimate.getPrice().getLowEstimate()).isEqualTo(4); + assertThat(rideEstimate.getPrice().getDisplay()).isEqualTo("$4.87"); + + assertThat(rideEstimate.getTrip()).isNotNull(); + assertThat(rideEstimate.getTrip().getDistanceUnit()).isEqualTo("mile"); + assertThat(rideEstimate.getTrip().getDurationEstimate()).isEqualTo(720); + assertThat(rideEstimate.getTrip().getDistanceEstimate()).isEqualTo(1.88f); + } + + @Test + public void testGetRideEstimate_withoutProductId() throws Exception { + stubFor(post(urlPathEqualTo("/v1/requests/estimate")) + .withRequestBody(equalToJson(RIDE_REQUEST, true, false)) + .willReturn(aResponse().withBodyFile("requests_estimate.json"))); + + final RideEstimate rideEstimate = service.estimateRide(createRideRequest()).execute().body(); + assertThat(rideEstimate.getPrice().getFareId()).isNull(); + assertThat(rideEstimate.getPrice().getHighEstimate()).isEqualTo(10); + assertThat(rideEstimate.getPrice().getLowEstimate()).isEqualTo(7); + assertThat(rideEstimate.getPrice().getDisplay()).isEqualTo("$7-10"); + + assertThat(rideEstimate.getTrip()).isNotNull(); + assertThat(rideEstimate.getTrip().getDistanceUnit()).isEqualTo("mile"); + assertThat(rideEstimate.getTrip().getDurationEstimate()).isEqualTo(720); + assertThat(rideEstimate.getTrip().getDistanceEstimate()).isEqualTo(1.88f); + } + + @Test + public void testRequestRide_withoutProductId() throws Exception { + stubFor(post(urlPathEqualTo("/v1/requests")) + .withRequestBody(equalToJson(RIDE_REQUEST, true, false)) + .willReturn(aResponse().withBodyFile("requests_current.json"))); + + final Ride ride = service.requestRide(createRideRequest()).execute().body(); + + assertThat(ride.getStatus()).isEqualTo("processing"); + assertThat(ride.getProductId()).isEqualTo(UBER_X_PRODUCT_ID); + assertThat(ride.getRideId()).isNotEmpty(); + assertThat(ride.isShared()).isFalse(); + assertThat(ride.getEta()).isNull(); + } + + @Test + public void testRequestRide_withUberPoolProductId() throws Exception { + stubFor(post(urlPathEqualTo("/v1/requests")) + .withRequestBody(equalToJson(RIDE_REQUEST_UBER_POOL, true, false)) + .willReturn(aResponse().withBodyFile("requests_current_UberPool.json"))); + + final Ride ride = service.requestRide(createUberPoolRideRequest()).execute().body(); + assertThat(ride.getStatus()).isEqualTo("processing"); + + assertThat(ride.getProductId()).isEqualTo(UBER_POOL_PRODUCT_ID); + assertThat(ride.getRideId()).isNotEmpty(); + assertThat(ride.isShared()).isTrue(); + } +} diff --git a/sdk/src/test/resources/__files/products.json b/sdk/src/test/resources/__files/products.json new file mode 100644 index 0000000..c7de4c6 --- /dev/null +++ b/sdk/src/test/resources/__files/products.json @@ -0,0 +1,182 @@ +{ + "products": [ + { + "capacity": 2, + "product_id": "26546650-e557-4a7b-86e7-6a3942445247", + "price_details": null, + "image": "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberpool.png", + "shared": true, + "short_description": "POOL", + "display_name": "uberPOOL", + "description": "Share the ride, split the cost." + }, + { + "capacity": 4, + "product_id": "a1111c8c-c720-46c3-8534-2fcdd730040d", + "price_details": { + "service_fees": [ + { + "fee": 1.55, + "name": "Booking fee" + } + ], + "cost_per_minute": 0.22, + "distance_unit": "mile", + "minimum": 6.55, + "cost_per_distance": 1.15, + "base": 2.0, + "cancellation_fee": 5.0, + "currency_code": "USD" + }, + "image": "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberx.png", + "shared": false, + "short_description": "uberX", + "display_name": "uberX", + "description": "The low-cost Uber" + }, + { + "capacity": 6, + "product_id": "821415d8-3bd5-4e27-9604-194e4359a449", + "price_details": { + "service_fees": [ + { + "fee": 1.55, + "name": "Booking fee" + } + ], + "cost_per_minute": 0.3, + "distance_unit": "mile", + "minimum": 8.55, + "cost_per_distance": 2.0, + "base": 3.0, + "cancellation_fee": 5.0, + "currency_code": "USD" + }, + "image": "https://uber-static.s3.amazonaws.com/car-types/mono/mono-uberxl2-2.png", + "shared": false, + "short_description": "uberXL", + "display_name": "uberXL", + "description": "Low-cost rides for large groups" + }, + { + "capacity": 4, + "product_id": "57c0ff4e-1493-4ef9-a4df-6b961525cf92", + "price_details": { + "service_fees": [ + { + "fee": 1.55, + "name": "Booking fee" + } + ], + "cost_per_minute": 0.5, + "distance_unit": "mile", + "minimum": 10.55, + "cost_per_distance": 2.75, + "base": 5.0, + "cancellation_fee": 5.0, + "currency_code": "USD" + }, + "image": "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberselect.png", + "shared": false, + "short_description": "SELECT", + "display_name": "UberSELECT", + "description": "A step above the every day" + }, + { + "capacity": 4, + "product_id": "d4abaae7-f4d6-4152-91cc-77523e8165a4", + "price_details": { + "service_fees": [], + "cost_per_minute": 0.65, + "distance_unit": "mile", + "minimum": 15.0, + "cost_per_distance": 3.75, + "base": 8.0, + "cancellation_fee": 10.0, + "currency_code": "USD" + }, + "image": "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-black.png", + "shared": false, + "short_description": "BLACK CAR", + "display_name": "UberBLACK", + "description": "The original Uber" + }, + { + "capacity": 6, + "product_id": "8920cb5e-51a4-4fa4-acdf-dd86c5e18ae0", + "price_details": { + "service_fees": [], + "cost_per_minute": 0.9, + "distance_unit": "mile", + "minimum": 25.0, + "cost_per_distance": 3.75, + "base": 15.0, + "cancellation_fee": 10.0, + "currency_code": "USD" + }, + "image": "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-suv.png", + "shared": false, + "short_description": "SUV", + "display_name": "UberSUV", + "description": "Room for everyone" + }, + { + "capacity": 4, + "product_id": "ff5ed8fe-6585-4803-be13-3ca541235de3", + "price_details": { + "service_fees": [ + { + "fee": 1.55, + "name": "Booking fee" + } + ], + "cost_per_minute": 0.22, + "distance_unit": "mile", + "minimum": 6.55, + "cost_per_distance": 1.15, + "base": 2.0, + "cancellation_fee": 5.0, + "currency_code": "USD" + }, + "image": "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-wheelchair.png", + "shared": false, + "short_description": "ASSIST", + "display_name": "ASSIST", + "description": "ASSIST" + }, + { + "capacity": 4, + "product_id": "2832a1f5-cfc0-48bb-ab76-7ea7a62060e7", + "price_details": { + "service_fees": [ + { + "fee": 1.55, + "name": "Booking fee" + } + ], + "cost_per_minute": 0.45, + "distance_unit": "mile", + "minimum": 8.55, + "cost_per_distance": 2.15, + "base": 5.0, + "cancellation_fee": 5.0, + "currency_code": "USD" + }, + "image": "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-wheelchair.png", + "shared": false, + "short_description": "WAV", + "display_name": "uberWAV", + "description": "Wheelchair Accessible Vehicles" + }, + { + "capacity": 4, + "product_id": "3ab64887-4842-4c8e-9780-ccecd3a0391d", + "price_details": null, + "image": "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-taxi.png", + "shared": false, + "short_description": "TAXI", + "display_name": "uberTAXI", + "description": "Taxi without the hassle" + } + ] +} \ No newline at end of file diff --git a/sdk/src/test/resources/__files/request_estimate_UberPool.json b/sdk/src/test/resources/__files/request_estimate_UberPool.json new file mode 100644 index 0000000..e1e6696 --- /dev/null +++ b/sdk/src/test/resources/__files/request_estimate_UberPool.json @@ -0,0 +1,21 @@ +{ + "price": { + "surge_confirmation_href": null, + "high_estimate": 5, + "fare_id": "2455e0e040da58e77babe4e32e4c771f89faf87778a95bc5aec2be406865ad30", + "surge_confirmation_id": null, + "minimum": null, + "expires_at": 1466106805, + "low_estimate": 4, + "fare_breakdown": [], + "surge_multiplier": 1.0, + "display": "$4.87", + "currency_code": "USD" + }, + "trip": { + "distance_unit": "mile", + "duration_estimate": 720, + "distance_estimate": 1.88 + }, + "pickup_estimate": 4 +} \ No newline at end of file diff --git a/sdk/src/test/resources/__files/requests_current.json b/sdk/src/test/resources/__files/requests_current.json new file mode 100644 index 0000000..5adb36f --- /dev/null +++ b/sdk/src/test/resources/__files/requests_current.json @@ -0,0 +1,11 @@ +{ + "status": "processing", + "product_id": "a1111c8c-c720-46c3-8534-2fcdd730040d", + "request_id": "6a964a88-5ed9-49a0-9be9-dd09ed8c9d7a", + "driver": null, + "eta": null, + "location": null, + "vehicle": null, + "surge_multiplier": 1.0, + "shared": false +} \ No newline at end of file diff --git a/sdk/src/test/resources/__files/requests_current_UberPool.json b/sdk/src/test/resources/__files/requests_current_UberPool.json new file mode 100644 index 0000000..05d93fc --- /dev/null +++ b/sdk/src/test/resources/__files/requests_current_UberPool.json @@ -0,0 +1,11 @@ +{ + "status": "processing", + "product_id": "26546650-e557-4a7b-86e7-6a3942445247", + "request_id": "7c658aac-3bbb-4d37-9520-9ad95f13deea", + "driver": null, + "eta": null, + "location": null, + "vehicle": null, + "surge_multiplier": 1.0, + "shared": true +} \ No newline at end of file diff --git a/sdk/src/test/resources/__files/requests_estimate.json b/sdk/src/test/resources/__files/requests_estimate.json new file mode 100644 index 0000000..bcd2ec2 --- /dev/null +++ b/sdk/src/test/resources/__files/requests_estimate.json @@ -0,0 +1,44 @@ +{ + "price": { + "surge_confirmation_href": null, + "high_estimate": 10, + "surge_confirmation_id": null, + "minimum": 7, + "low_estimate": 7, + "fare_breakdown": [ + { + "high_amount": 2.0, + "display_amount": "2.00", + "display_name": "Base Fare", + "low_amount": 2.0 + }, + { + "high_amount": 2.59, + "display_amount": "1.94-2.59", + "display_name": "Distance", + "low_amount": 1.94 + }, + { + "high_amount": 1.55, + "display_amount": "1.55", + "display_name": "Booking Fee", + "low_amount": 1.55 + }, + { + "high_amount": 3.08, + "display_amount": "2.31-3.08", + "display_name": "Time", + "low_amount": 2.31 + } + ], + "surge_multiplier": 1.0, + "display": "$7-10", + "currency_code": "USD" + }, + "trip": { + "distance_unit": "mile", + "duration_estimate": 720, + "distance_estimate": 1.88 + }, + "pickup_estimate": 2 +} \ No newline at end of file