Skip to content

Commit 870ab43

Browse files
committed
merge master
2 parents 01646bd + 80c44b9 commit 870ab43

31 files changed

+527
-388
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.project
33
.settings
44
eclipsebin
5+
.gradletasknamecache
56

67
bin
78
gen

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1-
v0.5.3 - TBD
1+
v0.6.1 - TBD
22
------------
33

4+
v0.6.0 - 11/11/2016
5+
------------
6+
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.
7+
8+
### Added
9+
- Fare to RideEstimate, this will be returned in the case of a product that supports upfront pricing.
10+
11+
- [Pull #24](https://github.com/uber/rides-java-sdk/pull/24) Add Ride.Status
12+
- [Pull #24](https://github.com/uber/rides-java-sdk/pull/24) Add SMS number field to Driver
13+
14+
### Breaking
15+
- Price in RideEstimate is now Estimate and will be null for products that support upfront pricing.
16+
- PriceEstimate uses BigDecimal in place of Integer for our low and high estimates.
17+
- RideRequestButton now requires both a pickup and a dropoff for estimating.
18+
- Removed all China endpoint support.
19+
420
v0.5.2 - 7/11/2016
521
------------
622
### Added

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ This SDK helps your Java App make HTTP requests to the Uber Rides API.
88
#### Before you begin
99
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.
1010

11-
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.
11+
Note: Using Android? Be sure to checkout the [Uber Android SDK](github.com/uber/rides-android-sdk) in addition, which has native authentication mechanisms.
1212

1313
#### Gradle
1414
If using Gradle, add this to your project’s `build.gradle` file:
1515
```gradle
1616
dependencies {
17-
compile 'com.uber.sdk:rides:0.5.2'
17+
compile 'com.uber.sdk:rides:0.6.0'
1818
}
1919
```
2020

@@ -24,7 +24,7 @@ If using Maven, add this to your project's `pom.xml` file:
2424
<dependency>
2525
<groupId>com.uber.sdk</groupId>
2626
<artifactId>rides</artifactId>
27-
<version>0.5.2</version>
27+
<version>0.6.0</version>
2828
</dependency>
2929
```
3030

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ group=com.uber.sdk
2424
groupId=com.uber.sdk
2525
artifactId=rides
2626
githubDownloadPrefix=https://github.com/uber/rides-java-sdk/releases/download/
27-
version=0.5.3-SNAPSHOT
27+
version=0.6.1-SNAPSHOT

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ distributionBase=GRADLE_USER_HOME
2525
distributionPath=wrapper/dists
2626
zipStoreBase=GRADLE_USER_HOME
2727
zipStorePath=wrapper/dists
28-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
28+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

sdk/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ uploadArchives {
111111
name 'Alex Texter'
112112
113113
}
114+
115+
developer {
116+
id 'tyvsmith'
117+
name 'Ty Smith'
118+
119+
}
114120
}
115121
}
116122
}
@@ -123,6 +129,7 @@ dependencies {
123129

124130
compile 'com.squareup.retrofit2:retrofit:2.0.2'
125131
compile 'com.squareup.retrofit2:converter-moshi:2.0.2'
132+
compile 'com.squareup.moshi:moshi:1.2.0'
126133
compile 'com.squareup.okhttp3:okhttp:3.2.0'
127134
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
128135

sdk/src/main/java/com/uber/sdk/core/auth/AccessTokenAuthenticator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
public class AccessTokenAuthenticator implements Authenticator {
3939

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

4343
private final SessionConfiguration sessionConfiguration;
4444
private final AccessTokenStorage tokenStorage;
@@ -48,8 +48,7 @@ public AccessTokenAuthenticator(SessionConfiguration sessionConfiguration,
4848
AccessTokenStorage tokenStorage) {
4949
this(sessionConfiguration,
5050
tokenStorage,
51-
createOAuthService(String.format(TOKEN_URL,
52-
sessionConfiguration.getEndpointRegion().domain)));
51+
createOAuthService(String.format(TOKEN_URL, sessionConfiguration.getLoginHost())));
5352
}
5453

5554
AccessTokenAuthenticator(SessionConfiguration sessionConfiguration,

sdk/src/main/java/com/uber/sdk/rides/auth/OAuth2Credentials.java

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@
2222

2323
package com.uber.sdk.rides.auth;
2424

25-
import com.google.api.client.auth.oauth2.AuthorizationCodeFlow;
26-
import com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest;
27-
import com.google.api.client.auth.oauth2.BearerToken;
28-
import com.google.api.client.auth.oauth2.ClientParametersAuthentication;
29-
import com.google.api.client.auth.oauth2.Credential;
30-
import com.google.api.client.auth.oauth2.TokenResponse;
25+
import com.google.api.client.auth.oauth2.*;
3126
import com.google.api.client.http.GenericUrl;
3227
import com.google.api.client.http.HttpTransport;
3328
import com.google.api.client.http.javanet.NetHttpTransport;
@@ -39,6 +34,7 @@
3934
import com.uber.sdk.rides.client.SessionConfiguration;
4035
import com.uber.sdk.rides.client.utils.Preconditions;
4136

37+
import javax.annotation.Nullable;
4238
import java.io.IOException;
4339
import java.io.UnsupportedEncodingException;
4440
import java.net.URLEncoder;
@@ -47,10 +43,6 @@
4743
import java.util.Set;
4844
import java.util.TreeSet;
4945

50-
import javax.annotation.Nullable;
51-
52-
import static com.uber.sdk.rides.client.SessionConfiguration.EndpointRegion.WORLD;
53-
5446
/**
5547
* Utility for creating and managing OAuth 2.0 Credentials.
5648
*/
@@ -69,7 +61,6 @@ public class OAuth2Credentials {
6961
*/
7062
public static class Builder {
7163

72-
private SessionConfiguration.EndpointRegion loginRegion;
7364
private Set<Scope> scopes;
7465
private Set<String> customScopes;
7566
private String clientId;
@@ -78,12 +69,12 @@ public static class Builder {
7869
private HttpTransport httpTransport;
7970
private AuthorizationCodeFlow authorizationCodeFlow;
8071
private AbstractDataStoreFactory credentialDataStoreFactory;
72+
private String loginHost = "https://login.uber.com";
8173

8274
/**
8375
* Set the {@link SessionConfiguration} information
8476
*/
8577
public Builder setSessionConfiguration(SessionConfiguration configuration) {
86-
this.loginRegion = configuration.getEndpointRegion();
8778
if (scopes != null) {
8879
this.scopes = new HashSet<>(configuration.getScopes());
8980
}
@@ -95,14 +86,7 @@ public Builder setSessionConfiguration(SessionConfiguration configuration) {
9586
this.clientId = configuration.getClientId();
9687
this.clientSecret = configuration.getClientSecret();
9788
this.redirectUri = configuration.getRedirectUri();
98-
return this;
99-
}
100-
101-
/**
102-
* Sets the authorization server domain.
103-
*/
104-
public Builder setLoginRegion(SessionConfiguration.EndpointRegion loginRegion) {
105-
this.loginRegion = loginRegion;
89+
this.loginHost = configuration.getLoginHost();
10690
return this;
10791
}
10892

@@ -205,21 +189,17 @@ public OAuth2Credentials build() {
205189
credentialDataStoreFactory = MemoryDataStoreFactory.getDefaultInstance();
206190
}
207191

208-
if (loginRegion == null) {
209-
loginRegion = WORLD;
210-
}
211-
212192
if (authorizationCodeFlow == null) {
213193
try {
214194
AuthorizationCodeFlow.Builder builder =
215195
new AuthorizationCodeFlow.Builder(
216196
BearerToken.authorizationHeaderAccessMethod(),
217197
httpTransport,
218198
new JacksonFactory(),
219-
new GenericUrl(getLoginDomain(loginRegion) + TOKEN_PATH),
199+
new GenericUrl(loginHost + TOKEN_PATH),
220200
new ClientParametersAuthentication(clientId, clientSecret),
221201
clientId,
222-
getLoginDomain(loginRegion) + AUTHORIZATION_PATH);
202+
loginHost + AUTHORIZATION_PATH);
223203
if (oAuth2Credentials.scopes != null && !oAuth2Credentials.scopes.isEmpty()) {
224204
builder.setScopes(oAuth2Credentials.scopes);
225205
}
@@ -232,10 +212,6 @@ public OAuth2Credentials build() {
232212
oAuth2Credentials.authorizationCodeFlow = authorizationCodeFlow;
233213
return oAuth2Credentials;
234214
}
235-
236-
private String getLoginDomain(SessionConfiguration.EndpointRegion endpointRegion) {
237-
return "https://login." + endpointRegion.domain;
238-
}
239215
}
240216

241217
private OAuth2Credentials() {}

sdk/src/main/java/com/uber/sdk/rides/client/SessionConfiguration.java

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import java.util.HashSet;
3131
import java.util.Locale;
3232

33-
import static com.uber.sdk.rides.client.SessionConfiguration.EndpointRegion.WORLD;
33+
import static com.uber.sdk.rides.client.SessionConfiguration.EndpointRegion.DEFAULT;
3434
import static com.uber.sdk.rides.client.utils.Preconditions.checkNotNull;
3535

3636
/**
@@ -54,14 +54,20 @@ public enum Environment {
5454
}
5555

5656
public enum EndpointRegion {
57-
WORLD("uber.com"),
58-
CHINA("uber.com.cn");
57+
DEFAULT("uber.com");
5958

60-
public String domain;
59+
private String domain;
6160

6261
EndpointRegion(String domain) {
6362
this.domain = domain;
6463
}
64+
65+
/**
66+
* @return domain to use.
67+
*/
68+
public String getDomain() {
69+
return domain;
70+
}
6571
}
6672

6773
/**
@@ -72,7 +78,6 @@ public static class Builder {
7278
private String clientSecret;
7379
private String serverToken;
7480
private String redirectUri;
75-
private EndpointRegion region = EndpointRegion.WORLD;
7681
private Environment environment;
7782
private Collection<Scope> scopes;
7883
private Collection<String> customScopes;
@@ -126,17 +131,6 @@ public Builder setRedirectUri(@Nonnull String redirectUri) {
126131
return this;
127132
}
128133

129-
/**
130-
* Set the {@link EndpointRegion} your app is registered in.
131-
* Used to determine what endpoints to send requests to.
132-
*
133-
* @param region The {@link EndpointRegion} the SDK should use
134-
*/
135-
public Builder setEndpointRegion(@Nonnull EndpointRegion region) {
136-
this.region = region;
137-
return this;
138-
}
139-
140134
/**
141135
* Sets the {@link Environment} to be used for API requests
142136
*
@@ -192,10 +186,6 @@ public Builder setLocale(@Nonnull Locale locale) {
192186
public SessionConfiguration build() {
193187
checkNotNull(clientId, "Client must be set");
194188

195-
if (region == null) {
196-
region = WORLD;
197-
}
198-
199189
if (environment == null) {
200190
environment = Environment.PRODUCTION;
201191
}
@@ -221,7 +211,7 @@ public SessionConfiguration build() {
221211
clientSecret,
222212
serverToken,
223213
redirectUri,
224-
region,
214+
DEFAULT,
225215
environment,
226216
baseUrl,
227217
scopes,
@@ -234,7 +224,7 @@ public SessionConfiguration build() {
234224
private final String clientSecret;
235225
private final String serverToken;
236226
private final String redirectUri;
237-
private final EndpointRegion region;
227+
private final EndpointRegion endpointRegion;
238228
private final Environment environment;
239229
private final String baseUrl;
240230
private final Collection<Scope> scopes;
@@ -245,7 +235,7 @@ protected SessionConfiguration(@Nonnull String clientId,
245235
@Nonnull String clientSecret,
246236
@Nonnull String serverToken,
247237
@Nonnull String redirectUri,
248-
@Nonnull EndpointRegion region,
238+
@Nonnull EndpointRegion endpointRegion,
249239
@Nonnull Environment environment,
250240
String baseUrl,
251241
@Nonnull Collection<Scope> scopes,
@@ -255,7 +245,7 @@ protected SessionConfiguration(@Nonnull String clientId,
255245
this.clientSecret = clientSecret;
256246
this.serverToken = serverToken;
257247
this.redirectUri = redirectUri;
258-
this.region = region;
248+
this.endpointRegion = endpointRegion;
259249
this.environment = environment;
260250
this.baseUrl = baseUrl;
261251
this.scopes = scopes;
@@ -300,22 +290,22 @@ public String getRedirectUri() {
300290
}
301291

302292
/**
303-
* Gets the current {@link EndpointRegion} the SDK is using.
304-
* Defaults to {@link EndpointRegion#WORLD}.
293+
* Gets the environment configured, either {@link Environment#PRODUCTION} or {@link Environment#SANDBOX}
305294
*
306-
* @return The {@link EndpointRegion} the SDK is using.
295+
* @return {@link Environment} that is configured
307296
*/
308-
public EndpointRegion getEndpointRegion() {
309-
return region;
297+
public Environment getEnvironment() {
298+
return environment;
310299
}
311300

312301
/**
313-
* Gets the environment configured, either {@link Environment#PRODUCTION} or {@link Environment#SANDBOX}
302+
* Gets the current {@link EndpointRegion} the SDK is using.
303+
* Defaults to {@link EndpointRegion#DEFAULT}.
314304
*
315-
* @return {@link Environment} that is configured
305+
* @return the {@link EndpointRegion} the SDK us using.
316306
*/
317-
public Environment getEnvironment() {
318-
return environment;
307+
public EndpointRegion getEndpointRegion() {
308+
return endpointRegion;
319309
}
320310

321311
/**
@@ -325,7 +315,15 @@ public Environment getEnvironment() {
325315
public String getEndpointHost() {
326316
return baseUrl != null ?
327317
baseUrl :
328-
String.format("https://%s.%s", environment.subDomain, region.domain);
318+
String.format("https://%s.%s", environment.subDomain, DEFAULT.getDomain());
319+
}
320+
321+
/**
322+
* Gets the login host used to sign in to the Uber API.
323+
*/
324+
@Nonnull
325+
public String getLoginHost() {
326+
return String.format("https://login.%s", DEFAULT.getDomain());
329327
}
330328

331329
/**
@@ -358,7 +356,6 @@ public Builder newBuilder() {
358356
return new Builder()
359357
.setClientId(clientId)
360358
.setRedirectUri(redirectUri)
361-
.setEndpointRegion(region)
362359
.setEnvironment(environment)
363360
.setScopes(scopes);
364361
}

sdk/src/main/java/com/uber/sdk/rides/client/UberRidesApi.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import com.squareup.moshi.Moshi;
2626
import com.uber.sdk.rides.client.internal.ApiInterceptor;
27+
import com.uber.sdk.rides.client.internal.BigDecimalAdapter;
2728
import com.uber.sdk.rides.client.internal.RefreshAuthenticator;
2829
import com.uber.sdk.rides.client.services.RidesService;
2930
import okhttp3.OkHttpClient;
@@ -126,7 +127,7 @@ OkHttpClient createClient(OkHttpClient client,
126127
}
127128

128129
Retrofit createRetrofit(OkHttpClient client, Session session) {
129-
Moshi moshi = new Moshi.Builder().build();
130+
Moshi moshi = new Moshi.Builder().add(new BigDecimalAdapter()).build();
130131

131132
return new Retrofit.Builder()
132133
.addConverterFactory(MoshiConverterFactory.create(moshi))

0 commit comments

Comments
 (0)