Created
March 8, 2016 20:37
-
-
Save LLin233/5484898ac35fb6fd54b9 to your computer and use it in GitHub Desktop.
Retrofit Endpoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class BaseEndpoint { | |
protected static final String BASE_URL = "https://api.instagram.com/v1/"; | |
protected static OkHttpClient httpClient = new OkHttpClient(); | |
protected static HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); | |
protected static Retrofit.Builder builder = new Retrofit.Builder() | |
.baseUrl(BASE_URL) | |
.addConverterFactory(GsonConverterFactory.create()); | |
protected final String accessToken; | |
protected BaseEndpoint(final String accessToken) { | |
this.accessToken = accessToken; | |
} | |
} | |
public final class UsersEndpoint extends BaseEndpoint { | |
private final UserService userService; | |
public UsersEndpoint(final String accessToken) { | |
super(accessToken); | |
//final RestAdapter restAdapter = new RestAdapter.Builder().setLogLevel(logLevel).setEndpoint(BASE_URL).build(); | |
logging.setLevel(HttpLoggingInterceptor.Level.BASIC); | |
httpClient.interceptors().add(logging); | |
Retrofit retrofit = builder.client(httpClient).build(); | |
Log.d("User", retrofit.toString()); | |
userService = retrofit.create(UserService.class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment