2021-06-27 20:44:35 +00:00
|
|
|
package com.discord.gateway.rest;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import com.discord.models.domain.ModelGateway;
|
|
|
|
import com.discord.restapi.RequiredHeadersInterceptor;
|
|
|
|
import com.discord.restapi.RestAPIBuilder;
|
|
|
|
import com.discord.restapi.utils.RetryWithDelay;
|
|
|
|
import com.franmontiel.persistentcookiejar.PersistentCookieJar;
|
|
|
|
import com.franmontiel.persistentcookiejar.cache.SetCookieCache;
|
|
|
|
import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor;
|
|
|
|
import d0.t.n;
|
|
|
|
import d0.z.d.c0;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import j0.p.a;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Objects;
|
|
|
|
import okhttp3.Interceptor;
|
|
|
|
import rx.Observable;
|
|
|
|
/* compiled from: RestClient.kt */
|
|
|
|
public final class RestClient {
|
|
|
|
public static final RestClient INSTANCE = new RestClient();
|
|
|
|
private static RestApi restApi;
|
|
|
|
|
|
|
|
private RestClient() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Observable<String> getGateway() {
|
|
|
|
RetryWithDelay retryWithDelay = RetryWithDelay.INSTANCE;
|
|
|
|
RestApi restApi2 = restApi;
|
|
|
|
if (restApi2 == null) {
|
|
|
|
m.throwUninitializedPropertyAccessException("restApi");
|
|
|
|
}
|
2021-07-03 23:36:06 +00:00
|
|
|
Observable<ModelGateway> X = restApi2.getGateway().X(a.c());
|
|
|
|
m.checkNotNullExpressionValue(X, "restApi\n .getGa…scribeOn(Schedulers.io())");
|
|
|
|
Observable<String> F = RetryWithDelay.restRetry$default(retryWithDelay, X, 0, null, null, 7, null).F(RestClient$getGateway$1.INSTANCE);
|
|
|
|
m.checkNotNullExpressionValue(F, "restApi\n .getGa… .map { it.url }");
|
|
|
|
return F;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final void init(RestConfig restConfig, Context context) {
|
|
|
|
m.checkNotNullParameter(restConfig, "restConfig");
|
|
|
|
m.checkNotNullParameter(context, "context");
|
|
|
|
String component1 = restConfig.component1();
|
|
|
|
RequiredHeadersInterceptor.HeadersProvider component2 = restConfig.component2();
|
|
|
|
List<Interceptor> component3 = restConfig.component3();
|
|
|
|
RequiredHeadersInterceptor requiredHeadersInterceptor = new RequiredHeadersInterceptor(component2);
|
|
|
|
PersistentCookieJar persistentCookieJar = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(context));
|
|
|
|
c0 c0Var = new c0(2);
|
|
|
|
c0Var.add(requiredHeadersInterceptor);
|
|
|
|
Object[] array = component3.toArray(new Interceptor[0]);
|
|
|
|
Objects.requireNonNull(array, "null cannot be cast to non-null type kotlin.Array<T>");
|
|
|
|
c0Var.addSpread(array);
|
|
|
|
restApi = (RestApi) RestAPIBuilder.build$default(new RestAPIBuilder(component1, persistentCookieJar), RestApi.class, false, 0, n.listOf((Object[]) ((Interceptor[]) c0Var.toArray(new Interceptor[c0Var.size()]))), null, false, null, 118, null);
|
|
|
|
}
|
|
|
|
}
|