Skip to content

Commit 0ccbd46

Browse files
committed
[Gradle Release Plugin] - pre tag commit: 'v0.5.0'.
1 parent a75c8ce commit 0ccbd46

File tree

100 files changed

+3947
-4012
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+3947
-4012
lines changed

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
v0.5.0 - 6/2/2016
2+
------------------
3+
This release sets up the Java SDK for the Uber Android SDK to utilize it as a third party dependency by adding common interfaces and removing heavier weight components.
4+
5+
### Added
6+
7+
#### SessionConfiguration
8+
SessionConfiguration is a new class to hold on to client information for authentication. This is used by underlying components.
9+
10+
#### UberRidesApi
11+
12+
`UberServices` has been replaced with `UberRidesApi`, which uses a `Session` to construct Api Services
13+
14+
#### Sessions
15+
`AccessTokenSession`, `ServerTokenSession`, and `CredentialSession` have been added for the three types of authentication.
16+
17+
#### AccessTokenStorage
18+
A common interface to store access tokens
19+
20+
#### RidesService
21+
Replaces `UberRidesSyncService` and `UberRidesAsyncService` with a Retrofit 2 based API Service. Both sync and async can be utilized directly on the resulting `Call<T>`
22+
23+
### Changed
24+
- Split packaging into core and rides
25+
- `Oauth2Credentials` now accepts a `SessionConfiguration`
26+
- Updated from Retrofit 1 to Retrofit 2
27+
- Updated from OkHttp2 to OkHttp3
28+
- Removed Gauva dependency
29+
30+
### Breaking
31+
- Removed `UberServices` in favor of `UberRidesApi`
32+
- Removed `UberRidesSyncService` and `UberRidesAsyncService` in favor of `RidesService`
33+
134
v0.3.0 - 5/9/2016
235
------------------
336
- Merged #7

README.md

Lines changed: 70 additions & 22 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: This Java SDK is not suitable for Android development. We will release an official Android SDK soon.
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.3.0'
17+
compile 'com.uber.sdk:rides:0.5.0'
1818
}
1919
```
2020

@@ -24,32 +24,41 @@ 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.3.0</version>
27+
<version>0.5.0</version>
2828
</dependency>
2929
```
3030

3131
### Authenticating and creating a session
32-
To make calls, you need to create an authenticated session with the API. While operations on behalf of users require a user-authorized token using OAuth 2, general requests can use server-token authentication.
32+
To make calls, you need to create an authenticated session with the API. While operations on behalf of users require a user-authorized token using OAuth 2, general requests can use server-token authentication.
33+
3334

3435
#### Create a session using a server token
3536
```java
3637
// Get the server token for your app from the developer dashboard.
37-
Session session = new Session.Builder()
38+
SessionConfiguration config = new SessionConfiguration.Builder()
39+
.setClientId("YOUR_CLIENT_ID")
3840
.setServerToken("YOUR_SERVER_TOKEN")
39-
.setEnvironment(Environment.PRODUCTION)
4041
.build();
42+
43+
ServerTokenSession session = new ServerTokenSession(config));
4144
```
4245
#### Create a session using the OAuth 2 flow
4346
In an OAuth session, the app first asks the user to authorize and then exchanges the authorization code for an access token from Uber.
4447
Note: Make sure the redirect URI matches the callback URI in the developer dashboard for the app.
4548

4649
**Step 1**. Create an OAuth2Credentials object with your client ID, client secret, scopes, and a redirect callback URI to capture the user’s authorization code.
4750
```java
48-
OAuth2Credentials credentials = new OAuth2Credentials.Builder()
49-
.setClientSecrets(clientId, clientSecret)
51+
SessionConfiguration config = new SessionConfiguration.Builder()
52+
.setClientId("YOUR_CLIENT_ID")
53+
.setClientSecret("YOUR_CLIENT_SECRET")
5054
.setScopes(yourScopes)
5155
.setRedirectUri(redirectUri)
5256
.build();
57+
58+
OAuth2Credentials credentials = new OAuth2Credentials.Builder()
59+
.setSessionConfiguration(config)
60+
.build();
61+
5362
```
5463
**Step 2**. Navigate the user to the authorization URL from the OAuth2Credentials object.
5564
```java
@@ -61,19 +70,51 @@ Credential credential = credentials.authenticate(authorizationCode, userId);
6170
```
6271
**Step 4**. Create a session object using the credential object.
6372
```java
64-
Session session = new Session.Builder()
65-
.setCredential(credential)
66-
.setEnvironment(Environment.PRODUCTION)
67-
.build();
73+
CredentialsSession session = new CredentialsSession(config, credential)
6874
```
6975
**Step 5**. Instantiate a service using a session to start making calls.
7076
```java
71-
UberRidesSyncService service = UberRidesServices.createSync(session);
77+
RidesService service = UberRidesApi.with(session).createService();
7278
```
7379
Note: Keep each user's access token in a secure data store. Reuse the same token to make API calls on behalf of your user without repeating the authorization flow each time they visit your app. The SDK handles the token refresh automatically when it makes API requests with an `UberRidesService`.
7480

7581
## Sync vs. Async Calls
76-
Both synchronous and asynchronous calls work with the Uber rides Java SDK. Instantiate your service appropriately with `UberRidesServices.createSync(session)` or `UberRidesServices.createAsync(session)`. Asynchronous calls are returned on a platform appropriate thread accessible through callbacks.
82+
Both synchronous and asynchronous calls work with the Uber rides Java SDK. The networking stack for the Uber SDK is powered by [Retrofit 2](https://github.com/square/retrofit) and the same model of threading is available.
83+
84+
#### Sync
85+
```java
86+
Response<UserProfile> response = service.getUserProfile().execute();
87+
if (response.isSuccessful()) {
88+
//Success
89+
UserProfile profile = response.body();
90+
} else {
91+
//Failure
92+
ApiError error = ErrorParser.parseError(response);
93+
}
94+
95+
```
96+
97+
#### Async
98+
```java
99+
service.getUserProfile().enqueue(new Callback<UserProfile>() {
100+
@Override
101+
public void onResponse(Call<UserProfile> call, Response<UserProfile> response) {
102+
if (response.isSuccessful()) {
103+
//Success
104+
UserProfile profile = response.body();
105+
} else {
106+
//Api Failure
107+
ApiError error = ErrorParser.parseError(response);
108+
}
109+
}
110+
111+
@Override
112+
public void onFailure(Call<UserProfile> call, Throwable t) {
113+
//Network Failure
114+
}
115+
});
116+
```
117+
77118

78119
## Samples for Common Calls
79120
Use the Java classes in the [samples](https://github.com/uber/rides-java-sdk/tree/master/samples/cmdline-sample) folder to test standard requests. Alternatively, you can download a sample from the [releases page](https://github.com/uber/rides-java-sdk/releases/tag/v0.1.0) to try them out.
@@ -83,8 +124,8 @@ For full documentation, visit our [Developer Site](https://developer.uber.com/v1
83124
### Get available products
84125
```java
85126
// Get a list of products for a specific location in GPS coordinates, example: 37.79f, -122.39f.
86-
ProductsResponse productsResponse = service.getProducts(37.79f, -122.39f).getBody();
87-
List <Product> products = productsResponse.getProducts();
127+
Response<List<Product>> response = service.getProducts(37.79f, -122.39f).execute();
128+
List<Product> products = response.body();
88129
String productId = products.get(0).getProductId();
89130
```
90131

@@ -95,30 +136,37 @@ RideRequestParameters rideRequestParameters = new RideRequestParameters.Builder(
95136
.setProductId(productId)
96137
.setDropoffCoordinates(37.49f, -122.41f)
97138
.build();
98-
Ride ride = service.requestRide(rideRequestParameters).getBody();
139+
Ride ride = service.requestRide(rideRequestParameters).execute().body();
99140
String rideId = ride.getRideId();
100141
```
101142
**Warning**: This real-world request can send an Uber driver to the specified start location. To develop
102143
and test against endpoints in a sandbox environment, instantiate your `UberRidesService` with a `Session` whose `Environment` is set to `SANDBOX`.
144+
This will take an existing session and generate a new one pointing to `SANDBOX`.
103145
```java
104-
Session session = new Session.Builder().setCredential(credential).setEnvironment(Environment.SANDBOX).build();
105-
UberRidesSyncService service = UberRidesServices.createSync(session);
146+
147+
SessionConfiguration config = existingConfig.newBuilder().setEnvironment(Environment.SANDBOX).build()
148+
149+
CredentialsSession session = new CredentialsSession(config, credential));
150+
RidesService service = UberRidesApi.with(session);
106151
```
107152
See our [documentation](https://developer.uber.com/v1/sandbox/) to learn more about the sandbox environment.
108153

109154
### Update a ride in the sandbox
110155
If you request a ride in the sandbox, you can step through the different states of the ride.
111156
```java
112157
SandboxRideRequestParameters rideParameters = new SandboxRideRequestParameters.Builder().setStatus(“accepted”).build();
113-
Response<Void> response = client.updateSandboxRide(rideId, rideParameters);
158+
Response<Void> response = service.updateSandboxRide(rideId, rideParameters).execute();
114159
```
115-
A successful update returns a 204 for `response.getStatus()`.
160+
A successful update returns a 204 for `response.code()`.
116161

117-
Note: The `updateSandboxRide` method is not valid in the `PRODUCTION` `Environment`, where the ride status changes automatically. In a `PRODUCTION` `Environment`, the call throws an `IllegalStateException`.
162+
Note: The `updateSandboxRide` method is not valid in the `PRODUCTION` `Environment`, where the ride status changes automatically. In a `PRODUCTION` `Environment`, the call will fail.
118163

119164
## Getting Help
120165
Uber developers actively monitor the [uber-api tag](http://stackoverflow.com/questions/tagged/uber-api) on StackOverflow. If you need help installing or using the library, ask a question there. Make sure to tag your question with `uber-api` and `java`!
121166

167+
## Migrating from a previous version
168+
As the Uber SDK get closer to a 1.0 release, the API's will become more stable. In the meantime, be sure to check out the changelog to know what differs!
169+
122170
## Contributing
123171
We :heart: contributions. If you find a bug in the library or would like to add new features, go ahead and open
124172
issues or pull requests against this repo. Before you do so, please sign the

build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* Copyright (c) 2016 Uber Technologies, Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
123
apply plugin: 'distribution'
224
apply plugin: 'net.researchgate.release'
325
apply plugin: 'co.riiid.gradle'

gradle.properties

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
1+
#
2+
# Copyright (c) 2016 Uber Technologies, Inc.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
#
22+
123
group=com.uber.sdk
224
groupId=com.uber.sdk
325
artifactId=rides
426
githubDownloadPrefix=https://github.com/uber/rides-java-sdk/releases/download/
5-
version=0.3.1-SNAPSHOT
27+
version=0.5.0
Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
1+
#
2+
# Copyright (c) 2016 Uber Technologies, Inc.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
#
22+
123
#Wed Apr 10 15:27:10 PDT 2013
224
distributionBase=GRADLE_USER_HOME
325
distributionPath=wrapper/dists
426
zipStoreBase=GRADLE_USER_HOME
527
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
28+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip

samples/build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* Copyright (c) 2016 Uber Technologies, Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
123
subprojects {
224
configure(install.repositories.mavenInstaller) {
325
pom.project {

samples/cmdline-sample/build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* Copyright (c) 2016 Uber Technologies, Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
123
apply plugin: 'application'
224

325
targetCompatibility = JavaVersion.VERSION_1_7
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1+
#
2+
# Copyright (c) 2016 Uber Technologies, Inc.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
#
22+
123
description=Command line sample

0 commit comments

Comments
 (0)