// Path: src/main/java/com/victorsima/uber/exception/ForbiddenException.java
// public class ForbiddenException extends Exception {
// 
//     public ForbiddenException() {
//         super("HTTP 403 error");
//     }
// }
// 
// Path: src/main/java/com/victorsima/uber/exception/UnauthorizedException.java
// public class UnauthorizedException extends Exception {
// 
//     public UnauthorizedException() {
//         super("HTTP 401 error");
//     }
// }
// 
// Path: src/main/java/com/victorsima/uber/model/AccessToken.java
// public class AccessToken {
// 
//     @Expose
//     @SerializedName("access_token")
//     private String accessToken;
// 
//     @Expose
//     @SerializedName("refresh_token")
//     private String refreshToken;
// 
//     @Expose
//     @SerializedName("token_type")
//     private String tokenType;
// 
//     @Expose
//     @SerializedName("expires_in")
//     private String expiresIn;
// 
//     @Expose
//     @SerializedName("scope")
//     private String scope;
// 
//     public AccessToken() {
//     }
// 
//     public String getAccessToken() {
//         return this.accessToken;
//     }
// 
//     public String getTokenType() {
//         return this.tokenType;
//     }
// 
//     public void setAccessToken(String paramString) {
//         this.accessToken = paramString;
//     }
// 
//     public void setTokenType(String paramString) {
//         this.tokenType = paramString;
//     }
// 
//     public String getExpiresIn() {
//         return expiresIn;
//     }
// 
//     public void setExpiresIn(String expiresIn) {
//         this.expiresIn = expiresIn;
//     }
// 
//     public String getScope() {
//         return scope;
//     }
// 
//     public void setScope(String scope) {
//         this.scope = scope;
//     }
// 
//     public String getRefreshToken() {
//         return refreshToken;
//     }
// 
//     public void setRefreshToken(String refreshToken) {
//         this.refreshToken = refreshToken;
//     }
// }
// 
// Path: src/main/java/com/victorsima/uber/model/sandbox/SandboxService.java
// public interface SandboxService {
// 
//     /**
//      * <p><b>FOR SANDBOX USE ONLY</b></p>
//      * <p>Currently the sandbox does not change states automatically the way a real Request in production would,
//      * so this endpoint gives the ability to walk an application through the different states of a Request.</p>
//      *
//      * <p>This endpoint effectively just modifies the status of an ongoing sandbox Request.</p>
//      * @param requestId
//      * @param request
//      * @return
//      */
//     @PUT("/v1/sandbox/requests/{request_id}")
//     Response putRequest(@Path("request_id") String requestId, @Body SandboxRequestBody request);
// 
//     /**
//      * <p><b>FOR SANDBOX USE ONLY</b></p>
//      * <p>Accepts a JSON body indicating what you would like the surge_multiplier to be when making a Request to a particular Product.</p>
//      * @param productId
//      * @param sandboxProductBody
//      * @return
//      */
//     @PUT("/v1/sandbox/products/{product_id}")
//     Response putProducts(@Path("product_id") String productId, @Body SandboxProductBody sandboxProductBody);
// }


import com.google.gson.*;
import com.squareup.okhttp.OkHttpClient;
import com.victorsima.uber.exception.ForbiddenException;
import com.victorsima.uber.exception.UnauthorizedException;
import com.victorsima.uber.model.AccessToken;
import com.victorsima.uber.model.sandbox.SandboxService;
import retrofit.*;
import retrofit.client.Client;
import retrofit.client.OkClient;
import retrofit.client.Response;
import retrofit.converter.GsonConverter;
import java.lang.reflect.Type;
import java.util.Date;
                .registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
                    public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
                        return new Date(json.getAsJsonPrimitive().getAsLong());
                    }
                });
        OkHttpClient okHttpClient = new OkHttpClient();
        gson = gsonBuilder.create();

        RestAdapter restAdapter = new RestAdapter.Builder()
                .setEndpoint(useSandbox ? sandboxApiUri : apiUri)
                .setRequestInterceptor(new RequestInterceptor() {
                    @Override
                    public void intercept(RequestFacade requestFacade) {

                        if (hasAccessToken()) {
                            requestFacade.addHeader("Authorization", "Bearer " + getAccessToken());
                            return;
                        } else if (hasServerToken()) {
                            requestFacade.addHeader("Authorization", "Token " + getServerToken());
                        }
                    }
                })
                .setErrorHandler(new ErrorHandler() {
                    @Override
                    public Throwable handleError(RetrofitError retrofitError) {
                        if (retrofitError != null && retrofitError.getResponse() != null) {
                            switch (retrofitError.getResponse().getStatus()) {
                                case 401: //Unauthorized
                                    return new UnauthorizedException();
                                case 403: //Forbidden
// Path: src/main/java/com/victorsima/uber/exception/ForbiddenException.java
// public class ForbiddenException extends Exception {
// 
//     public ForbiddenException() {
//         super("HTTP 403 error");
//     }
// }
// 
// Path: src/main/java/com/victorsima/uber/exception/UnauthorizedException.java
// public class UnauthorizedException extends Exception {
// 
//     public UnauthorizedException() {
//         super("HTTP 401 error");
//     }
// }
// 
// Path: src/main/java/com/victorsima/uber/model/AccessToken.java
// public class AccessToken {
// 
//     @Expose
//     @SerializedName("access_token")
//     private String accessToken;
// 
//     @Expose
//     @SerializedName("refresh_token")
//     private String refreshToken;
// 
//     @Expose
//     @SerializedName("token_type")
//     private String tokenType;
// 
//     @Expose
//     @SerializedName("expires_in")
//     private String expiresIn;
// 
//     @Expose
//     @SerializedName("scope")
//     private String scope;
// 
//     public AccessToken() {
//     }
// 
//     public String getAccessToken() {
//         return this.accessToken;
//     }
// 
//     public String getTokenType() {
//         return this.tokenType;
//     }
// 
//     public void setAccessToken(String paramString) {
//         this.accessToken = paramString;
//     }
// 
//     public void setTokenType(String paramString) {
//         this.tokenType = paramString;
//     }
// 
//     public String getExpiresIn() {
//         return expiresIn;
//     }
// 
//     public void setExpiresIn(String expiresIn) {
//         this.expiresIn = expiresIn;
//     }
// 
//     public String getScope() {
//         return scope;
//     }
// 
//     public void setScope(String scope) {
//         this.scope = scope;
//     }
// 
//     public String getRefreshToken() {
//         return refreshToken;
//     }
// 
//     public void setRefreshToken(String refreshToken) {
//         this.refreshToken = refreshToken;
//     }
// }
// 
// Path: src/main/java/com/victorsima/uber/model/sandbox/SandboxService.java
// public interface SandboxService {
// 
//     /**
//      * <p><b>FOR SANDBOX USE ONLY</b></p>
//      * <p>Currently the sandbox does not change states automatically the way a real Request in production would,
//      * so this endpoint gives the ability to walk an application through the different states of a Request.</p>
//      *
//      * <p>This endpoint effectively just modifies the status of an ongoing sandbox Request.</p>
//      * @param requestId
//      * @param request
//      * @return
//      */
//     @PUT("/v1/sandbox/requests/{request_id}")
//     Response putRequest(@Path("request_id") String requestId, @Body SandboxRequestBody request);
// 
//     /**
//      * <p><b>FOR SANDBOX USE ONLY</b></p>
//      * <p>Accepts a JSON body indicating what you would like the surge_multiplier to be when making a Request to a particular Product.</p>
//      * @param productId
//      * @param sandboxProductBody
//      * @return
//      */
//     @PUT("/v1/sandbox/products/{product_id}")
//     Response putProducts(@Path("product_id") String productId, @Body SandboxProductBody sandboxProductBody);
// }


// Path: src/main/java/com/victorsima/uber/UberClient.java
import com.google.gson.*;
import com.squareup.okhttp.OkHttpClient;
import com.victorsima.uber.exception.ForbiddenException;
import com.victorsima.uber.exception.UnauthorizedException;
import com.victorsima.uber.model.AccessToken;
import com.victorsima.uber.model.sandbox.SandboxService;
import retrofit.*;
import retrofit.client.Client;
import retrofit.client.OkClient;
import retrofit.client.Response;
import retrofit.converter.GsonConverter;
import java.lang.reflect.Type;
import java.util.Date;

                .registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
                    public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
                        return new Date(json.getAsJsonPrimitive().getAsLong());
                    }
                });
        OkHttpClient okHttpClient = new OkHttpClient();
        gson = gsonBuilder.create();

        RestAdapter restAdapter = new RestAdapter.Builder()
                .setEndpoint(useSandbox ? sandboxApiUri : apiUri)
                .setRequestInterceptor(new RequestInterceptor() {
                    @Override
                    public void intercept(RequestFacade requestFacade) {

                        if (hasAccessToken()) {
                            requestFacade.addHeader("Authorization", "Bearer " + getAccessToken());
                            return;
                        } else if (hasServerToken()) {
                            requestFacade.addHeader("Authorization", "Token " + getServerToken());
                        }
                    }
                })
                .setErrorHandler(new ErrorHandler() {
                    @Override
                    public Throwable handleError(RetrofitError retrofitError) {
                        if (retrofitError != null && retrofitError.getResponse() != null) {
                            switch (retrofitError.getResponse().getStatus()) {
                                case 401: //Unauthorized
                                    return new UnauthorizedException();
                                case 403: //Forbidden
                                    return new ForbiddenException();