package org.scribe.builder.api;

import org.scribe.model.Token;

/**
 * OAuth API for Evernote
 *
 * @author Pablo Fernandez
 * @author Norbert Potocki
 */
public class EvernoteApi extends DefaultApi10a
{
  private static final String AUTHORIZATION_URL = "https://www.evernote.com/OAuth.action?oauth_token=%s";

  @Override
  public String getRequestTokenEndpoint()
  {
    return "https://www.evernote.com/oauth";
  }

  @Override
  public String getAccessTokenEndpoint()
  {
    return "https://www.evernote.com/oauth";
  }

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

  public static class Sandbox extends EvernoteApi
  {
    private static final String SANDBOX_URL = "https://sandbox.evernote.com";

    @Override
    public String getRequestTokenEndpoint()
    {
      return SANDBOX_URL + "/oauth";
    }

    @Override
    public String getAccessTokenEndpoint()
    {
      return SANDBOX_URL + "/oauth";
    }

    @Override
    public String getAuthorizationUrl(Token requestToken)
    {
      return String.format(SANDBOX_URL + "/OAuth.action?oauth_token=%s", requestToken.getToken());
    }
  }

  public static class Yinxiang extends EvernoteApi
  {
    private static final String SANDBOX_URL = "https://app.yinxiang.com";

    @Override
    public String getRequestTokenEndpoint()
    {
      return SANDBOX_URL + "/oauth";
    }

    @Override
    public String getAccessTokenEndpoint()
    {
      return SANDBOX_URL + "/oauth";
    }

    @Override
    public String getAuthorizationUrl(Token requestToken)
    {
      return String.format(SANDBOX_URL + "/OAuth.action?oauth_token=%s", requestToken.getToken());
    }
  }
}

@@ -95,35 +95,8 @@
 %0A *%0A
- * @author Pablo Fernandez%0A
  * @
@@ -179,109 +179,80 @@
   pr
-ivate static final String AUTHORIZATION_URL = %22https://www.evernote.com/OAuth.action?oauth_token=%25s%22;
+otected String serviceUrl() %7B%0A    return %22https://www.evernote.com%22;%0A  %7D
 %0A%0A  
@@ -322,33 +322,24 @@
 urn 
-%22https://www.evernote.com
+serviceUrl() + %22
 /oau
@@ -420,33 +420,24 @@
 urn 
-%22https://www.evernote.com
+serviceUrl() + %22
 /oau
@@ -547,25 +547,53 @@
 mat(
-AUTHORIZATION_URL
+serviceUrl() + %22/OAuth.action?oauth_token=%25s%22
 , re
@@ -617,24 +617,58 @@
 en());%0A  %7D%0A%0A
+  /**%0A   * Sandbox endpoint%0A   */%0A
   public sta
@@ -717,288 +717,96 @@
     
-private static final String SANDBOX_URL = %22https://sandbox.evernote.com%22;%0A%0A    @Override%0A    public String getRequestTokenEndpoint()%0A    %7B%0A      return SANDBOX_URL + %22/oauth%22;%0A    %7D%0A%0A    @Override%0A    public String getAccessTokenEndpoint()%0A    %7B%0A      return SANDBOX_URL + %22/oauth
+@Override%0A    protected String serviceUrl() %7B%0A      return %22https://sandbox.evernote.com
 %22;%0A 
@@ -814,717 +814,197 @@
   %7D%0A
-%0A
   
-  @Override%0A    public String getAuthorizationUrl(Token requestToken)%0A    %7B%0A      return String.format(SANDBOX_URL + %22/OAuth.action?oauth_token=%25s%22, requestToken.getToken());%0A    %7D%0A  %7D%0A%0A  public static class Yinxiang extends EvernoteApi%0A  %7B%0A    private static final String SANDBOX_URL = %22https://app.yinxiang.com%22;%0A%0A    @Override%0A    public String getRequestTokenEndpoint()%0A    %7B%0A      return SANDBOX_URL + %22/oauth%22;%0A    %7D%0A%0A    @Override%0A    public String getAccessTokenEndpoint()%0A    %7B%0A      return SANDBOX_URL + %22/oauth%22;%0A    %7D%0A%0A    @Override%0A    public String getAuthorizationUrl(Token requestToken)%0A    %7B%0A      return String.format(SANDBOX_URL + %22/OAuth.action?oauth_token=%25s%22, requestToken.getToken())
+%7D%0A%0A  /**%0A   * Yinxiang Biji endpoint%0A   */%0A  public static class Yinxiang extends EvernoteApi%0A  %7B%0A    @Override%0A    protected String serviceUrl() %7B%0A      return %22https://app.yinxiang.com%22
 ;%0A  

refactor EvernoteApi getting rid of duplicate code