Skip to content

Commit

Permalink
[Gradle Release Plugin] - pre tag commit: 'v0.5.0'.
Browse files Browse the repository at this point in the history
  • Loading branch information
tyvsmith committed Jun 2, 2016
1 parent a75c8ce commit 0ccbd46
Show file tree
Hide file tree
Showing 100 changed files with 3,947 additions and 4,012 deletions.
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
v0.5.0 - 6/2/2016
------------------
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.

### Added

#### SessionConfiguration
SessionConfiguration is a new class to hold on to client information for authentication. This is used by underlying components.

#### UberRidesApi

`UberServices` has been replaced with `UberRidesApi`, which uses a `Session` to construct Api Services

#### Sessions
`AccessTokenSession`, `ServerTokenSession`, and `CredentialSession` have been added for the three types of authentication.

#### AccessTokenStorage
A common interface to store access tokens

#### RidesService
Replaces `UberRidesSyncService` and `UberRidesAsyncService` with a Retrofit 2 based API Service. Both sync and async can be utilized directly on the resulting `Call<T>`

### Changed
- Split packaging into core and rides
- `Oauth2Credentials` now accepts a `SessionConfiguration`
- Updated from Retrofit 1 to Retrofit 2
- Updated from OkHttp2 to OkHttp3
- Removed Gauva dependency

### Breaking
- Removed `UberServices` in favor of `UberRidesApi`
- Removed `UberRidesSyncService` and `UberRidesAsyncService` in favor of `RidesService`

v0.3.0 - 5/9/2016
------------------
- Merged #7
Expand Down
92 changes: 70 additions & 22 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: This Java SDK is not suitable for Android development. We will release an official Android SDK soon.
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.3.0'
compile 'com.uber.sdk:rides:0.5.0'
}
```

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

### Authenticating and creating a session
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.
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.


#### Create a session using a server token
```java
// Get the server token for your app from the developer dashboard.
Session session = new Session.Builder()
SessionConfiguration config = new SessionConfiguration.Builder()
.setClientId("YOUR_CLIENT_ID")
.setServerToken("YOUR_SERVER_TOKEN")
.setEnvironment(Environment.PRODUCTION)
.build();

ServerTokenSession session = new ServerTokenSession(config));
```
#### Create a session using the OAuth 2 flow
In an OAuth session, the app first asks the user to authorize and then exchanges the authorization code for an access token from Uber.
Note: Make sure the redirect URI matches the callback URI in the developer dashboard for the app.

**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.
```java
OAuth2Credentials credentials = new OAuth2Credentials.Builder()
.setClientSecrets(clientId, clientSecret)
SessionConfiguration config = new SessionConfiguration.Builder()
.setClientId("YOUR_CLIENT_ID")
.setClientSecret("YOUR_CLIENT_SECRET")
.setScopes(yourScopes)
.setRedirectUri(redirectUri)
.build();

OAuth2Credentials credentials = new OAuth2Credentials.Builder()
.setSessionConfiguration(config)
.build();

```
**Step 2**. Navigate the user to the authorization URL from the OAuth2Credentials object.
```java
Expand All @@ -61,19 +70,51 @@ Credential credential = credentials.authenticate(authorizationCode, userId);
```
**Step 4**. Create a session object using the credential object.
```java
Session session = new Session.Builder()
.setCredential(credential)
.setEnvironment(Environment.PRODUCTION)
.build();
CredentialsSession session = new CredentialsSession(config, credential)
```
**Step 5**. Instantiate a service using a session to start making calls.
```java
UberRidesSyncService service = UberRidesServices.createSync(session);
RidesService service = UberRidesApi.with(session).createService();
```
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`.

## Sync vs. Async Calls
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.
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.

#### Sync
```java
Response<UserProfile> response = service.getUserProfile().execute();
if (response.isSuccessful()) {
//Success
UserProfile profile = response.body();
} else {
//Failure
ApiError error = ErrorParser.parseError(response);
}

```

#### Async
```java
service.getUserProfile().enqueue(new Callback<UserProfile>() {
@Override
public void onResponse(Call<UserProfile> call, Response<UserProfile> response) {
if (response.isSuccessful()) {
//Success
UserProfile profile = response.body();
} else {
//Api Failure
ApiError error = ErrorParser.parseError(response);
}
}

@Override
public void onFailure(Call<UserProfile> call, Throwable t) {
//Network Failure
}
});
```


## Samples for Common Calls
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.
Expand All @@ -83,8 +124,8 @@ For full documentation, visit our [Developer Site](https://developer.uber.com/v1
### Get available products
```java
// Get a list of products for a specific location in GPS coordinates, example: 37.79f, -122.39f.
ProductsResponse productsResponse = service.getProducts(37.79f, -122.39f).getBody();
List <Product> products = productsResponse.getProducts();
Response<List<Product>> response = service.getProducts(37.79f, -122.39f).execute();
List<Product> products = response.body();
String productId = products.get(0).getProductId();
```

Expand All @@ -95,30 +136,37 @@ RideRequestParameters rideRequestParameters = new RideRequestParameters.Builder(
.setProductId(productId)
.setDropoffCoordinates(37.49f, -122.41f)
.build();
Ride ride = service.requestRide(rideRequestParameters).getBody();
Ride ride = service.requestRide(rideRequestParameters).execute().body();
String rideId = ride.getRideId();
```
**Warning**: This real-world request can send an Uber driver to the specified start location. To develop
and test against endpoints in a sandbox environment, instantiate your `UberRidesService` with a `Session` whose `Environment` is set to `SANDBOX`.
This will take an existing session and generate a new one pointing to `SANDBOX`.
```java
Session session = new Session.Builder().setCredential(credential).setEnvironment(Environment.SANDBOX).build();
UberRidesSyncService service = UberRidesServices.createSync(session);

SessionConfiguration config = existingConfig.newBuilder().setEnvironment(Environment.SANDBOX).build()

CredentialsSession session = new CredentialsSession(config, credential));
RidesService service = UberRidesApi.with(session);
```
See our [documentation](https://developer.uber.com/v1/sandbox/) to learn more about the sandbox environment.

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

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

## Getting Help
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`!

## Migrating from a previous version
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!

## Contributing
We :heart: contributions. If you find a bug in the library or would like to add new features, go ahead and open
issues or pull requests against this repo. Before you do so, please sign the
Expand Down
22 changes: 22 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*
* Copyright (c) 2016 Uber Technologies, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

apply plugin: 'distribution'
apply plugin: 'net.researchgate.release'
apply plugin: 'co.riiid.gradle'
Expand Down
24 changes: 23 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
#
# Copyright (c) 2016 Uber Technologies, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

group=com.uber.sdk
groupId=com.uber.sdk
artifactId=rides
githubDownloadPrefix=https://github.com/uber/rides-java-sdk/releases/download/
version=0.3.1-SNAPSHOT
version=0.5.0
24 changes: 23 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
#
# Copyright (c) 2016 Uber Technologies, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
22 changes: 22 additions & 0 deletions samples/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*
* Copyright (c) 2016 Uber Technologies, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

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

apply plugin: 'application'

targetCompatibility = JavaVersion.VERSION_1_7
Expand Down
22 changes: 22 additions & 0 deletions samples/cmdline-sample/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
#
# Copyright (c) 2016 Uber Technologies, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

description=Command line sample

0 comments on commit 0ccbd46

Please sign in to comment.