using LitJson;

namespace Cute;

public class PaymentPCItemListTask : NetworkTask
{
	private CuteNetworkDefine.ApiType apiType = CuteNetworkDefine.ApiType.PaymentPCItemList;

	public override string Url => $"{CustomPreference.GetApplicationServerURL()}{CuteNetworkDefine.ApiUrlList[apiType]}";

	protected override int Parse()
	{
		PaymentPC instance = PaymentPC.GetInstance();
		resultCode = (int)base.ResponseData["data_headers"]["result_code"];
		if (resultCode != 1)
		{
			return resultCode;
		}
		JsonData jsonData = base.ResponseData["data"];
		instance.ProductIdList.Clear();
		instance.IdList.Clear();
		instance.ProductNameList.Clear();
		instance.ProductPriceList.Clear();
		instance.ProductTextList.Clear();
		instance.ProductPurchaseLimitList.Clear();
		instance.FormatProductPriceList.Clear();
		instance.ProductCsvIdList.Clear();
		instance.ProductImageNameList.Clear();
		instance.ProductIsSpecialShop.Clear();
		instance.ProductCurrentPurchaseCount.Clear();
		instance.ProductEndTime.Clear();
		for (int i = 0; i < jsonData.Count; i++)
		{
			JsonData jsonData2 = jsonData[i];
			string text = jsonData2["store_product_id"].ToString();
			string value = jsonData2["name"].ToString().Replace("\\n", "\n");
			string value2 = jsonData2["text"].ToString();
			string value3 = jsonData2["price"].ToString();
			string text2 = jsonData2["purchase_limit"].ToString();
			string text3 = jsonData2["id"].ToString();
			string value4 = jsonData2["image_name"].ToString();
			string value5 = jsonData2["end_time"].ToString();
			bool value6 = ((jsonData2["special_shop_flag"].ToInt() != 0) ? true : false);
			int value7 = jsonData2["purchase_num_current"].ToInt();
			instance.ProductIdList.Add(text);
			instance.IdList.Add(text3);
			instance.ProductNameList.Add(text, value);
			instance.ProductPriceList.Add(text, value3);
			instance.FormatProductPriceList.Add(text, value3);
			instance.ProductTextList.Add(text, value2);
			instance.ProductPurchaseLimitList.Add(text3, text2);
			instance.ProductCsvIdList.Add(text, text3);
			instance.ProductImageNameList.Add(text, value4);
			instance.ProductIsSpecialShop.Add(text, value6);
			instance.ProductCurrentPurchaseCount.Add(text, value7);
			instance.ProductPurchaseLimitCount.Add(text, int.Parse(text2));
			instance.ProductEndTime.Add(text, value5);
		}
		return resultCode;
	}
}
