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;

    /**
     * @deprecated use {@link #instance() }
     */
    @Deprecated
    //TODO: make protected in the next release
    public LinkedInApi() {
        scopesAsString = null;
    }

    /**
     * @param scopes scopes
     * @deprecated use {@link #instance(java.lang.String...) }
     */
    @Deprecated
    //TODO: make protected in the next release
    public LinkedInApi(String... scopes) {
        //TODO: deprecated check
        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;
    }

    public static LinkedInApi instance(String... scopes) {
        return scopes == null || scopes.length == 0 ? instance() : new LinkedInApi(scopes);
    }

    @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,546 +470,118 @@
     
-/**%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     * @param scopes scopes%0A     * @deprecated use %7B@link #instance(java.lang.String...) %7D%0A     */%0A    @Deprecated%0A    //TODO: make protected in the next release%0A    public LinkedInApi(String... scopes) %7B%0A        //TODO: deprecated check%0A        if (scopes == null %7C%7C scopes.length == 0) %7B%0A            scopesAsString = null;%0A        %7D else %7B%0A    
+protected LinkedInApi() %7B%0A        scopesAsString = null;%0A    %7D%0A%0A    protected LinkedInApi(String... scopes) %7B%0A
     
@@ -643,20 +643,16 @@
         
-    
 for (Str
@@ -685,20 +685,16 @@
         
- 
-   
 builder.
@@ -720,20 +720,16 @@
 scope);%0A
-    
         
@@ -734,28 +734,24 @@
   %7D%0A        
-    
 scopesAsStri
@@ -789,26 +789,16 @@
 ing(1);%0A
-        %7D%0A
     %7D%0A%0A 

drop deprecated methods