package co.ab180.airbridge.reactnative.extension import co.ab180.airbridge.AirbridgeInAppPurchaseEnvironment import co.ab180.airbridge.AirbridgeLogLevel import co.ab180.airbridge.AirbridgeOptionBuilder internal fun AirbridgeOptionBuilder.setAirbridgeJSON( airbridgeJSON: Map? ): AirbridgeOptionBuilder { val json = airbridgeJSON ?: return this (json["sdkEnabled"] as? Boolean)?.also { setSDKEnabled(it) } (json["logLevel"] as? String)?.also { when (it) { "debug" -> setLogLevel(AirbridgeLogLevel.DEBUG) "info" -> setLogLevel(AirbridgeLogLevel.INFO) "warning" -> setLogLevel(AirbridgeLogLevel.WARNING) "error" -> setLogLevel(AirbridgeLogLevel.ERROR) "fault" -> setLogLevel(AirbridgeLogLevel.FAULT) else -> {} } } (json["autoStartTrackingEnabled"] as? Boolean)?.also { setAutoStartTrackingEnabled(it) } (json["trackingLinkCustomDomains"] as? List<*>)?.also { array -> setCustomDomains(array.mapNotNull { it as? String }) } (json["trackMetaDeferredAppLinkEnabled"] as? Boolean)?.also { setTrackMetaDeferredAppLinkEnabled(it) } (json["sessionTimeoutInSecond"] as? Number)?.also { setSessionTimeout(it.toLong()) } (json["appStoreName"] as? String)?.also { setAppMarketIdentifier(it) } (json["collectLocationEnabled"] as? Boolean)?.also { setCollectLocationEnabled(it) } (json["metaInstallReferrerAppID"] as? String)?.also { setMetaInstallReferrer(it) } (json["trackAirbridgeDeeplinkOnlyEnabled"] as? Boolean)?.also { setTrackAirbridgeDeeplinkOnlyEnabled(it) } (json["trackInSessionLifecycleEventEnabled"] as? Boolean)?.also { setTrackInSessionLifeCycleEventEnabled(it) } (json["hashUserInformationEnabled"] as? Boolean)?.also { setHashUserInformationEnabled(it) } (json["sdkSignatureID"] as? String)?.also { id -> (json["sdkSignatureSecret"] as? String)?.also { secret -> setSDKSignature(id, secret) } } (json["clearEventBufferOnInitializeEnabled"] as? Boolean)?.also { setClearEventBufferOnInitializeEnabled(it) } (json["eventBufferCountLimit"] as? Number)?.also { setEventBufferCountLimit(it.toInt()) } (json["eventBufferSizeLimitInGibibyte"] as? Number)?.also { setEventBufferSizeLimit(it.toDouble()) } (json["pauseEventTransmitOnBackgroundEnabled"] as? Boolean)?.also { setPauseEventTransmitOnBackgroundEnabled(it) } (json["eventTransmitIntervalInSecond"] as? Number)?.also { setEventTransmitInterval(it.toLong()) } (json["errorLogCollectionEnabled"] as? Boolean)?.also { setErrorLogCollectionEnabled(it) } // 4.4.0 (json["inAppPurchaseEnvironment"] as? String)?.also { it.lowercase().run { when(it) { AirbridgeInAppPurchaseEnvironment.SANDBOX.name.lowercase() -> setInAppPurchaseEnvironment(AirbridgeInAppPurchaseEnvironment.SANDBOX) AirbridgeInAppPurchaseEnvironment.PRODUCTION.name.lowercase() -> setInAppPurchaseEnvironment(AirbridgeInAppPurchaseEnvironment.PRODUCTION) else -> { // no-op } } } } (json["collectTCFDataEnabled"] as? Boolean)?.also { setCollectTCFDataEnabled(it) } return this }