Skip to content

Commit bd09a52

Browse files
IngvarJackalStanislav Parshin
authored andcommitted
Change hardcoded telegram API URL for CI mocks (#91)
* extended TelegramBotAdapter API to override hardcoded telegram URL for CI testing purposes * fixed api url argument name * change api url params order
1 parent 75ffef6 commit bd09a52

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

library/src/main/java/com/pengrad/telegrambot/TelegramBotAdapter.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ public static TelegramBot buildDebug(String botToken) {
2424
}
2525

2626
public static TelegramBot buildCustom(String botToken, OkHttpClient okHttpClient) {
27-
TelegramBotClient client = new TelegramBotClient(okHttpClient, gson(), apiUrl(botToken));
27+
return buildCustom(botToken, okHttpClient, API_URL);
28+
}
29+
30+
public static TelegramBot buildCustom(String botToken, OkHttpClient okHttpClient, String apiUrl) {
31+
TelegramBotClient client = new TelegramBotClient(okHttpClient, gson(), apiUrl(apiUrl, botToken));
2832
FileApi fileApi = new FileApi(botToken);
2933
return new TelegramBot(client, fileApi);
3034
}
@@ -43,7 +47,7 @@ private static Gson gson() {
4347
return new Gson();
4448
}
4549

46-
private static String apiUrl(String botToken) {
47-
return API_URL + botToken + "/";
50+
private static String apiUrl(String apiUrl, String botToken) {
51+
return apiUrl + botToken + "/";
4852
}
4953
}

0 commit comments

Comments
 (0)