package com.github.scribejava.apis;

import com.github.scribejava.core.builder.api.DefaultApi10a;
import com.github.scribejava.core.model.OAuth1RequestToken;

public class LinkedInApi extends DefaultApi10a {

    private static final String AUTHORIZE_URL = "https://api.linkedin.com/uas/oauth/authenticate?oauth_token=%s";
    private static final String REQUEST_TOKEN_URL = "https://api.linkedin.com/uas/oauth/requestToken";

    private final String scopesAsString;

    public LinkedInApi() {
        scopesAsString = null;
    }

    public LinkedInApi(String... scopes) {
        if (scopes == null || scopes.length == 0) {
            scopesAsString = null;
        } else {
            final StringBuilder builder = new StringBuilder();
            for (String scope : scopes) {
                builder.append('+').append(scope);
            }
            scopesAsString = "?scope=" + builder.substring(1);
        }
    }

    private static class InstanceHolder {

        private static final LinkedInApi INSTANCE = new LinkedInApi();
    }

    public static LinkedInApi instance() {
        return InstanceHolder.INSTANCE;
    }

    @Override
    public String getAccessTokenEndpoint() {
        return "https://api.linkedin.com/uas/oauth/accessToken";
    }

    @Override
    public String getRequestTokenEndpoint() {
        return scopesAsString == null ? REQUEST_TOKEN_URL : REQUEST_TOKEN_URL + scopesAsString;
    }

    @Override
    public String getAuthorizationUrl(OAuth1RequestToken requestToken) {
        return String.format(AUTHORIZE_URL, requestToken.getToken());
    }
}

@@ -470,68 +470,333 @@
     
-public LinkedInApi() %7B%0A        scopesAsString = null;%0A    %7D%0A
+/**%0A     * @deprecated use %7B@link #instance() %7D%0A     */%0A    @Deprecated%0A    //TODO: make protected in the next release%0A    public LinkedInApi() %7B%0A        scopesAsString = null;%0A    %7D%0A%0A    /**%0A     * @deprecated use %7B@link #instance(java.lang.String...) %7D%0A     */%0A    @Deprecated%0A    //TODO: make protected in the next release
 %0A   
@@ -827,32 +827,65 @@
 ng... scopes) %7B%0A
+        //TODO: deprecated check%0A
         if (scop
@@ -1425,32 +1425,190 @@
 NSTANCE;%0A    %7D%0A%0A
+    public static LinkedInApi instance(String... scopes) %7B%0A        return scopes == null %7C%7C scopes.length == 0 ? instance() : new LinkedInApi(scopes);%0A    %7D%0A%0A
     @Override%0A  

improve LinkedInApi interface