Всемс добрый день всем спасибо за ответ на предыдущий вопрос
Теперь Вопрос следующий Есть API для которого я создал запрос @GET
@GET("auth.cgi")
Single<AuthResponse> getAuthResponce(
@Query("username") String username,
@Query("password") String password);
Есть класс AuthUtils вот такой
public class ApiUtils {
public static final List<Class<?>> NETWORK_EXCEPTIONS = Arrays.asList(
UnknownHostException.class,
SocketTimeoutException.class,
ConnectException.class
);
private static OkHttpClient sClient;
private static Retrofit sRetrofit;
private static Gson sGson;
private static AlarApi sApi;
private static OkHttpClient getClient() {
if (sClient == null) {
OkHttpClient.Builder builder = new OkHttpClient().newBuilder();
builder.addInterceptor(new ApiKeyInterceptor());
if (!BuildConfig.BUILD_TYPE.contains("release")) {
builder.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY));
}
sClient =
builder.build();
}
return sClient;
}
private static Retrofit getRetrofit() {
if (sGson == null) {
sGson = new Gson();
}
if (sRetrofit == null) {
sRetrofit = new Retrofit.Builder()
.baseUrl(BuildConfig.API_URL)
// need for interceptors
.client(getClient())
.addConverterFactory(GsonConverterFactory.create(sGson))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
}
return sRetrofit;
}
public static AlarApi getApiService() {
if (sApi == null) {
sApi = getRetrofit().create(AlarApi.class);
}
return sApi;
}
}
И собсвенно вопрос в том,как лучше и проще вызвать getAuthResponce
получить ответ вроде {"status":"ok","code":"1065791006"}
и выделить из ответа нужную строку code=somevalue