package com.uwetrottmann.getglue;

import com.uwetrottmann.getglue.services.ObjectService;
import retrofit.RequestInterceptor;
import retrofit.RestAdapter;

public class ServiceManager {

    private static final String API_URL = "https://api.getglue.com/v3";
    private boolean mIsDebug;

    public ServiceManager() {
    }

    public ServiceManager setIsDebug(boolean isDebug) {
        mIsDebug = isDebug;
        return this;
    }

    private RestAdapter buildRestAdapter() {
        RestAdapter.Builder builder = new RestAdapter.Builder()
                .setServer(API_URL);

        // TODO OAuth integration

        if (mIsDebug) {
            builder.setLogLevel(RestAdapter.LogLevel.FULL);
        }

        return builder.build();
    }

    public ObjectService objectService() {
        ObjectService service = buildRestAdapter().create(ObjectService.class);
        return service;
    }
}

@@ -95,341 +95,1938 @@
 ort 
-retrofit.RequestInterceptor;%0Aimport retrofit.RestAdapter;%0A%0Apublic class ServiceManager %7B%0A%0A    private static final String API_URL = %22https://api.getglue.com/v3%22;%0A    private boolean mIsDebug;%0A%0A    public ServiceManager() %7B%0A    %7D%0A%0A    public ServiceManager setIsDebug(boolean isDebug) %7B%0A        mIsDebug = isDebug;%0A        return this
+org.apache.oltu.oauth2.client.request.OAuthClientRequest;%0Aimport org.apache.oltu.oauth2.client.response.OAuthAuthzResponse;%0Aimport org.apache.oltu.oauth2.common.exception.OAuthSystemException;%0Aimport org.apache.oltu.oauth2.common.message.types.GrantType;%0Aimport retrofit.RequestInterceptor;%0Aimport retrofit.RestAdapter;%0A%0Apublic class ServiceManager %7B%0A%0A    private static final String API_URL = %22https://api.getglue.com/v3%22;%0A    private static final String OAUTH2_AUTHORIZATION_URL = %22https://api.getglue.com/oauth2/authorize%22;%0A    private static final String OAUTH2_ACCESS_TOKEN_URL = %22https://api.getglue.com/oauth2/access_token%22;%0A    private boolean mIsDebug;%0A    private String mAccessToken;%0A%0A    public ServiceManager() %7B%0A    %7D%0A%0A    public ServiceManager setIsDebug(boolean isDebug) %7B%0A        mIsDebug = isDebug;%0A        return this;%0A    %7D%0A%0A    public OAuthClientRequest getAuthorizationRequest(String clientId, String redirectUri) throws OAuthSystemException %7B%0A        OAuthClientRequest request = OAuthClientRequest%0A                .authorizationLocation(OAUTH2_AUTHORIZATION_URL)%0A                .setClientId(clientId)%0A                .setRedirectURI(redirectUri)%0A                .buildQueryMessage();%0A        return request;%0A    %7D%0A%0A    public OAuthClientRequest getAccessTokenRequest(String clientId, String clientSecret, String redirectUri,%0A                                                    String authCode) throws OAuthSystemException %7B%0A        OAuthClientRequest request = OAuthClientRequest%0A                .tokenLocation(OAUTH2_ACCESS_TOKEN_URL)%0A                .setGrantType(GrantType.AUTHORIZATION_CODE)%0A                .setClientId(clientId)%0A                .setClientSecret(clientSecret)%0A                .setRedirectURI(redirectUri)%0A                .setCode(authCode)%0A                .buildBodyMessage();%0A        return request;%0A    %7D%0A%0A    public void setAccessToken(String token) %7B%0A        mAccessToken = token
 ;%0A  
@@ -2192,30 +2192,278 @@
  // 
-TODO
+Supply
  OAuth 
-integration
+2.0 access token%0A        builder.setRequestInterceptor(new RequestInterceptor() %7B%0A            @Override%0A            public void intercept(RequestFacade request) %7B%0A                request.addQueryParam(%22access_token%22, mAccessToken);%0A            %7D%0A        %7D);
 %0A%0A  

Add OAuth 2.0 helper methods to manager.