Skip to content

Instantly share code, notes, and snippets.

@LLin233
Created March 8, 2016 20:37
Show Gist options
  • Save LLin233/5484898ac35fb6fd54b9 to your computer and use it in GitHub Desktop.
Save LLin233/5484898ac35fb6fd54b9 to your computer and use it in GitHub Desktop.
Retrofit Endpoint
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