Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
vsima committed Aug 21, 2014
2 parents fbde403 + ab7920d commit f8b12ac
Show file tree
Hide file tree
Showing 14 changed files with 322 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ env:
- secure: K6WKT4qqLDBlrxrlRysqYmDe7ZCjltcekpxRQFa3EV255p4PfAYdkvS2zejiyrT5Chp3d2Eikk5Yu1GzevYX3BjvnGgBKhZaZne/DnZxWVajTqzbREw5drrzJAofrPWDMc3D8xQy5/NsGWC1uB/v5VK4c14lnuQbJZlT3jiNWfA=
- secure: NQyhY89YFVoaDUks9XBuuJSYABzpVZBS+r4b6FZyjvlSIwpW7bYyNZeKo9KBrTEECYPvL2S2+j6TdRDGvpzxIuKj9OmQ0Sw/xl6Nma2cvIhlE+tlGxTdgoYxDWDeld54NT8O22KbRy6QJiWjiHV6/56iOA/5/8hcwBNILCFb9yQ=
- secure: x+OuCP9Qo9y9wyEaV7Dw8LqjbBsYKEkq2DbCp3ei1Gpd9N4B9JZJ/OU5Z8w6widy15v/1STWLWruNXkwsa4/7ssyAubpQ/KbFyfQEFK4NjTJvuBoBPmmVGMAVfuwq45RXc6vL5QBK3LoagdDDTBtbnF3L6pWIU3eCv9G7TuZKPw=
- secure: UiseiTT+yq+FLPaYh4sZR1UXw75Hm2HGnt3ACSRwN7EQUpzVz2q8/m1wKEI+tIDGM2kJd+GOGCZj9xKXxwmVkyG9XSeFLivt9JkgdKn4t6KULsRO89sqIBYHG6MirkMdGmt4a646HzRaLfe9LJaHCy7/T12ioauUpPTQNHWoFew=
- secure: asVAo2s431NC9k9pvrwQv4xzs58j5WExnPU6+xZNbHFtJkKPyhTl6ZJWXlGUZjYczyuHHArsaX/D5s0yPPe1IEiBlhka+5xwusm0bOI6n8Vj8LKfCi4PzcA7h6YNMA08MlMxPqGMXEkQDbZQp5+FPlzx4Ru0cDA+NEApObvJnE0=
- secure: YzTbYm25xKsVAH3EoCJ0vPR5g5TqeeiMlpRL1Qlt2IbhqiVyj/T7O3AFiXNBsao+xt3zeinZuZlJL5Do4eh8VisOwPdnWYoPcY9a8kuc2b+7ihFN+GWztE7UkQvxI4v1pPzPzcz5R53kYnyc8nBetx0hIluMNn0PuTVR5fUOKPM=
- secure: D1YgbcQgtvZLXD39laqL2KkvItOsYbYAnBMBcZV64m/9Eb8Jc3TexhaYvCYVMJinCltEL629LwWfy6zklgmmGROgAX+16VPl0ggG4xpJEGfdQ334e30nuH6pgY3o23NembCF06HXA0l1ZCOmrUMfkoWKL5V0W2TqV0Rq+U3MPDg=
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

#Uber API client for Android & Java
This is an an api client library for Uber's new public api for Android and Java applications.
An api client library for Uber's public rest api for Android and Java applications. This library currently supports all api calls using server_token authentication:
* product types
* price estimates
* time estimates

##Build Status
[![Build Status](https://travis-ci.org/vsima/uber-java-client.svg?branch=master)](https://travis-ci.org/vsima/uber-java-client)
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'java'
apply plugin: 'jacoco'

sourceCompatibility = 1.7
version = '1.0'
version = '0.0.1'

repositories {
mavenCentral()
Expand All @@ -11,7 +11,7 @@ repositories {
dependencies {
compile 'com.squareup.retrofit:retrofit:1.5.1'
compile 'com.squareup.okhttp:okhttp:1.5.4'
compile 'com.netflix.rxjava:rxjava-core:0.17.0'
//compile 'com.netflix.rxjava:rxjava-core:0.17.0'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
test {
Expand Down
77 changes: 74 additions & 3 deletions src/main/java/com/victorsima/uber/UberService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.victorsima.uber;

import com.victorsima.uber.model.Prices;
import com.victorsima.uber.model.Products;
import com.victorsima.uber.model.Times;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Header;
Expand All @@ -11,11 +13,80 @@
*/
public interface UberService {

/**
* The Products endpoint returns information about the Uber products offered at a given location. The response
* includes the display name and other details about each product, and lists the products in the proper
* display order.
*
* @param latitude Latitude component of location.
* @param longitude Longitude component of location.
* @return
*/
@GET("/products")
Products getProducts(@Query("latitude") double latitude,
@Query("longitude") double longitude);

/**
* @see #getProducts(double, double)
*/
@GET("/products")
void getProducts(@Query("latitude") double latitude,
@Query("longitude") double longitude,
Callback<Products> productsCallback);
@GET("/products")
Products getProducts(@Query("latitude") double latitude,
@Query("longitude") double longitude);




/**
* The Price Estimates endpoint returns an estimated price range for each product offered at a given location.
* The price estimate is provided as a formatted string with the full price range and the localized currency
* symbol.
*
* @param startLatitude Latitude component of start location.
* @param startLongitude Longitude component of start location.
* @param endLatitude Latitude component of end location.
* @param endLongitude Longitude component of end location.
* @return
*/
@GET("/estimates/price")
Prices getPriceEstimates(@Query("start_latitude") double startLatitude,
@Query("start_longitude") double startLongitude,
@Query("end_latitude") double endLatitude,
@Query("end_longitude") double endLongitude);

/**
* @see #getPriceEstimates(double, double, double, double)
*/
@GET("/estimates/price")
void getPriceEstimates(@Query("start_latitude") double startLatitude,
@Query("start_longitude") double startLongitude,
@Query("end_latitude") double endLatitude,
@Query("end_longitude") double endLongitude,
Callback<Prices> productsCallback);

/**
* The Time Estimates endpoint returns ETAs for all products offered at a given location, with the responses
* expressed as integers in seconds. We recommend that this endpoint be called every minute to provide the
* most accurate, up-to-date ETAs.
*
* @param startLatitude Latitude component.
* @param startLongitude Longitude component.
* @param customerUUID (optional) Unique customer identifier to be used for experience customization.
* @param productId (optional) Unique identifier representing a specific product for a given latitude & longitude.
* @return
*/
@GET("/estimates/time")
Times getTimeEstimates(@Query("start_latitude") double startLatitude,
@Query("start_longitude") double startLongitude,
@Query("customer_uuid") String customerUUID,
@Query("product_id") String productId);

/**
* @see #getTimeEstimates(double, double, String, String)
*/
void getTimeEstimates(@Query("start_latitude") double startLatitude,
@Query("start_longitude") double startLongitude,
@Query("customer_uuid") String customerUUID,
@Query("product_id") String productId,
Callback<Times> timesCallback);
}
4 changes: 3 additions & 1 deletion src/main/java/com/victorsima/uber/model/AccessToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
* Uber Oauth2 AccessToken model obj
*/
public class AccessToken {

@Expose
Expand Down
95 changes: 95 additions & 0 deletions src/main/java/com/victorsima/uber/model/Price.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.victorsima.uber.model;


import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
* Price model obj
*/
public class Price {

@Expose
@SerializedName("product_id")
private String productId;

@Expose
@SerializedName("currency_code")
private String currencyCode;//TODO: parse to java.util.Currency

@Expose
@SerializedName("display_name")
private String displayName;

@Expose
@SerializedName("estimate")
private String estimate;

@Expose
@SerializedName("low_estimate")
private int lowEstimate;

@Expose
@SerializedName("high_estimate")
private int highEstimate;

@Expose
@SerializedName("surge_multiplier")
private float surgeMultiplier;

public String getProductId() {
return productId;
}

public void setProductId(String productId) {
this.productId = productId;
}

public String getCurrencyCode() {
return currencyCode;
}

public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}

public String getDisplayName() {
return displayName;
}

public void setDisplayName(String displayName) {
this.displayName = displayName;
}

public String getEstimate() {
return estimate;
}

public void setEstimate(String estimate) {
this.estimate = estimate;
}

public int getLowEstimate() {
return lowEstimate;
}

public void setLowEstimate(int lowEstimate) {
this.lowEstimate = lowEstimate;
}

public int getHighEstimate() {
return highEstimate;
}

public void setHighEstimate(int highEstimate) {
this.highEstimate = highEstimate;
}

public float getSurgeMultiplier() {
return surgeMultiplier;
}

public void setSurgeMultiplier(float surgeMultiplier) {
this.surgeMultiplier = surgeMultiplier;
}
}
25 changes: 25 additions & 0 deletions src/main/java/com/victorsima/uber/model/Prices.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.victorsima.uber.model;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
* Prices model obj
*/
public class Prices {


@Expose
@SerializedName("prices")
private List<Price> prices;

public List<Price> getPrices() {
return prices;
}

public void setPrices(List<Price> prices) {
this.prices = prices;
}
}
3 changes: 1 addition & 2 deletions src/main/java/com/victorsima/uber/model/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import com.google.gson.annotations.SerializedName;

/**
* Created by victorsima on 8/20/14.
* Product model obj
*/
public class Product {


@Expose
@SerializedName("product_id")
private String productId;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/victorsima/uber/model/Products.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;

/**
* Created by victorsima on 8/20/14.
* Products model obj
*/
public class Products {

Expand Down
46 changes: 46 additions & 0 deletions src/main/java/com/victorsima/uber/model/Time.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.victorsima.uber.model;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
* Time model obj
*/
public class Time {

@Expose
@SerializedName("product_id")
private String productId;

@Expose
@SerializedName("display_name")
private String displayName;

@Expose
@SerializedName("estimate")
private int estimate;

public String getProductId() {
return productId;
}

public void setProductId(String productId) {
this.productId = productId;
}

public String getDisplayName() {
return displayName;
}

public void setDisplayName(String displayName) {
this.displayName = displayName;
}

public int getEstimate() {
return estimate;
}

public void setEstimate(int estimate) {
this.estimate = estimate;
}
}
24 changes: 24 additions & 0 deletions src/main/java/com/victorsima/uber/model/Times.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.victorsima.uber.model;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
* Times model obj
*/
public class Times {

@Expose
@SerializedName("times")
private List<Time> times;

public List<Time> getTimes() {
return times;
}

public void setTimes(List<Time> times) {
this.times = times;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/victorsima/uber/model/UserActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.victorsima.uber.model;

/**
* Created by victorsima on 8/20/14.
* Uber User Activity model obj
*/
public class UserActivity {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/victorsima/uber/model/UserProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.google.gson.annotations.SerializedName;

/**
* Created by victorsima on 8/20/14.
* Uber User Profile model obj
*/
public class UserProfile {

Expand Down
Loading

0 comments on commit f8b12ac

Please sign in to comment.