content: #if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
  
  import android.util.Log;
  
  import ${PACKAGE_UTIL}.${CONSTANTS};
  import com.google.gson.Gson;
  import com.google.gson.GsonBuilder;
  
  import java.io.IOException;
  import java.lang.reflect.Modifier;
  import java.util.concurrent.TimeUnit;
  
  import okhttp3.Interceptor;
  import okhttp3.OkHttpClient;
  import okhttp3.Request;
  import okhttp3.Response;
  import okhttp3.ResponseBody;
  import okio.Buffer;
  import retrofit2.Retrofit;
  import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
  import retrofit2.converter.gson.GsonConverterFactory;
  import rx.Observable;
  
  #parse("File Header.java")
  public class ${NAME} {
      public Retrofit getAdapter() {
          OkHttpClient client = new OkHttpClient.Builder()
                  .connectTimeout(10, TimeUnit.SECONDS)
                  .readTimeout(10, TimeUnit.SECONDS)
                  .addInterceptor(new LoggingInterceptor())
                  .build();
  
          Gson gson = new GsonBuilder()
                  .excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
                  .serializeNulls()
                  .create();
  
          return new Retrofit.Builder()
                  .baseUrl(Constants.ENDPOINT)
                  .client(client)
                  .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                  .addConverterFactory(GsonConverterFactory.create(gson))
                  .build();
      }
  
      public static class LoggingInterceptor implements Interceptor {
          @Override public Response intercept(Chain chain) throws IOException {
              Request request = chain.request();
              long t1 = System.nanoTime();
              String requestLog = String.format("Sending request %s on %s%n%s",
                      request.url(), chain.connection(), request.headers());
              //YLog.d(String.format("Sending request %s on %s%n%s",
              //        request.url(), chain.connection(), request.headers()));
              if (request.method().compareToIgnoreCase("post") == 0) {
                  requestLog = requestLog + "  " + bodyToString(request);
              }
              Log.d("Retrofit", "Retrofit request" + "\n" + requestLog);
  
              Response response = chain.proceed(request);
              long t2 = System.nanoTime();
  
              String responseLog = String.format("Received response for %s in %.1fms%n%s",
                      response.request().url(), (t2 - t1) / 1e6d, response.headers());
  
              String bodyString = response.body().string();
  
              Log.d("Retrofit", "Retrofit response" + "\n" + responseLog + bodyString);
  
              return response.newBuilder()
                      .body(ResponseBody.create(response.body().contentType(), bodyString))
                      .build();
              //return response;
          }
      }
  
  
      public static String bodyToString(final Request request) {
          try {
              final Request copy = request.newBuilder().build();
              final Buffer buffer = new Buffer();
              copy.body().writeTo(buffer);
              return buffer.readUtf8();
          } catch (final IOException e) {
              return "did not work";
          }
      }
  }