minor changes (not found message now builts from template), refs #9991

This commit is contained in:
anonymouzz
2017-08-07 10:42:15 +07:00
parent 248b561093
commit a60c7cb797

View File

@@ -41,6 +41,8 @@ public final class ApiClient {
private static final int TIMEOUT_CONNECTION = 3;
private static final int TIMEOUT_READ = 3;
private static final int TIMEOUT_WRITE = 3;
private static final String IDENTIFIER_NOT_FOUND = "Идентификатор {card} не найден.";
public final String endpoint;
public final String appToken;
@@ -89,16 +91,17 @@ public final class ApiClient {
try {
final Response response = http.newCall(request).execute();
final String body = response.body().string();
final String NOT_FOUND_MESSAGE = IDENTIFIER_NOT_FOUND.replace("{card}", card);
switch (response.code()) {
case 200:
final JSONArray users = new JSONArray(body);
if (users.length() > 0) {
return new Pair<>(card, users.get(0).toString());
} else {
return new Pair<>(null, "Пользователь с таким id не найден");
return new Pair<>(null, NOT_FOUND_MESSAGE);
}
case 204:
return new Pair<>(null, "Пользователь с таким id не найден");
return new Pair<>(null, NOT_FOUND_MESSAGE);
default:
return new Pair<>(null, "Что-то пошло не так");
}