Skip to content

Commit 94a3520

Browse files
author
Alex Texter
committed
[Gradle Release Plugin] - pre tag commit: 'v0.6.0'.
1 parent 45b68d0 commit 94a3520

31 files changed

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

417
v0.5.2 - 7/11/2016
518
------------

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.0

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: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949

5050
import javax.annotation.Nullable;
5151

52-
import static com.uber.sdk.rides.client.SessionConfiguration.EndpointRegion.WORLD;
53-
5452
/**
5553
* Utility for creating and managing OAuth 2.0 Credentials.
5654
*/
@@ -69,7 +67,6 @@ public class OAuth2Credentials {
6967
*/
7068
public static class Builder {
7169

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

8280
/**
8381
* Set the {@link SessionConfiguration} information
8482
*/
8583
public Builder setSessionConfiguration(SessionConfiguration configuration) {
86-
this.loginRegion = configuration.getEndpointRegion();
8784
if (scopes != null) {
8885
this.scopes = new HashSet<>(configuration.getScopes());
8986
}
@@ -95,14 +92,7 @@ public Builder setSessionConfiguration(SessionConfiguration configuration) {
9592
this.clientId = configuration.getClientId();
9693
this.clientSecret = configuration.getClientSecret();
9794
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;
95+
this.loginHost = configuration.getLoginHost();
10696
return this;
10797
}
10898

@@ -205,21 +195,17 @@ public OAuth2Credentials build() {
205195
credentialDataStoreFactory = MemoryDataStoreFactory.getDefaultInstance();
206196
}
207197

208-
if (loginRegion == null) {
209-
loginRegion = WORLD;
210-
}
211-
212198
if (authorizationCodeFlow == null) {
213199
try {
214200
AuthorizationCodeFlow.Builder builder =
215201
new AuthorizationCodeFlow.Builder(
216202
BearerToken.authorizationHeaderAccessMethod(),
217203
httpTransport,
218204
new JacksonFactory(),
219-
new GenericUrl(getLoginDomain(loginRegion) + TOKEN_PATH),
205+
new GenericUrl(loginHost + TOKEN_PATH),
220206
new ClientParametersAuthentication(clientId, clientSecret),
221207
clientId,
222-
getLoginDomain(loginRegion) + AUTHORIZATION_PATH);
208+
loginHost + AUTHORIZATION_PATH);
223209
if (oAuth2Credentials.scopes != null && !oAuth2Credentials.scopes.isEmpty()) {
224210
builder.setScopes(oAuth2Credentials.scopes);
225211
}
@@ -232,10 +218,6 @@ public OAuth2Credentials build() {
232218
oAuth2Credentials.authorizationCodeFlow = authorizationCodeFlow;
233219
return oAuth2Credentials;
234220
}
235-
236-
private String getLoginDomain(SessionConfiguration.EndpointRegion endpointRegion) {
237-
return "https://login." + endpointRegion.domain;
238-
}
239221
}
240222

241223
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
@@ -31,7 +31,7 @@
3131

3232
import javax.annotation.Nonnull;
3333

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

3737
/**
@@ -55,14 +55,20 @@ public enum Environment {
5555
}
5656

5757
public enum EndpointRegion {
58-
WORLD("uber.com"),
59-
CHINA("uber.com.cn");
58+
DEFAULT("uber.com");
6059

61-
public String domain;
60+
private String domain;
6261

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

6874
/**
@@ -73,7 +79,6 @@ public static class Builder {
7379
private String clientSecret;
7480
private String serverToken;
7581
private String redirectUri;
76-
private EndpointRegion region = EndpointRegion.WORLD;
7782
private Environment environment;
7883
private Collection<Scope> scopes;
7984
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
*
@@ -187,10 +181,6 @@ public Builder setLocale(@Nonnull Locale locale) {
187181
public SessionConfiguration build() {
188182
checkNotNull(clientId, "Client must be set");
189183

190-
if (region == null) {
191-
region = WORLD;
192-
}
193-
194184
if (environment == null) {
195185
environment = Environment.PRODUCTION;
196186
}
@@ -216,7 +206,7 @@ public SessionConfiguration build() {
216206
clientSecret,
217207
serverToken,
218208
redirectUri,
219-
region,
209+
DEFAULT,
220210
environment,
221211
scopes,
222212
customScopes,
@@ -228,7 +218,7 @@ public SessionConfiguration build() {
228218
private final String clientSecret;
229219
private final String serverToken;
230220
private final String redirectUri;
231-
private final EndpointRegion region;
221+
private final EndpointRegion endpointRegion;
232222
private final Environment environment;
233223
private final Collection<Scope> scopes;
234224
private final Collection<String> customScopes;
@@ -238,7 +228,7 @@ protected SessionConfiguration(@Nonnull String clientId,
238228
@Nonnull String clientSecret,
239229
@Nonnull String serverToken,
240230
@Nonnull String redirectUri,
241-
@Nonnull EndpointRegion region,
231+
@Nonnull EndpointRegion endpointRegion,
242232
@Nonnull Environment environment,
243233
@Nonnull Collection<Scope> scopes,
244234
@Nonnull Collection<String> customScopes,
@@ -247,7 +237,7 @@ protected SessionConfiguration(@Nonnull String clientId,
247237
this.clientSecret = clientSecret;
248238
this.serverToken = serverToken;
249239
this.redirectUri = redirectUri;
250-
this.region = region;
240+
this.endpointRegion = endpointRegion;
251241
this.environment = environment;
252242
this.scopes = scopes;
253243
this.customScopes = customScopes;
@@ -291,30 +281,38 @@ public String getRedirectUri() {
291281
}
292282

293283
/**
294-
* Gets the current {@link EndpointRegion} the SDK is using.
295-
* Defaults to {@link EndpointRegion#WORLD}.
284+
* Gets the environment configured, either {@link Environment#PRODUCTION} or {@link Environment#SANDBOX}
296285
*
297-
* @return The {@link EndpointRegion} the SDK is using.
286+
* @return {@link Environment} that is configured
298287
*/
299-
public EndpointRegion getEndpointRegion() {
300-
return region;
288+
public Environment getEnvironment() {
289+
return environment;
301290
}
302291

303292
/**
304-
* Gets the environment configured, either {@link Environment#PRODUCTION} or {@link Environment#SANDBOX}
293+
* Gets the current {@link EndpointRegion} the SDK is using.
294+
* Defaults to {@link EndpointRegion#DEFAULT}.
305295
*
306-
* @return {@link Environment} that is configured
296+
* @return the {@link EndpointRegion} the SDK us using.
307297
*/
308-
public Environment getEnvironment() {
309-
return environment;
298+
public EndpointRegion getEndpointRegion() {
299+
return endpointRegion;
310300
}
311301

312302
/**
313303
* Gets the endpoint host used to hit the Uber API.
314304
*/
315305
@Nonnull
316306
public String getEndpointHost() {
317-
return String.format("https://%s.%s", environment.subDomain, region.domain);
307+
return String.format("https://%s.%s", environment.subDomain, DEFAULT.getDomain());
308+
}
309+
310+
/**
311+
* Gets the login host used to sign in to the Uber API.
312+
*/
313+
@Nonnull
314+
public String getLoginHost() {
315+
return String.format("https://login.%s", DEFAULT.getDomain());
318316
}
319317

320318
/**
@@ -347,7 +345,6 @@ public Builder newBuilder() {
347345
return new Builder()
348346
.setClientId(clientId)
349347
.setRedirectUri(redirectUri)
350-
.setEndpointRegion(region)
351348
.setEnvironment(environment)
352349
.setScopes(scopes);
353350
}

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)