2021-06-27 20:44:35 +00:00
|
|
|
package f0;
|
|
|
|
|
2021-08-09 22:50:01 +00:00
|
|
|
import androidx.browser.trusted.sharing.ShareTarget;
|
|
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
|
|
import com.discord.widgets.chat.input.MentionUtilsKt;
|
2021-06-27 20:44:35 +00:00
|
|
|
import d0.g0.t;
|
|
|
|
import d0.t.h0;
|
|
|
|
import d0.t.n;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import f0.f0.c;
|
|
|
|
import f0.f0.h.f;
|
|
|
|
import f0.w;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Objects;
|
|
|
|
import kotlin.Pair;
|
|
|
|
import okhttp3.Headers;
|
|
|
|
import okhttp3.RequestBody;
|
|
|
|
/* compiled from: Request.kt */
|
|
|
|
public final class z {
|
|
|
|
public d a;
|
|
|
|
public final w b;
|
|
|
|
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
2021-08-18 19:46:22 +00:00
|
|
|
public final String f2821c;
|
2021-06-27 20:44:35 +00:00
|
|
|
public final Headers d;
|
|
|
|
public final RequestBody e;
|
|
|
|
public final Map<Class<?>, Object> f;
|
|
|
|
|
|
|
|
/* compiled from: Request.kt */
|
|
|
|
public static class a {
|
|
|
|
public w a;
|
|
|
|
public String b;
|
|
|
|
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
2021-08-18 19:46:22 +00:00
|
|
|
public Headers.a f2822c;
|
2021-06-27 20:44:35 +00:00
|
|
|
public RequestBody d;
|
|
|
|
public Map<Class<?>, Object> e;
|
|
|
|
|
|
|
|
public a() {
|
|
|
|
this.e = new LinkedHashMap();
|
2021-08-09 22:50:01 +00:00
|
|
|
this.b = ShareTarget.METHOD_GET;
|
2021-08-18 19:46:22 +00:00
|
|
|
this.f2822c = new Headers.a();
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public a(z zVar) {
|
|
|
|
m.checkParameterIsNotNull(zVar, "request");
|
|
|
|
this.e = new LinkedHashMap();
|
|
|
|
this.a = zVar.b;
|
2021-08-18 19:46:22 +00:00
|
|
|
this.b = zVar.f2821c;
|
2021-06-27 20:44:35 +00:00
|
|
|
this.d = zVar.e;
|
|
|
|
this.e = zVar.f.isEmpty() ? new LinkedHashMap<>() : h0.toMutableMap(zVar.f);
|
2021-08-18 19:46:22 +00:00
|
|
|
this.f2822c = zVar.d.e();
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public z a() {
|
|
|
|
Map map;
|
|
|
|
w wVar = this.a;
|
|
|
|
if (wVar != null) {
|
|
|
|
String str = this.b;
|
2021-08-18 19:46:22 +00:00
|
|
|
Headers c2 = this.f2822c.c();
|
2021-06-27 20:44:35 +00:00
|
|
|
RequestBody requestBody = this.d;
|
|
|
|
Map<Class<?>, Object> map2 = this.e;
|
|
|
|
byte[] bArr = c.a;
|
|
|
|
m.checkParameterIsNotNull(map2, "$this$toImmutableMap");
|
|
|
|
if (map2.isEmpty()) {
|
|
|
|
map = h0.emptyMap();
|
|
|
|
} else {
|
|
|
|
map = Collections.unmodifiableMap(new LinkedHashMap(map2));
|
|
|
|
m.checkExpressionValueIsNotNull(map, "Collections.unmodifiableMap(LinkedHashMap(this))");
|
|
|
|
}
|
|
|
|
return new z(wVar, str, c2, requestBody, map);
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("url == null".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
public a b(String str, String str2) {
|
2021-08-09 22:50:01 +00:00
|
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
2021-06-27 20:44:35 +00:00
|
|
|
m.checkParameterIsNotNull(str2, "value");
|
2021-08-18 19:46:22 +00:00
|
|
|
Headers.a aVar = this.f2822c;
|
2021-06-27 20:44:35 +00:00
|
|
|
Objects.requireNonNull(aVar);
|
2021-08-09 22:50:01 +00:00
|
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
2021-06-27 20:44:35 +00:00
|
|
|
m.checkParameterIsNotNull(str2, "value");
|
|
|
|
Headers.b bVar = Headers.i;
|
|
|
|
bVar.a(str);
|
|
|
|
bVar.b(str2, str);
|
|
|
|
aVar.d(str);
|
|
|
|
aVar.b(str, str2);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public a c(String str, RequestBody requestBody) {
|
|
|
|
m.checkParameterIsNotNull(str, "method");
|
|
|
|
boolean z2 = false;
|
|
|
|
if (str.length() > 0) {
|
|
|
|
if (requestBody == null) {
|
|
|
|
m.checkParameterIsNotNull(str, "method");
|
2021-08-09 22:50:01 +00:00
|
|
|
if (m.areEqual(str, ShareTarget.METHOD_POST) || m.areEqual(str, "PUT") || m.areEqual(str, "PATCH") || m.areEqual(str, "PROPPATCH") || m.areEqual(str, "REPORT")) {
|
2021-06-27 20:44:35 +00:00
|
|
|
z2 = true;
|
|
|
|
}
|
|
|
|
if (!(!z2)) {
|
2021-07-27 04:36:47 +00:00
|
|
|
throw new IllegalArgumentException(c.d.b.a.a.t("method ", str, " must have a request body.").toString());
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
} else if (!f.a(str)) {
|
2021-07-27 04:36:47 +00:00
|
|
|
throw new IllegalArgumentException(c.d.b.a.a.t("method ", str, " must not have a request body.").toString());
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
this.b = str;
|
|
|
|
this.d = requestBody;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
throw new IllegalArgumentException("method.isEmpty() == true".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
public a d(String str) {
|
2021-08-09 22:50:01 +00:00
|
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
2021-08-18 19:46:22 +00:00
|
|
|
this.f2822c.d(str);
|
2021-06-27 20:44:35 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public <T> a e(Class<? super T> cls, T t) {
|
|
|
|
m.checkParameterIsNotNull(cls, "type");
|
|
|
|
if (t == null) {
|
|
|
|
this.e.remove(cls);
|
|
|
|
} else {
|
|
|
|
if (this.e.isEmpty()) {
|
|
|
|
this.e = new LinkedHashMap();
|
|
|
|
}
|
|
|
|
Map<Class<?>, Object> map = this.e;
|
|
|
|
Object cast = cls.cast(t);
|
|
|
|
if (cast == null) {
|
|
|
|
m.throwNpe();
|
|
|
|
}
|
|
|
|
map.put(cls, cast);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public a f(String str) {
|
|
|
|
m.checkParameterIsNotNull(str, "url");
|
|
|
|
if (t.startsWith(str, "ws:", true)) {
|
2021-07-27 04:36:47 +00:00
|
|
|
StringBuilder K = c.d.b.a.a.K("http:");
|
2021-06-27 20:44:35 +00:00
|
|
|
String substring = str.substring(3);
|
|
|
|
m.checkExpressionValueIsNotNull(substring, "(this as java.lang.String).substring(startIndex)");
|
2021-07-27 04:36:47 +00:00
|
|
|
K.append(substring);
|
|
|
|
str = K.toString();
|
2021-06-27 20:44:35 +00:00
|
|
|
} else if (t.startsWith(str, "wss:", true)) {
|
2021-07-27 04:36:47 +00:00
|
|
|
StringBuilder K2 = c.d.b.a.a.K("https:");
|
2021-06-27 20:44:35 +00:00
|
|
|
String substring2 = str.substring(4);
|
|
|
|
m.checkExpressionValueIsNotNull(substring2, "(this as java.lang.String).substring(startIndex)");
|
2021-07-27 04:36:47 +00:00
|
|
|
K2.append(substring2);
|
|
|
|
str = K2.toString();
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
m.checkParameterIsNotNull(str, "$this$toHttpUrl");
|
|
|
|
w.a aVar = new w.a();
|
|
|
|
aVar.e(null, str);
|
|
|
|
g(aVar.b());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public a g(w wVar) {
|
|
|
|
m.checkParameterIsNotNull(wVar, "url");
|
|
|
|
this.a = wVar;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public z(w wVar, String str, Headers headers, RequestBody requestBody, Map<Class<?>, ? extends Object> map) {
|
|
|
|
m.checkParameterIsNotNull(wVar, "url");
|
|
|
|
m.checkParameterIsNotNull(str, "method");
|
|
|
|
m.checkParameterIsNotNull(headers, "headers");
|
2021-08-09 22:50:01 +00:00
|
|
|
m.checkParameterIsNotNull(map, ModelAuditLogEntry.CHANGE_KEY_TAGS);
|
2021-06-27 20:44:35 +00:00
|
|
|
this.b = wVar;
|
2021-08-18 19:46:22 +00:00
|
|
|
this.f2821c = str;
|
2021-06-27 20:44:35 +00:00
|
|
|
this.d = headers;
|
|
|
|
this.e = requestBody;
|
|
|
|
this.f = map;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final d a() {
|
|
|
|
d dVar = this.a;
|
|
|
|
if (dVar != null) {
|
|
|
|
return dVar;
|
|
|
|
}
|
|
|
|
d b = d.a.b(this.d);
|
|
|
|
this.a = b;
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final String b(String str) {
|
2021-08-09 22:50:01 +00:00
|
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
2021-06-27 20:44:35 +00:00
|
|
|
return this.d.c(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-07-27 04:36:47 +00:00
|
|
|
StringBuilder K = c.d.b.a.a.K("Request{method=");
|
2021-08-18 19:46:22 +00:00
|
|
|
K.append(this.f2821c);
|
2021-07-27 04:36:47 +00:00
|
|
|
K.append(", url=");
|
|
|
|
K.append(this.b);
|
2021-06-27 20:44:35 +00:00
|
|
|
if (this.d.size() != 0) {
|
2021-07-27 04:36:47 +00:00
|
|
|
K.append(", headers=[");
|
2021-06-27 20:44:35 +00:00
|
|
|
int i = 0;
|
|
|
|
for (Pair<? extends String, ? extends String> pair : this.d) {
|
|
|
|
int i2 = i + 1;
|
|
|
|
if (i < 0) {
|
|
|
|
n.throwIndexOverflow();
|
|
|
|
}
|
|
|
|
Pair<? extends String, ? extends String> pair2 = pair;
|
|
|
|
String str = (String) pair2.component1();
|
|
|
|
String str2 = (String) pair2.component2();
|
|
|
|
if (i > 0) {
|
2021-07-27 04:36:47 +00:00
|
|
|
K.append(", ");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-07-27 04:36:47 +00:00
|
|
|
K.append(str);
|
2021-08-09 22:50:01 +00:00
|
|
|
K.append(MentionUtilsKt.EMOJIS_AND_STICKERS_CHAR);
|
2021-07-27 04:36:47 +00:00
|
|
|
K.append(str2);
|
2021-06-27 20:44:35 +00:00
|
|
|
i = i2;
|
|
|
|
}
|
2021-07-27 04:36:47 +00:00
|
|
|
K.append(']');
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
if (!this.f.isEmpty()) {
|
2021-07-27 04:36:47 +00:00
|
|
|
K.append(", tags=");
|
|
|
|
K.append(this.f);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-07-27 04:36:47 +00:00
|
|
|
K.append('}');
|
|
|
|
String sb = K.toString();
|
2021-06-27 20:44:35 +00:00
|
|
|
m.checkExpressionValueIsNotNull(sb, "StringBuilder().apply(builderAction).toString()");
|
|
|
|
return sb;
|
|
|
|
}
|
|
|
|
}
|