Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save access token and request uuid in route options #669

Merged
merged 2 commits into from
Nov 30, 2017
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 @@ -135,9 +135,8 @@ public Response<DirectionsResponse> executeCall() throws IOException {
if (!response.isSuccessful()) {
errorDidOccur(null, response);
}
List<DirectionsRoute> routes = response.body().routes();
return Response.success(response.body().toBuilder().routes(
generateRouteOptions(routes)).build());
generateRouteOptions(response)).build());
}

/**
Expand All @@ -161,7 +160,7 @@ public void onResponse(Call<DirectionsResponse> call, Response<DirectionsRespons
callback.onResponse(call, response);
}
DirectionsResponse newResponse = response.body().toBuilder().routes(
generateRouteOptions(response.body().routes())).build();
generateRouteOptions(response)).build();
callback.onResponse(call, Response.success(newResponse));
}

Expand All @@ -188,8 +187,8 @@ private void errorDidOccur(@Nullable Callback<DirectionsResponse> callback,
}
}


private List<DirectionsRoute> generateRouteOptions(List<DirectionsRoute> routes) {
private List<DirectionsRoute> generateRouteOptions(Response<DirectionsResponse> response) {
List<DirectionsRoute> routes = response.body().routes();
List<DirectionsRoute> modifiedRoutes = new ArrayList<>();
for (DirectionsRoute route : routes) {
modifiedRoutes.add(route.toBuilder().routeOptions(
Expand All @@ -206,6 +205,8 @@ private List<DirectionsRoute> generateRouteOptions(List<DirectionsRoute> routes)
.bannerInstructions(bannerInstructions())
.exclude(exclude())
.voiceUnits(voiceUnits())
.accessToken(accessToken())
.requestUuid(response.body().uuid())
.build()
).build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ public static Builder builder() {
@Nullable
public abstract String voiceUnits();

public abstract String accessToken();

@Nullable
public abstract String requestUuid();

/**
* Gson type adapter for parsing Gson to this class.
*
Expand Down Expand Up @@ -249,6 +254,10 @@ public abstract static class Builder {

public abstract Builder voiceUnits(@Nullable String voiceUnits);

public abstract Builder accessToken(String accessToken);

public abstract Builder requestUuid(String requestUuid);

/**
* The same exclusions the user originally made when the request was made.
*
Expand Down