Skip to content
Open
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 numberDiff line numberDiff line change
Expand Up@@ -83,6 +83,7 @@ public static class Builder {
private Collection<Scope> scopes;
private Collection<String> customScopes;
private Locale locale;
private String baseUrl;

/**
* The Uber API requires a registered clientId to be sent along with API requests and Deeplinks.
Expand DownExpand Up@@ -142,6 +143,11 @@ public Builder setEnvironment(@Nonnull Environment environment) {
return this;
}

public Builder setBaseUrl(@Nonnull String url) {
this.baseUrl = url;
return this;
}

/**
* Sets the Scope Collection to be used when requesting authentication
*
Expand DownExpand Up@@ -208,6 +214,7 @@ public SessionConfiguration build() {
redirectUri,
DEFAULT,
environment,
baseUrl,
scopes,
customScopes,
locale);
Expand All@@ -220,6 +227,7 @@ public SessionConfiguration build() {
private final String redirectUri;
private final EndpointRegion endpointRegion;
private final Environment environment;
private final String baseUrl;
private final Collection<Scope> scopes;
private final Collection<String> customScopes;
private final Locale locale;
Expand All@@ -230,6 +238,7 @@ protected SessionConfiguration(@Nonnull String clientId,
@Nonnull String redirectUri,
@Nonnull EndpointRegion endpointRegion,
@Nonnull Environment environment,
String baseUrl,
@Nonnull Collection<Scope> scopes,
@Nonnull Collection<String> customScopes,
@Nonnull Locale locale) {
Expand All@@ -239,6 +248,7 @@ protected SessionConfiguration(@Nonnull String clientId,
this.redirectUri = redirectUri;
this.endpointRegion = endpointRegion;
this.environment = environment;
this.baseUrl = baseUrl;
this.scopes = scopes;
this.customScopes = customScopes;
this.locale = locale;
Expand DownExpand Up@@ -304,15 +314,19 @@ public EndpointRegion getEndpointRegion() {
*/
@Nonnull
public String getEndpointHost() {
return String.format("https://%s.%s", environment.subDomain, DEFAULT.getDomain());
return baseUrl != null ?
baseUrl :
String.format("https://%s.%s", environment.subDomain, DEFAULT.getDomain());
}

/**
* Gets the login host used to sign in to the Uber API.
*/
@Nonnull
public String getLoginHost() {
return String.format("https://login.%s", DEFAULT.getDomain());
return baseUrl != null ?
baseUrl :
String.format("https://login.%s", DEFAULT.getDomain());
}

/**
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,6 @@
package com.uber.sdk.core.client;

import com.uber.sdk.core.auth.Scope;

import org.junit.Test;

import java.util.Arrays;
Expand DownExpand Up@@ -128,4 +127,13 @@ public void buildSession_whenSandboxEnv_shouldGiveSandboxEndpointHost() throws E
.setEnvironment(SANDBOX).build();
assertEquals("https://sandbox-api.uber.com", sessionConfig.getEndpointHost());
}
}

@Test
public void buildSession_whenCustomEnvUrl_shouldGiveCustomEndpointHost() throws Exception {
SessionConfiguration sessionConfig = new SessionConfiguration.Builder()
.setBaseUrl("http://localhost:8888/uber-mock")
.setClientId("clientId")
.build();
assertEquals("http://localhost:8888/uber-mock", sessionConfig.getEndpointHost());
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@
import com.squareup.moshi.Moshi;
import com.uber.sdk.core.client.internal.BigDecimalAdapter;
import com.uber.sdk.rides.WireMockTest;
import com.uber.sdk.rides.client.services.RidesService;
import com.uber.sdk.rides.client.model.Product;
import com.uber.sdk.rides.client.model.Ride;
import com.uber.sdk.rides.client.model.RideEstimate;
Expand Down