正在查看: BetterTogether v3.0.0 应用的 RequestFactory.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: BetterTogether v3.0.0 应用的 RequestFactory.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.adapty.internal.data.cloud;
import a0.g0;
import com.adapty.internal.data.cache.CacheRepository;
import com.adapty.internal.data.cache.ResponseCacheKeyProvider;
import com.adapty.internal.data.cache.ResponseCacheKeys;
import com.adapty.internal.data.cloud.Request;
import com.adapty.internal.data.models.AnalyticsEvent;
import com.adapty.internal.data.models.AttributionData;
import com.adapty.internal.data.models.InstallationMeta;
import com.adapty.internal.data.models.ProfileDto;
import com.adapty.internal.data.models.requests.CreateOrUpdateProfileRequest;
import com.adapty.internal.data.models.requests.RestoreReceiptRequest;
import com.adapty.internal.data.models.requests.SendEventRequest;
import com.adapty.internal.data.models.requests.SetVariationIdRequest;
import com.adapty.internal.data.models.requests.UpdateAttributionRequest;
import com.adapty.internal.data.models.requests.ValidateReceiptRequest;
import com.adapty.internal.domain.models.PurchaseableProduct;
import com.adapty.internal.utils.MetaInfoRetriever;
import com.adapty.internal.utils.PayloadProvider;
import com.adapty.internal.utils.UtilsKt;
import com.adapty.models.AdaptyProfileParameters;
import com.android.billingclient.api.Purchase;
import com.google.android.gms.fitness.request.uOle.UrBgMnP;
import en.o;
import g0.b;
import java.util.List;
import java.util.Set;
import kf.pB.YHRsBUu;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.collections.a1;
import kotlin.collections.b0;
import kotlin.collections.d0;
import kotlin.collections.e0;
import kotlin.collections.j0;
import kotlin.collections.q0;
import kotlin.collections.z0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.u;
import kotlin.text.y;
import og.m;
@Metadata
public final class RequestFactory {
@Deprecated
private static final String API_KEY_PREFIX = "Api-Key ";
@Deprecated
private static final String AUTHORIZATION_KEY = "Authorization";
private static final Companion Companion = new Companion((DefaultConstructorMarker) null);
private final String apiKey;
private final String apiKeyPrefix;
private final String backendBaseUrl;
private final CacheRepository cacheRepository;
private final o gson;
private final String inappsEndpointPrefix;
private final boolean isObserverMode;
private final MetaInfoRetriever metaInfoRetriever;
private final PayloadProvider payloadProvider;
private final String profilesEndpointPrefix;
private final ResponseCacheKeyProvider responseCacheKeyProvider;
public RequestFactory(CacheRepository cacheRepository, ResponseCacheKeyProvider responseCacheKeyProvider, MetaInfoRetriever metaInfoRetriever, PayloadProvider payloadProvider, o oVar, String str, boolean z, String str2) {
Intrinsics.checkNotNullParameter(cacheRepository, "cacheRepository");
Intrinsics.checkNotNullParameter(responseCacheKeyProvider, "responseCacheKeyProvider");
Intrinsics.checkNotNullParameter(metaInfoRetriever, "metaInfoRetriever");
Intrinsics.checkNotNullParameter(payloadProvider, "payloadProvider");
Intrinsics.checkNotNullParameter(oVar, "gson");
Intrinsics.checkNotNullParameter(str, "apiKey");
Intrinsics.checkNotNullParameter(str2, "backendBaseUrl");
this.cacheRepository = cacheRepository;
this.responseCacheKeyProvider = responseCacheKeyProvider;
this.metaInfoRetriever = metaInfoRetriever;
this.payloadProvider = payloadProvider;
this.gson = oVar;
this.apiKey = str;
this.isObserverMode = z;
this.backendBaseUrl = str2;
this.inappsEndpointPrefix = "in-apps";
this.profilesEndpointPrefix = "analytics/profiles";
String str3 = (String) CollectionsKt.E(0, y.O(str, new String[]{"."}, 0, 6));
this.apiKeyPrefix = str3 == null ? "" : str3;
}
private final void addDefaultHeaders(Request.Builder builder) {
Set set;
Set e3 = a1.e(new Request.Header[]{new Request.Header("Accept-Encoding", "gzip"), new Request.Header("adapty-sdk-profile-id", this.cacheRepository.getProfileId()), new Request.Header("adapty-sdk-platform", "Android"), new Request.Header("adapty-sdk-version", "3.1.0"), new Request.Header("adapty-sdk-session", this.cacheRepository.getSessionId()), new Request.Header("adapty-sdk-device-id", this.metaInfoRetriever.getInstallationMetaId()), new Request.Header("adapty-sdk-observer-mode-enabled", String.valueOf(this.isObserverMode)), new Request.Header("adapty-sdk-android-billing-new", "true"), new Request.Header("adapty-sdk-store", this.metaInfoRetriever.getStore()), new Request.Header(AUTHORIZATION_KEY, g0.j(API_KEY_PREFIX, this.apiKey)), new Request.Header("adapty-app-version", (String) this.metaInfoRetriever.getAppBuildAndVersion().e)});
Pair crossplatformNameAndVersion = this.metaInfoRetriever.getCrossplatformNameAndVersion();
if (crossplatformNameAndVersion != null) {
set = a1.d(new Request.Header[]{new Request.Header("adapty-sdk-crossplatform-name", (String) crossplatformNameAndVersion.d), new Request.Header("adapty-sdk-crossplatform-version", (String) crossplatformNameAndVersion.e)});
} else {
set = null;
}
j0.o(e3, builder.headers);
if (set != null) {
j0.o(set, builder.headers);
}
}
private final void addResponseCacheKeys(Request.Builder builder, ResponseCacheKeys responseCacheKeys) {
builder.responseCacheKeys = responseCacheKeys;
Set set = builder.headers;
String string$adapty_release = this.cacheRepository.getString$adapty_release(responseCacheKeys.getResponseHashKey());
Request.Header header = string$adapty_release != null ? new Request.Header("adapty-sdk-previous-response-hash", string$adapty_release) : null;
j0.o(header != null ? z0.b(header) : q0.d, set);
}
private final Request buildRequest(Function1<? super Request.Builder, Unit> function1) {
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
function1.invoke(builder);
if (builder.getMethod() != Request$Method.GET) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
private final String getDisableCacheQueryParamOrEmpty() {
ProfileDto profile = this.cacheRepository.getProfile();
return profile != null ? Intrinsics.c(profile.isTestUser(), Boolean.TRUE) : false ? "?disable_cache" : "";
}
private final String getEndpointForProfileRequests(String str) {
return this.profilesEndpointPrefix + "/" + str + "/";
}
public final Request createProfileRequest(String str, InstallationMeta installationMeta, AdaptyProfileParameters adaptyProfileParameters) {
Intrinsics.checkNotNullParameter(installationMeta, "installationMeta");
String profileId = this.cacheRepository.getProfileId();
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
builder.setMethod(Request$Method.POST);
builder.body = this.gson.i(CreateOrUpdateProfileRequest.Companion.create(profileId, installationMeta, str, adaptyProfileParameters));
builder.endPoint = getEndpointForProfileRequests(profileId);
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.CreateProfile.Companion.create(!(str == null || str.length() == 0));
if (builder.getMethod() != Request$Method.GET) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
public final Request getAnalyticsConfig() {
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
Request$Method request$Method = Request$Method.GET;
builder.setMethod(request$Method);
builder.endPoint = "events/blacklist/";
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.GetAnalyticsConfig.Companion.create();
if (builder.getMethod() != request$Method) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
public final Request getIPv4Request() {
Request.Builder builder = new Request.Builder(new Request("https://api.ipify.org?format=json"));
builder.setMethod(Request$Method.GET);
return builder.build();
}
public final Request getPaywallVariationsFallbackRequest(String str, String str2) {
Intrinsics.checkNotNullParameter(str, "id");
Intrinsics.checkNotNullParameter(str2, YHRsBUu.Iuu);
Request.Builder builder = new Request.Builder(new Request("https://fallback.adapty.io/api/v1/sdk/"));
builder.setMethod(Request$Method.GET);
String extractLanguageCode = UtilsKt.extractLanguageCode(str2);
if (extractLanguageCode == null) {
extractLanguageCode = "en";
}
String builderVersion = this.metaInfoRetriever.getBuilderVersion();
String str3 = this.inappsEndpointPrefix;
String str4 = this.apiKeyPrefix;
String store = this.metaInfoRetriever.getStore();
String disableCacheQueryParamOrEmpty = getDisableCacheQueryParamOrEmpty();
StringBuilder sb2 = new StringBuilder();
sb2.append(str3);
sb2.append("/");
sb2.append(str4);
sb2.append("/paywall/variations/");
sb2.append(str);
m.s(sb2, "/", store, "/", extractLanguageCode);
builder.endPoint = g0.m(sb2, "/", builderVersion, "/fallback.json", disableCacheQueryParamOrEmpty);
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.GetFallbackPaywall.Companion.create(this.apiKeyPrefix, str, extractLanguageCode);
return builder.build();
}
public final Request getPaywallVariationsRequest(String str, String str2, String str3) {
g0.u(str, "id", str2, "locale", str3, "segmentId");
String profileId = this.cacheRepository.getProfileId();
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
Request$Method request$Method = Request$Method.GET;
builder.setMethod(request$Method);
String builderVersion = this.metaInfoRetriever.getBuilderVersion();
String payloadHashForPaywallRequest = this.payloadProvider.getPayloadHashForPaywallRequest(str2, str3, builderVersion);
String str4 = this.inappsEndpointPrefix;
String str5 = this.apiKeyPrefix;
String disableCacheQueryParamOrEmpty = getDisableCacheQueryParamOrEmpty();
StringBuilder sb2 = new StringBuilder();
sb2.append(str4);
sb2.append("/");
sb2.append(str5);
sb2.append("/paywall/variations/");
sb2.append(str);
builder.endPoint = g0.m(sb2, "/", payloadHashForPaywallRequest, "/", disableCacheQueryParamOrEmpty);
Set set = builder.headers;
Request.Header[] headerArr = new Request.Header[4];
headerArr[0] = new Request.Header("adapty-paywall-locale", str2);
headerArr[1] = new Request.Header("adapty-paywall-builder-version", builderVersion);
headerArr[2] = new Request.Header("adapty-profile-segment-hash", str3);
String adaptyUiVersionOrNull = this.metaInfoRetriever.getAdaptyUiVersionOrNull();
headerArr[3] = adaptyUiVersionOrNull != null ? new Request.Header("adapty-ui-version", adaptyUiVersionOrNull) : null;
Intrinsics.checkNotNullParameter(headerArr, "elements");
j0.o(b0.n(headerArr), set);
builder.currentDataWhenSent = Request.CurrentDataWhenSent.Companion.create(profileId);
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.GetPaywall.Companion.create(this.apiKeyPrefix, str, str2, str3, payloadHashForPaywallRequest);
if (builder.getMethod() != request$Method) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
public final Request getPaywallVariationsUntargetedRequest(String str, String str2) {
Intrinsics.checkNotNullParameter(str, "id");
Intrinsics.checkNotNullParameter(str2, "locale");
Request.Builder builder = new Request.Builder(new Request("https://configs-cdn.adapty.io/api/v1/sdk/"));
builder.setMethod(Request$Method.GET);
String extractLanguageCode = UtilsKt.extractLanguageCode(str2);
if (extractLanguageCode == null) {
extractLanguageCode = "en";
}
String builderVersion = this.metaInfoRetriever.getBuilderVersion();
String str3 = this.inappsEndpointPrefix;
String str4 = this.apiKeyPrefix;
String store = this.metaInfoRetriever.getStore();
StringBuilder sb2 = new StringBuilder();
sb2.append(str3);
sb2.append("/");
sb2.append(str4);
sb2.append("/paywall/variations/");
sb2.append(str);
m.s(sb2, "/", store, "/", extractLanguageCode);
builder.endPoint = m.j(sb2, "/", builderVersion, "/fallback.json");
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.GetUntargetedPaywall.Companion.create(this.apiKeyPrefix, str, extractLanguageCode);
return builder.build();
}
public final Request getProductIdsRequest() {
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
Request$Method request$Method = Request$Method.GET;
builder.setMethod(request$Method);
String str = this.inappsEndpointPrefix;
String str2 = this.apiKeyPrefix;
String store = this.metaInfoRetriever.getStore();
String disableCacheQueryParamOrEmpty = getDisableCacheQueryParamOrEmpty();
StringBuilder sb2 = new StringBuilder();
sb2.append(str);
sb2.append("/");
sb2.append(str2);
sb2.append("/products-ids/");
sb2.append(store);
builder.endPoint = b.n(sb2, "/", disableCacheQueryParamOrEmpty);
addResponseCacheKeys(builder, this.responseCacheKeyProvider.forGetProductIds());
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.GetProductIds.Companion.create();
if (builder.getMethod() != request$Method) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
public final Request getProfileRequest() {
String profileId = this.cacheRepository.getProfileId();
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
Request$Method request$Method = Request$Method.GET;
builder.setMethod(request$Method);
builder.endPoint = getEndpointForProfileRequests(profileId);
addResponseCacheKeys(builder, this.responseCacheKeyProvider.forGetProfile());
builder.currentDataWhenSent = Request.CurrentDataWhenSent.Companion.create(profileId);
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.GetProfile.Companion.create();
if (builder.getMethod() != request$Method) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
public final Request getViewConfigurationFallbackRequest(String str, String str2) {
Intrinsics.checkNotNullParameter(str, "paywallId");
Intrinsics.checkNotNullParameter(str2, "locale");
Request.Builder builder = new Request.Builder(new Request("https://fallback.adapty.io/api/v1/sdk/"));
builder.setMethod(Request$Method.GET);
String builderVersion = this.metaInfoRetriever.getBuilderVersion();
String extractLanguageCode = UtilsKt.extractLanguageCode(str2);
if (extractLanguageCode == null) {
extractLanguageCode = "en";
}
String str3 = this.inappsEndpointPrefix;
String str4 = this.apiKeyPrefix;
String disableCacheQueryParamOrEmpty = getDisableCacheQueryParamOrEmpty();
StringBuilder sb2 = new StringBuilder();
sb2.append(str3);
sb2.append("/");
sb2.append(str4);
sb2.append("/paywall-builder/");
sb2.append(str);
m.s(sb2, "/", builderVersion, "/", extractLanguageCode);
builder.endPoint = b.n(sb2, "/fallback.json", disableCacheQueryParamOrEmpty);
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.GetFallbackPaywallBuilder.Companion.create(this.apiKeyPrefix, str, builderVersion, extractLanguageCode);
return builder.build();
}
public final Request getViewConfigurationRequest(String str, String str2) {
Intrinsics.checkNotNullParameter(str, "variationId");
Intrinsics.checkNotNullParameter(str2, "locale");
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
Request$Method request$Method = Request$Method.GET;
builder.setMethod(request$Method);
String adaptyUiVersion = this.metaInfoRetriever.getAdaptyUiVersion();
String builderVersion = this.metaInfoRetriever.getBuilderVersion();
String payloadHashForPaywallBuilderRequest = this.payloadProvider.getPayloadHashForPaywallBuilderRequest(str2, builderVersion);
String str3 = this.inappsEndpointPrefix;
String str4 = this.apiKeyPrefix;
String disableCacheQueryParamOrEmpty = getDisableCacheQueryParamOrEmpty();
StringBuilder sb2 = new StringBuilder();
sb2.append(str3);
sb2.append("/");
sb2.append(str4);
sb2.append("/paywall-builder/");
sb2.append(str);
builder.endPoint = g0.m(sb2, "/", payloadHashForPaywallBuilderRequest, "/", disableCacheQueryParamOrEmpty);
j0.o(e0.g(new Request.Header[]{new Request.Header("adapty-paywall-builder-locale", str2), new Request.Header("adapty-paywall-builder-version", builderVersion), new Request.Header("adapty-ui-version", adaptyUiVersion)}), builder.headers);
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.GetPaywallBuilder.Companion.create(str);
if (builder.getMethod() != request$Method) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
public final Request restorePurchasesRequest(List list) {
Intrinsics.checkNotNullParameter(list, "purchases");
String profileId = this.cacheRepository.getProfileId();
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
builder.setMethod(Request$Method.POST);
builder.body = this.gson.i(RestoreReceiptRequest.Companion.create(profileId, list));
builder.endPoint = "purchase/play-store/token/v2/restore/";
Request.CurrentDataWhenSent.Companion companion = Request.CurrentDataWhenSent.Companion;
String customerUserId = this.cacheRepository.getCustomerUserId();
if (customerUserId == null || !(!u.i(customerUserId))) {
customerUserId = null;
}
builder.currentDataWhenSent = companion.create(profileId, customerUserId);
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.Restore.Companion.create(list);
if (builder.getMethod() != Request$Method.GET) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
public final Request sendAnalyticsEventsRequest(List list) {
Intrinsics.checkNotNullParameter(list, SendEventRequestSerializer.EVENTS);
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
builder.setMethod(Request$Method.POST);
builder.endPoint = "events/";
builder.body = this.gson.i(SendEventRequest.Companion.create(list));
if (builder.getMethod() != Request$Method.GET) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
public final Request setVariationIdRequest(String str, String str2) {
Intrinsics.checkNotNullParameter(str, "transactionId");
Intrinsics.checkNotNullParameter(str2, "variationId");
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
builder.setMethod(Request$Method.POST);
builder.endPoint = "purchase/transaction/variation-id/set/";
builder.body = this.gson.i(SetVariationIdRequest.Companion.create(str, str2));
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.SetVariationId.Companion.create(str, str2);
if (builder.getMethod() != Request$Method.GET) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
public final Request updateAttributionRequest(AttributionData attributionData) {
Intrinsics.checkNotNullParameter(attributionData, "attributionData");
String profileId = this.cacheRepository.getProfileId();
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
builder.setMethod(Request$Method.POST);
builder.endPoint = g0.x(getEndpointForProfileRequests(profileId), "attribution/");
builder.body = this.gson.i(UpdateAttributionRequest.Companion.create(attributionData));
builder.currentDataWhenSent = Request.CurrentDataWhenSent.Companion.create(profileId);
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.SetAttribution.Companion.create(attributionData);
if (builder.getMethod() != Request$Method.GET) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
public final Request updateProfileRequest(AdaptyProfileParameters adaptyProfileParameters, InstallationMeta installationMeta, String str) {
String profileId = this.cacheRepository.getProfileId();
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
builder.setMethod(Request$Method.PATCH);
builder.body = this.gson.i(CreateOrUpdateProfileRequest.Companion.create(profileId, installationMeta, adaptyProfileParameters, str));
builder.endPoint = getEndpointForProfileRequests(profileId);
addResponseCacheKeys(builder, this.responseCacheKeyProvider.forGetProfile());
builder.currentDataWhenSent = Request.CurrentDataWhenSent.Companion.create(profileId);
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.UpdateProfile.Companion.create();
if (builder.getMethod() != Request$Method.GET) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
public final Request validatePurchaseRequest(Purchase purchase, PurchaseableProduct purchaseableProduct) {
Intrinsics.checkNotNullParameter(purchase, "purchase");
Intrinsics.checkNotNullParameter(purchaseableProduct, UrBgMnP.auJC);
String profileId = this.cacheRepository.getProfileId();
Request.Builder builder = new Request.Builder(this.backendBaseUrl);
builder.setMethod(Request$Method.POST);
builder.endPoint = "purchase/play-store/token/v2/validate/";
builder.body = this.gson.i(ValidateReceiptRequest.Companion.create(profileId, purchase, purchaseableProduct));
builder.currentDataWhenSent = Request.CurrentDataWhenSent.Companion.create(profileId);
builder.systemLog = AnalyticsEvent.BackendAPIRequestData.Validate.Companion.create(purchaseableProduct, purchase);
if (builder.getMethod() != Request$Method.GET) {
j0.o(d0.b(new Request.Header("Content-type", "application/vnd.api+json")), builder.headers);
}
addDefaultHeaders(builder);
return builder.build();
}
}