- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
106 lines
3.6 KiB
Java
106 lines
3.6 KiB
Java
package com.singular.sdk.internal;
|
|
|
|
import java.io.IOException;
|
|
import java.util.HashMap;
|
|
import java.util.InvalidPropertiesFormatException;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public abstract class BaseApi extends SingularMap implements Api {
|
|
public static final SingularLog logger = SingularLog.getLogger(BaseApi.class.getSimpleName());
|
|
|
|
public BaseApi(String str, long j) {
|
|
put("__TYPE__", str);
|
|
put("__TIMESTAMP__", String.valueOf(j));
|
|
}
|
|
|
|
public Map getParams() {
|
|
HashMap hashMap = new HashMap(this);
|
|
hashMap.remove("__TYPE__");
|
|
hashMap.remove("__TIMESTAMP__");
|
|
return hashMap;
|
|
}
|
|
|
|
public void addParams(Map map) {
|
|
if (map == null) {
|
|
return;
|
|
}
|
|
putAll(map);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public long getTimestamp() {
|
|
String str = (String) get("__TIMESTAMP__");
|
|
if (Utils.isEmptyOrNull(str)) {
|
|
return -1L;
|
|
}
|
|
return Long.parseLong(str);
|
|
}
|
|
|
|
public String getUrl() {
|
|
return "https://sdk-api-v1.singular.net/api/v1" + getPath();
|
|
}
|
|
|
|
public boolean makeRequest(SingularInstance singularInstance) {
|
|
return SingularRequestHandler.makeRequest(singularInstance, getUrl(), getParams(), getTimestamp(), getOnApiCallback());
|
|
}
|
|
|
|
public String toJsonAsString() {
|
|
return new JSONObject(this).toString();
|
|
}
|
|
|
|
public static BaseApi from(String str) {
|
|
if (str == null) {
|
|
throw new NullPointerException("api string cannot be null");
|
|
}
|
|
Map fromString = fromString(str);
|
|
String str2 = (String) fromString.get("__TYPE__");
|
|
String str3 = (String) fromString.get("__TIMESTAMP__");
|
|
long parseLong = !Utils.isEmptyOrNull(str3) ? Long.parseLong(str3) : -1L;
|
|
if ("EVENT".equalsIgnoreCase(str2)) {
|
|
ApiSubmitEvent apiSubmitEvent = new ApiSubmitEvent(parseLong);
|
|
apiSubmitEvent.addParams(fromString);
|
|
return apiSubmitEvent;
|
|
}
|
|
if ("SESSION_START".equalsIgnoreCase(str2)) {
|
|
ApiStartSession apiStartSession = new ApiStartSession(parseLong);
|
|
apiStartSession.addParams(fromString);
|
|
return apiStartSession;
|
|
}
|
|
if ("GDPR_CONSENT".equalsIgnoreCase(str2)) {
|
|
ApiGDPRConsent apiGDPRConsent = new ApiGDPRConsent(parseLong);
|
|
apiGDPRConsent.addParams(fromString);
|
|
return apiGDPRConsent;
|
|
}
|
|
if ("GDPR_UNDER_13".equalsIgnoreCase(str2)) {
|
|
ApiGDPRUnder13 apiGDPRUnder13 = new ApiGDPRUnder13(parseLong);
|
|
apiGDPRUnder13.addParams(fromString);
|
|
return apiGDPRUnder13;
|
|
}
|
|
if ("CUSTOM_USER_ID".equalsIgnoreCase(str2)) {
|
|
ApiCustomUserId apiCustomUserId = new ApiCustomUserId(parseLong);
|
|
apiCustomUserId.addParams(fromString);
|
|
return apiCustomUserId;
|
|
}
|
|
throw new InvalidPropertiesFormatException(String.format("Unknown type = %s", str2));
|
|
}
|
|
|
|
public static Map fromString(String str) {
|
|
try {
|
|
JSONObject jSONObject = new JSONObject(str);
|
|
HashMap hashMap = new HashMap();
|
|
Iterator<String> keys = jSONObject.keys();
|
|
while (keys.hasNext()) {
|
|
String next = keys.next();
|
|
hashMap.put(next, (String) jSONObject.get(next));
|
|
}
|
|
return hashMap;
|
|
} catch (JSONException e) {
|
|
throw new IOException(e);
|
|
}
|
|
}
|
|
}
|