namespace Guru
{
    using System.Collections.Generic;
    using System.Text;
    /// 
    /// 启动参数配置
    /// 
    public partial class GuruSDKInitConfig
    {
        /// 
        /// 使用自定义的ConsentFlow启动流程
        /// 
        public bool UseCustomConsent = false;
        /// 
        /// SDK初始化完成后自动加载广告
        /// 
        public bool AutoLoadWhenAdsReady = true;
        /// 
        /// 使用IAP支付插件功能
        /// 
        public bool IAPEnabled = true;
        /// 
        /// 自动申请推送授权信息
        /// 
        public bool AutoNotificationPermission = true;
        /// 
        /// 自动记录完成的关卡
        /// 
        public bool AutoRecordFinishedLevels = true;
        /// 
        /// 自定义 Service 云控 Key
        /// 
        public string CustomServiceKey = "";
        /// 
        /// Banner 背景颜色 Hex 值
        /// 
        public string BannerBackgroundColor = "#00000000";
        /// 
        /// 已购买去广告道具
        /// 
        public bool IsBuyNoAds = false;
        /// 
        /// Debug模式(默认关闭)
        /// 
        public bool DebugMode = false;
        /// 
        /// Debug模式下开启打点(默认关闭)
        /// 
        public bool EnableDebugLogEvent = false;
        /// 
        /// 云控参数的默认配置
        /// 
        /// 
        public Dictionary DefaultRemoteData = new Dictionary();
        /// 
        /// 启用 AdjustDeeplink
        /// 
        public bool UseAdjustDeeplink = false;
        
        /// 
        /// 支付初始化Keys
        /// 
        public byte[] GoogleKeys;       // 数据取自 GooglePlayTangle.Data();
        public byte[] AppleRootCerts;   // 数据取自 AppleTangle.Data();
        
        #region Initialization
        
        /// 
        /// 构建启动配置
        /// 
        /// 
        public static GuruSDKInitConfig Build(
            bool useCustomConsent = false, 
            bool autoLoadAds = true, 
            bool iapEnabled = true, 
            bool autoRecordFinishedLevels = true, 
            bool isBuyNoAds = false,
            string bannerBackgroundColor = "#00000000",
            bool debugMode = false,
            bool useAdjustDeeplink = false,
            Dictionary defaultRemoteData = null,
            byte[] googleKeys = null,
            byte[] appleRootCerts = null,
            bool debugEnableEventLog = false)
        {
            // 创建启动用参数
            GuruSDKInitConfig config = new GuruSDKInitConfig()
            {
                UseCustomConsent = useCustomConsent,
                AutoLoadWhenAdsReady = autoLoadAds,
                IAPEnabled = iapEnabled,
                AutoRecordFinishedLevels = autoRecordFinishedLevels,
                IsBuyNoAds = isBuyNoAds,
                BannerBackgroundColor = bannerBackgroundColor,
                DebugMode = debugMode,
                UseAdjustDeeplink = useAdjustDeeplink,
                GoogleKeys = googleKeys,
                AppleRootCerts = appleRootCerts,
                DefaultRemoteData = defaultRemoteData ?? new Dictionary(),
                EnableDebugLogEvent = debugEnableEventLog,
            };
#if UNITY_EDITOR
            config.DebugMode = true;
#endif
            return config;
        }
        
        #endregion
        #region Print
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine($"------- Custom InitConfig -------");
            sb.AppendLine($"\t  UseCustomConsent: {UseCustomConsent}");
            sb.AppendLine($"\t  AutoLoadWhenAdsReady: {AutoLoadWhenAdsReady}");
            sb.AppendLine($"\t  IAPEnabled: {IAPEnabled}");
            sb.AppendLine($"\t  AutoNotificationPermission: {AutoNotificationPermission}");
            sb.AppendLine($"\t  AutoRecordFinishedLevels: {AutoRecordFinishedLevels}");
            sb.AppendLine($"\t  CustomServiceKey: {CustomServiceKey}");
            sb.AppendLine($"\t  BannerBackgroundColor: {BannerBackgroundColor}");
            sb.AppendLine($"\t  IsBuyNoAds: {IsBuyNoAds}");
            sb.AppendLine($"\t  DebugMode: {DebugMode}");
            sb.AppendLine($"\t  DefaultRemote: Count: {DefaultRemoteData.Count}");
            sb.AppendLine($"------- Custom InitConfig -------");
            return sb.ToString();
        }
        #endregion
    }
}