using System;
using Steamworks;

namespace Cute;

public class SteamMicroTxnInitTask : NetworkTask
{
	private class MicroTxtInitPost : PostParams
	{
		public new string steam_id = "";

		public string app_id = "";

		public string currency = "";

		public string ip_address = "";

		public string item_id = "";
	}

	private CuteNetworkDefine.ApiType apiType = CuteNetworkDefine.ApiType.SteamMicroTxnInit;

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

	public void SetParameter(string item_id)
	{
		MicroTxtInitPost microTxtInitPost = new MicroTxtInitPost();
		try
		{
			microTxtInitPost.steam_id = SteamUser.GetSteamID().ToString();
			microTxtInitPost.app_id = SteamUtils.GetAppID().ToString();
		}
		catch (Exception ex)
		{
			Debug.LogError(ex.Message);
			Debug.LogError(ex.StackTrace);
			Debug.LogError("steam client を起動してください。");
		}
		microTxtInitPost.currency = PCPlatformSTEAM.Currency;
		microTxtInitPost.ip_address = Toolbox.DeviceManager.GetIpAddress();
		microTxtInitPost.item_id = item_id;
		base.Params = microTxtInitPost;
	}

	protected override int Parse()
	{
		int result = base.Parse();
		_ = 1;
		return result;
	}
}
