125 lines
3.0 KiB
C#
125 lines
3.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace WZ
|
|
{
|
|
public static class KwaiAdsConfigParser
|
|
{
|
|
private static KwaiBiddingConfig _rvConfig;
|
|
private static KwaiBiddingConfig _ivConfig;
|
|
public static void Parse(string json, bool isRv)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(json))
|
|
{
|
|
LoggerUtils.Error("KwaiBiddingConfig JSON string is null or empty");
|
|
}
|
|
|
|
if (isRv)
|
|
{
|
|
_rvConfig = JsonUtility.FromJson<KwaiBiddingConfig>(json);
|
|
}
|
|
else
|
|
{
|
|
_ivConfig = JsonUtility.FromJson<KwaiBiddingConfig>(json);
|
|
}
|
|
|
|
LoggerUtils.Info("KwaiBiddingConfig parsed successfully");
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LoggerUtils.Error($"Error parsing KwaiBiddingConfig: {e.Message}");
|
|
}
|
|
}
|
|
|
|
public static bool GetKwaiRvFloorOpen()
|
|
{
|
|
if (_rvConfig == null)
|
|
{
|
|
return false;
|
|
}
|
|
return _rvConfig.kwai_floor_open == 1;
|
|
}
|
|
|
|
public static int GetRvParallelRequests()
|
|
{
|
|
if (_rvConfig == null)
|
|
{
|
|
return 0;
|
|
}
|
|
return _rvConfig.parallel_requests;
|
|
}
|
|
|
|
public static List<FloorConfig> GetRvFloorConfigs()
|
|
{
|
|
if (_rvConfig == null)
|
|
{
|
|
return null;
|
|
}
|
|
return _rvConfig.floors;
|
|
}
|
|
|
|
public static bool GetKwaiIvFloorOpen()
|
|
{
|
|
if (_ivConfig == null)
|
|
{
|
|
return false;
|
|
}
|
|
return _ivConfig.kwai_floor_open == 1;
|
|
}
|
|
|
|
public static int GetIvParallelRequests()
|
|
{
|
|
if (_ivConfig == null)
|
|
{
|
|
return 0;
|
|
}
|
|
return _ivConfig.parallel_requests;
|
|
}
|
|
|
|
public static List<FloorConfig> GetIvFloorConfigs()
|
|
{
|
|
if (_ivConfig == null)
|
|
{
|
|
return null;
|
|
}
|
|
return _ivConfig.floors;
|
|
}
|
|
|
|
public static string GetKwaiAppId()
|
|
{
|
|
return _rvConfig?.kwai_appid;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取 Kwai App Token
|
|
/// </summary>
|
|
public static string GetKwaiAppToken()
|
|
{
|
|
return _rvConfig?.kwai_apptoken;
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class FloorConfig
|
|
{
|
|
public string id;
|
|
public string unite_id;
|
|
public float price;
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class KwaiBiddingConfig
|
|
{
|
|
public int kwai_floor_open;
|
|
public string kwai_appid;
|
|
public string kwai_apptoken;
|
|
public int parallel_requests;
|
|
public List<FloorConfig> floors;
|
|
}
|
|
}
|
|
}
|
|
|