package com.pengrad.telegrambot;

import com.google.gson.Gson;
import com.pengrad.telegrambot.impl.FileApi;
import com.pengrad.telegrambot.impl.TelegramBotClient;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;

/**
 * stas
 * 8/4/15.
 */
public class TelegramBotAdapter {

    public static final String API_URL = "https://api.telegram.org/bot";

    public static TelegramBot build(String botToken) {
        FileApi fileApi = new FileApi(botToken);
        TelegramBotClient api = new TelegramBotClient(client(null), gson(), apiUrl(botToken));
        return new TelegramBot(api, fileApi);
    }

    public static TelegramBot buildDebug(String botToken) {
        FileApi fileApi = new FileApi(botToken);
        TelegramBotClient api = new TelegramBotClient(client(httpLoggingInterceptor()), gson(), apiUrl(botToken));
        return new TelegramBot(api, fileApi);
    }

    private static OkHttpClient client(Interceptor interceptor) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        if (interceptor != null) builder.addInterceptor(interceptor);
        return builder.build();
    }

    private static Interceptor httpLoggingInterceptor() {
        return new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY);
    }

    private static Gson gson() {
        return new Gson();
    }

    private static String apiUrl(String botToken) {
        return API_URL + botToken + "/";
    }
}

@@ -464,132 +464,107 @@
     
-FileApi fileApi = new FileApi(botToken
+return buildCustom(botToken, client(null)
 );%0A    
+%7D%0A%0A
     
-TelegramBotClient api = new TelegramBotClient(client(null), gson(), apiUrl(
+public static TelegramBot buildDebug(String 
 botT
@@ -560,34 +560,34 @@
 String botToken)
-);
+ %7B
 %0A        return 
@@ -590,36 +590,62 @@
 urn 
-new TelegramBot(api, fileApi
+buildCustom(botToken, client(httpLoggingInterceptor())
 );%0A 
@@ -677,37 +677,38 @@
 elegramBot build
-Debug
+Custom
 (String botToken
@@ -711,60 +711,38 @@
 oken
-) %7B%0A        FileApi fileApi = new FileApi(botToken);
+, OkHttpClient okHttpClient) %7B
 %0A   
@@ -764,19 +764,22 @@
 tClient 
-api
+client
  = new T
@@ -799,40 +799,20 @@
 ent(
-client(httpLoggingInterceptor())
+okHttpClient
 , gs
@@ -832,24 +832,73 @@
 botToken));%0A
+        FileApi fileApi = new FileApi(botToken);%0A
         retu
@@ -916,19 +916,22 @@
 gramBot(
-api
+client
 , fileAp

Add support for custom OkHttpClient when creating bot