package com.blaze.rtnblazegam.module import android.util.Log import androidx.annotation.Keep import com.blaze.gam.custom_native.BlazeGAMCustomNativeAdsDefaultConfig import com.facebook.react.bridge.ReadableMap import com.google.gson.Gson @Keep data class BlazeRTNEnableCustomNativeAdsOptions( val defaultAdConfig: BlazeRTNDefaultAdConfig? ) { @Keep data class BlazeRTNDefaultAdConfig( val adUnit: String, val templateId: String ) } fun ReadableMap.extractEnableCustomNativeAdsOptions(): BlazeRTNEnableCustomNativeAdsOptions? { return try { val gson = Gson() val jsonString = gson.toJson(this.toHashMap()) gson.fromJson(jsonString, BlazeRTNEnableCustomNativeAdsOptions::class.java) } catch (e: Exception) { Log.e(BlazeGAMSdkModule.TAG, "Error decoding JSON with Gson: $e") null } } val BlazeRTNEnableCustomNativeAdsOptions.BlazeRTNDefaultAdConfig.asNativeModel: BlazeGAMCustomNativeAdsDefaultConfig get() = BlazeGAMCustomNativeAdsDefaultConfig( adUnit = adUnit, templateId = templateId )