Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.uber.sdk.rides.client.model.Ride;
import com.uber.sdk.rides.client.model.RideEstimate;
import com.uber.sdk.rides.client.model.RideMap;
import com.uber.sdk.rides.client.model.RideReceipt;
import com.uber.sdk.rides.client.model.RideRequestParameters;
import com.uber.sdk.rides.client.model.RideUpdateParameters;
import com.uber.sdk.rides.client.model.SandboxProductRequestParameters;
Expand Down Expand Up @@ -223,6 +224,14 @@ void updateRide(@Nonnull String rideId,
*/
void getRideDetails(@Nonnull String rideId, Callback<Ride> callback);

/**
* Get receipt information for a completed request.
*
* @param rideId The unique identifier of a ride.
* @param callback The request callback.
*/
void getRideReceipt(@Nonnull String rideId, Callback<RideReceipt> callback);

/**
* <p>
* The request estimate endpoint allows a ride to be estimated given the desired product, start,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.uber.sdk.rides.client.model.Ride;
import com.uber.sdk.rides.client.model.RideEstimate;
import com.uber.sdk.rides.client.model.RideMap;
import com.uber.sdk.rides.client.model.RideReceipt;
import com.uber.sdk.rides.client.model.RideRequestParameters;
import com.uber.sdk.rides.client.model.RideUpdateParameters;
import com.uber.sdk.rides.client.model.SandboxProductRequestParameters;
Expand Down Expand Up @@ -201,6 +202,13 @@ Response<Void> updateRide(@Nonnull String rideId, @Nonnull RideUpdateParameters
*/
Response<Ride> getRideDetails(@Nonnull String rideId) throws ApiException, NetworkException;

/**
* Get receipt information for a completed request.
*
* @param rideId The unique identifier of a ride.
*/
Response<RideReceipt> getRideReceipt(@Nonnull String rideId) throws ApiException, NetworkException;

/**
* <p>
* The request estimate endpoint allows a ride to be estimated given the desired product, start,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import com.uber.sdk.rides.client.error.NetworkException;
import com.uber.sdk.rides.client.error.SurgeError;
import com.uber.sdk.rides.client.error.UberError;
import com.uber.sdk.rides.client.model.PaymentMethod;
import com.uber.sdk.rides.client.model.PaymentMethodsResponse;
import com.uber.sdk.rides.client.model.Place;
import com.uber.sdk.rides.client.model.Place.Places;
Expand All @@ -52,6 +51,7 @@
import com.uber.sdk.rides.client.model.Ride;
import com.uber.sdk.rides.client.model.RideEstimate;
import com.uber.sdk.rides.client.model.RideMap;
import com.uber.sdk.rides.client.model.RideReceipt;
import com.uber.sdk.rides.client.model.RideRequestParameters;
import com.uber.sdk.rides.client.model.RideUpdateParameters;
import com.uber.sdk.rides.client.model.SandboxProductRequestParameters;
Expand Down Expand Up @@ -364,6 +364,20 @@ public Response<Ride> getRideDetails(@Nonnull String rideId) throws ApiException
return transformFuture(future);
}

@Override
public void getRideReceipt(@Nonnull String rideId, Callback<RideReceipt> callback) {
service.getRideReceipt(rideId, new InternalCallback<RideReceipt>(callback));
}

@Override
public Response<RideReceipt> getRideReceipt(@Nonnull String rideId) throws ApiException, NetworkException {
final SettableFuture<ResponseOrException<RideReceipt>> future = SettableFuture.create();

getRideReceipt(rideId, new SettableFutureCallback<>(future));

return transformFuture(future);
}

@Override
public void estimateRide(RideRequestParameters rideRequestParameters, Callback<RideEstimate> callback) {
service.estimateRide(rideRequestParameters, new InternalCallback<>(callback));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.uber.sdk.rides.client.model.Ride;
import com.uber.sdk.rides.client.model.RideEstimate;
import com.uber.sdk.rides.client.model.RideMap;
import com.uber.sdk.rides.client.model.RideReceipt;
import com.uber.sdk.rides.client.model.RideRequestParameters;
import com.uber.sdk.rides.client.model.RideUpdateParameters;
import com.uber.sdk.rides.client.model.SandboxProductRequestParameters;
Expand Down Expand Up @@ -226,6 +227,16 @@ void setPlace(@Nonnull @Path("place_id") String placeId,
@GET("/v1/requests/{request_id}")
void getRideDetails(@Nonnull @Path("request_id") String rideId, Callback<Ride> callback);

/**
* Get receipt information for a completed request.<br/>
* Access to this endpoint is restricted and requires whitelisting.
*
* @param rideId The unique identifier for a ride.
* @param callback The request callback.
*/
@GET("/v1/requests/{request_id}/receipt")
void getRideReceipt(@Nonnull @Path("request_id") String rideId, Callback<RideReceipt> callback);

/**
* <p>
* The request estimate endpoint allows a ride to be estimated given the desired product, start,
Expand Down
144 changes: 144 additions & 0 deletions sdk/src/main/java/com/uber/sdk/rides/client/model/RideReceipt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@

package com.uber.sdk.rides.client.model;

import java.util.List;

import javax.annotation.Nullable;

/**
* A receipt for a completed request.
* See
* <a href="https://developer.uber.com/docs/v1-requests-receipt">Ride Request Receipt</a>
* for more information.
*/
public class RideReceipt {
private String request_id;
private List<Charge> charges;
@Nullable
private Charge surge_charge;
private List<Charge> charge_adjustments;
private String normal_fare;
private String subtotal;
private String total_charged;
@Nullable
private Float total_owed;
private String currency_code;
private String duration;
private String distance;
private String distance_label;

/**
* Gets the unique ID of the ride.
*/
public String getRideId() {
return request_id;
}

/**
* Gets the charges made against the rider.
*/
public List<Charge> getCharges() {
return charges;
}

/**
* Gets the surge charge. May be {@code null} if surge pricing was not in effect.
*/
@Nullable
public Charge getSurgeCharge() {
return surge_charge;
}

/**
* Gets the adjustments made to the charges such as promotions, and fees.
*/
public List<Charge> getChargeAdjustments() {
return charge_adjustments;
}

/**
* Gets the summation of the charges.
*/
public String getNormalFare() {
return normal_fare;
}

/**
* Gets the summation of the normal_fare and surge_charge.
*/
public String getSubTotal() {
return subtotal;
}

/**
* Gets the total amount charged to the users payment method.<br/>
* This is the the subtotal (split if applicable) with taxes included.
*/
public String getTotalCharged() {
return total_charged;
}

/**
* Gets the total amount still owed after attempting to charge the user.<br/>
* May be {@code null} if amount was paid in full.
*/
@Nullable
public Float getTotalOwed() {
return total_owed;
}

/**
* Gets the ISO 4217 currency code.
*/
public String getCurrencyCode() {
return currency_code;
}

/**
* Gets the time duration of the trip in ISO 8601 HH:MM:SS format.
*/
public String getDuration() {
return duration;
}

/**
* Gets the distance of the trip charged.
*/
public String getDistance() {
return distance;
}

/**
* Gets the localized unit of distance.
*/
public String getDistanceLabel() {
return distance_label;
}

public static class Charge {
private String name;
private float amount;
private String type;

/**
* Gets the name of the charge.
*/
public String getName() {
return name;
}

/**
* Gets the amount of the charge.
*/
public float getAmount() {
return amount;
}

/**
* Gets the type of the charge.
*/
public String getType() {
return type;
}
}
}