what-the-bank/sources/o/Rhp.java

74 lines
2.8 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package o;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.huawei.hms.support.feature.result.CommonConstant;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Response;
import okhttp3.ResponseBody;
/* loaded from: classes.dex */
public final class Rhp implements Interceptor {
private static final MediaType c;
private static final Gson d;
@InterfaceC13391fZD
public Rhp() {
}
@Override // okhttp3.Interceptor
public final Response intercept(Interceptor.Chain chain) {
JsonObject jsonObject;
JsonElement jsonElement;
JsonElement jsonElement2;
C14957gcv.e(chain, "");
Response proceed = chain.proceed(chain.request());
ResponseBody body = proceed.body();
JsonObject jsonObject2 = null;
try {
JsonObject jsonObject3 = (JsonObject) new Gson().fromJson(body != null ? body.string() : null, JsonObject.class);
jsonObject2 = jsonObject3.getAsJsonObject(CommonConstant.KEY_STATUS);
jsonObject = jsonObject3.getAsJsonObject("data");
C14957gcv.c(jsonObject, "");
if (jsonObject.has("demo")) {
jsonObject.addProperty("rawData", jsonObject.getAsJsonObject("demo").toString());
} else {
jsonObject.addProperty("rawData", jsonObject.toString());
}
} catch (Exception unused) {
jsonObject = new JsonObject();
jsonObject.addProperty("rawData", "");
}
jsonObject.addProperty("apiAuth", proceed.headers().get("Api-Auth"));
jsonObject.addProperty("code", Integer.valueOf((jsonObject2 == null || jsonObject2.get("code") == null) ? 0 : jsonObject2.get("code").getAsInt()));
if (jsonObject.get("header") == null || jsonObject.get("header").isJsonNull()) {
jsonObject.addProperty("header", (jsonObject2 == null || (jsonElement2 = jsonObject2.get("header")) == null || jsonElement2.isJsonNull()) ? "" : jsonObject2.get("header").getAsString());
jsonObject.addProperty("description", (jsonObject2 == null || (jsonElement = jsonObject2.get("description")) == null || jsonElement.isJsonNull()) ? "" : jsonObject2.get("description").getAsString());
}
String json = d.toJson((JsonElement) jsonObject);
C14957gcv.c((Object) json, "");
if (body != null) {
body.close();
}
return proceed.newBuilder().body(ResponseBody.Companion.create(json, c)).build();
}
/* loaded from: classes.dex */
public static final class Sts {
private Sts() {
}
public /* synthetic */ Sts(byte b) {
this();
}
}
static {
new Sts((byte) 0);
c = MediaType.Companion.get("application/json; charset=utf-8");
d = new Gson();
}
}