Advertisement
absjabed

Retrofit Client and Interface

Dec 21st, 2017
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. public interface ApiInterface {
  2.  
  3.     @POST("/iuk/api/credentials")
  4.     Call<ServerResponse> operation(@Body ServerRequest request);
  5. }
  6.  
  7.  
  8. public class RetrofitApiClient {
  9.     private static final String BASE_URL = "https://xyz.000webhostapp.com";
  10.     private static Retrofit retrofit = null;
  11.  
  12.     private static Gson gson = new GsonBuilder()
  13.             .setLenient()
  14.             .create();
  15.  
  16.     private RetrofitApiClient() {}
  17.  
  18.     public static synchronized Retrofit getClient() {
  19.         if (retrofit==null) {
  20.             retrofit = new Retrofit.Builder()
  21.                     .baseUrl(Config_Ref.BASE_URL)
  22.                     .addConverterFactory(GsonConverterFactory.create(gson))
  23.                     .build();
  24.         }
  25.         return retrofit;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement