Skip to content

Commit

Permalink
[Gradle Release Plugin] - pre tag commit: 'v0.6.0'.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Texter committed Nov 11, 2016
1 parent 45b68d0 commit 94a3520
Show file tree
Hide file tree
Showing 31 changed files with 524 additions and 382 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.project
.settings
eclipsebin
.gradletasknamecache

bin
gen
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
v0.5.3 - TBD
v0.6.0 - 11/11/2016
------------
This release moves all our endpoints to the new 1.2 version! This update brings support to upfront pricing and fares, which is now reflected in RideEstimate and usable in RideRequestParameters.

### Added
- Fare to RideEstimate, this will be returned in the case of a product that supports upfront pricing.

- [Pull #24](https://github.com/uber/rides-java-sdk/pull/24) Add Ride.Status
- [Pull #24](https://github.com/uber/rides-java-sdk/pull/24) Add SMS number field to Driver

### Breaking
- Price in RideEstimate is now Estimate and will be null for products that support upfront pricing.
- PriceEstimate uses BigDecimal in place of Integer for our low and high estimates.
- RideRequestButton now requires both a pickup and a dropoff for estimating.
- Removed all China endpoint support.

v0.5.2 - 7/11/2016
------------
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ This SDK helps your Java App make HTTP requests to the Uber Rides API.
#### 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.

Note: Using Android? Be sure to checkout the [Uber Android SDK](https://github.com/uber/rides-android-sdk) in addition, which has native authentication mechanisms.
Note: Using Android? Be sure to checkout the [Uber Android SDK](github.com/uber/rides-android-sdk) in addition, which has native authentication mechanisms.

#### Gradle
If using Gradle, add this to your project’s `build.gradle` file:
```gradle
dependencies {
compile 'com.uber.sdk:rides:0.5.2'
compile 'com.uber.sdk:rides:0.6.0'
}
```

Expand All @@ -24,7 +24,7 @@ If using Maven, add this to your project's `pom.xml` file:
<dependency>
<groupId>com.uber.sdk</groupId>
<artifactId>rides</artifactId>
<version>0.5.2</version>
<version>0.6.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.3-SNAPSHOT
version=0.6.0
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 changes: 7 additions & 0 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ uploadArchives {
name 'Alex Texter'
email '[email protected]'
}

developer {
id 'tyvsmith'
name 'Ty Smith'
email '[email protected]'
}
}
}
}
Expand All @@ -123,6 +129,7 @@ dependencies {

compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-moshi:2.0.2'
compile 'com.squareup.moshi:moshi:1.2.0'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
public class AccessTokenAuthenticator implements Authenticator {

private static final String HEADER_BEARER_ACCESS_VALUE = "Bearer %s";
private static final String TOKEN_URL = "https://login.%s/oauth/v2/mobile/";
private static final String TOKEN_URL = "%s/oauth/v2/mobile/";

private final SessionConfiguration sessionConfiguration;
private final AccessTokenStorage tokenStorage;
Expand All @@ -48,8 +48,7 @@ public AccessTokenAuthenticator(SessionConfiguration sessionConfiguration,
AccessTokenStorage tokenStorage) {
this(sessionConfiguration,
tokenStorage,
createOAuthService(String.format(TOKEN_URL,
sessionConfiguration.getEndpointRegion().domain)));
createOAuthService(String.format(TOKEN_URL, sessionConfiguration.getLoginHost())));
}

AccessTokenAuthenticator(SessionConfiguration sessionConfiguration,
Expand Down
26 changes: 4 additions & 22 deletions sdk/src/main/java/com/uber/sdk/rides/auth/OAuth2Credentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@

import javax.annotation.Nullable;

import static com.uber.sdk.rides.client.SessionConfiguration.EndpointRegion.WORLD;

/**
* Utility for creating and managing OAuth 2.0 Credentials.
*/
Expand All @@ -69,7 +67,6 @@ public class OAuth2Credentials {
*/
public static class Builder {

private SessionConfiguration.EndpointRegion loginRegion;
private Set<Scope> scopes;
private Set<String> customScopes;
private String clientId;
Expand All @@ -78,12 +75,12 @@ public static class Builder {
private HttpTransport httpTransport;
private AuthorizationCodeFlow authorizationCodeFlow;
private AbstractDataStoreFactory credentialDataStoreFactory;
private String loginHost = "https://login.uber.com";

/**
* Set the {@link SessionConfiguration} information
*/
public Builder setSessionConfiguration(SessionConfiguration configuration) {
this.loginRegion = configuration.getEndpointRegion();
if (scopes != null) {
this.scopes = new HashSet<>(configuration.getScopes());
}
Expand All @@ -95,14 +92,7 @@ public Builder setSessionConfiguration(SessionConfiguration configuration) {
this.clientId = configuration.getClientId();
this.clientSecret = configuration.getClientSecret();
this.redirectUri = configuration.getRedirectUri();
return this;
}

/**
* Sets the authorization server domain.
*/
public Builder setLoginRegion(SessionConfiguration.EndpointRegion loginRegion) {
this.loginRegion = loginRegion;
this.loginHost = configuration.getLoginHost();
return this;
}

Expand Down Expand Up @@ -205,21 +195,17 @@ public OAuth2Credentials build() {
credentialDataStoreFactory = MemoryDataStoreFactory.getDefaultInstance();
}

if (loginRegion == null) {
loginRegion = WORLD;
}

if (authorizationCodeFlow == null) {
try {
AuthorizationCodeFlow.Builder builder =
new AuthorizationCodeFlow.Builder(
BearerToken.authorizationHeaderAccessMethod(),
httpTransport,
new JacksonFactory(),
new GenericUrl(getLoginDomain(loginRegion) + TOKEN_PATH),
new GenericUrl(loginHost + TOKEN_PATH),
new ClientParametersAuthentication(clientId, clientSecret),
clientId,
getLoginDomain(loginRegion) + AUTHORIZATION_PATH);
loginHost + AUTHORIZATION_PATH);
if (oAuth2Credentials.scopes != null && !oAuth2Credentials.scopes.isEmpty()) {
builder.setScopes(oAuth2Credentials.scopes);
}
Expand All @@ -232,10 +218,6 @@ public OAuth2Credentials build() {
oAuth2Credentials.authorizationCodeFlow = authorizationCodeFlow;
return oAuth2Credentials;
}

private String getLoginDomain(SessionConfiguration.EndpointRegion endpointRegion) {
return "https://login." + endpointRegion.domain;
}
}

private OAuth2Credentials() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import javax.annotation.Nonnull;

import static com.uber.sdk.rides.client.SessionConfiguration.EndpointRegion.WORLD;
import static com.uber.sdk.rides.client.SessionConfiguration.EndpointRegion.DEFAULT;
import static com.uber.sdk.rides.client.utils.Preconditions.checkNotNull;

/**
Expand All @@ -55,14 +55,20 @@ public enum Environment {
}

public enum EndpointRegion {
WORLD("uber.com"),
CHINA("uber.com.cn");
DEFAULT("uber.com");

public String domain;
private String domain;

EndpointRegion(String domain) {
this.domain = domain;
}

/**
* @return domain to use.
*/
public String getDomain() {
return domain;
}
}

/**
Expand All @@ -73,7 +79,6 @@ public static class Builder {
private String clientSecret;
private String serverToken;
private String redirectUri;
private EndpointRegion region = EndpointRegion.WORLD;
private Environment environment;
private Collection<Scope> scopes;
private Collection<String> customScopes;
Expand Down Expand Up @@ -126,17 +131,6 @@ public Builder setRedirectUri(@Nonnull String redirectUri) {
return this;
}

/**
* Set the {@link EndpointRegion} your app is registered in.
* Used to determine what endpoints to send requests to.
*
* @param region The {@link EndpointRegion} the SDK should use
*/
public Builder setEndpointRegion(@Nonnull EndpointRegion region) {
this.region = region;
return this;
}

/**
* Sets the {@link Environment} to be used for API requests
*
Expand Down Expand Up @@ -187,10 +181,6 @@ public Builder setLocale(@Nonnull Locale locale) {
public SessionConfiguration build() {
checkNotNull(clientId, "Client must be set");

if (region == null) {
region = WORLD;
}

if (environment == null) {
environment = Environment.PRODUCTION;
}
Expand All @@ -216,7 +206,7 @@ public SessionConfiguration build() {
clientSecret,
serverToken,
redirectUri,
region,
DEFAULT,
environment,
scopes,
customScopes,
Expand All @@ -228,7 +218,7 @@ public SessionConfiguration build() {
private final String clientSecret;
private final String serverToken;
private final String redirectUri;
private final EndpointRegion region;
private final EndpointRegion endpointRegion;
private final Environment environment;
private final Collection<Scope> scopes;
private final Collection<String> customScopes;
Expand All @@ -238,7 +228,7 @@ protected SessionConfiguration(@Nonnull String clientId,
@Nonnull String clientSecret,
@Nonnull String serverToken,
@Nonnull String redirectUri,
@Nonnull EndpointRegion region,
@Nonnull EndpointRegion endpointRegion,
@Nonnull Environment environment,
@Nonnull Collection<Scope> scopes,
@Nonnull Collection<String> customScopes,
Expand All @@ -247,7 +237,7 @@ protected SessionConfiguration(@Nonnull String clientId,
this.clientSecret = clientSecret;
this.serverToken = serverToken;
this.redirectUri = redirectUri;
this.region = region;
this.endpointRegion = endpointRegion;
this.environment = environment;
this.scopes = scopes;
this.customScopes = customScopes;
Expand Down Expand Up @@ -291,30 +281,38 @@ public String getRedirectUri() {
}

/**
* Gets the current {@link EndpointRegion} the SDK is using.
* Defaults to {@link EndpointRegion#WORLD}.
* Gets the environment configured, either {@link Environment#PRODUCTION} or {@link Environment#SANDBOX}
*
* @return The {@link EndpointRegion} the SDK is using.
* @return {@link Environment} that is configured
*/
public EndpointRegion getEndpointRegion() {
return region;
public Environment getEnvironment() {
return environment;
}

/**
* Gets the environment configured, either {@link Environment#PRODUCTION} or {@link Environment#SANDBOX}
* Gets the current {@link EndpointRegion} the SDK is using.
* Defaults to {@link EndpointRegion#DEFAULT}.
*
* @return {@link Environment} that is configured
* @return the {@link EndpointRegion} the SDK us using.
*/
public Environment getEnvironment() {
return environment;
public EndpointRegion getEndpointRegion() {
return endpointRegion;
}

/**
* Gets the endpoint host used to hit the Uber API.
*/
@Nonnull
public String getEndpointHost() {
return String.format("https://%s.%s", environment.subDomain, region.domain);
return 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());
}

/**
Expand Down Expand Up @@ -347,7 +345,6 @@ public Builder newBuilder() {
return new Builder()
.setClientId(clientId)
.setRedirectUri(redirectUri)
.setEndpointRegion(region)
.setEnvironment(environment)
.setScopes(scopes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import com.squareup.moshi.Moshi;
import com.uber.sdk.rides.client.internal.ApiInterceptor;
import com.uber.sdk.rides.client.internal.BigDecimalAdapter;
import com.uber.sdk.rides.client.internal.RefreshAuthenticator;
import com.uber.sdk.rides.client.services.RidesService;
import okhttp3.OkHttpClient;
Expand Down Expand Up @@ -126,7 +127,7 @@ OkHttpClient createClient(OkHttpClient client,
}

Retrofit createRetrofit(OkHttpClient client, Session session) {
Moshi moshi = new Moshi.Builder().build();
Moshi moshi = new Moshi.Builder().add(new BigDecimalAdapter()).build();

return new Retrofit.Builder()
.addConverterFactory(MoshiConverterFactory.create(moshi))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ApiInterceptor implements Interceptor {
static final String HEADER_ACCESS_TOKEN = "Authorization";


static final String LIB_VERSION = "0.5.2";
static final String LIB_VERSION = "0.6.0";
static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
static final String HEADER_USER_AGENT = "X-Uber-User-Agent";

Expand Down
Loading

0 comments on commit 94a3520

Please sign in to comment.