using System.Collections.Generic;
using LitJson;

namespace Wizard;

public class GatheringInviteUserListTask : BaseTask
{
	public class InviteUserInfo
	{
		public string InviteId { get; private set; }

		public GatheringUserInfo userInfo { get; private set; }

		public InviteUserInfo(JsonData json)
		{
			InviteId = json["id"].ToString();
			userInfo = new GatheringUserInfo(json["user_info"]);
		}
	}

	public class GatheringInviteUserListTaskParam : BaseParam
	{
		public int page;

		public int oldest_time;
	}

	private Dictionary<int, string> _inviteIdDictionary;

	public List<InviteUserInfo> InviteUserInfoList { get; private set; }

	public GatheringInviteUserListTask()
	{
		base.type = ApiType.Type.GatheringInviteUserList;
	}

	public void SetParameter()
	{
		GatheringInviteUserListTaskParam gatheringInviteUserListTaskParam = new GatheringInviteUserListTaskParam();
		gatheringInviteUserListTaskParam.page = 0;
		gatheringInviteUserListTaskParam.oldest_time = 0;
		base.Params = gatheringInviteUserListTaskParam;
	}

	protected override int Parse()
	{
		int num = base.Parse();
		if (num != 1)
		{
			return num;
		}
		_inviteIdDictionary = new Dictionary<int, string>();
		InviteUserInfoList = new List<InviteUserInfo>();
		JsonData jsonData = base.ResponseData["data"]["invite_list"];
		for (int i = 0; i < jsonData.Count; i++)
		{
			InviteUserInfo inviteUserInfo = new InviteUserInfo(jsonData[i]);
			InviteUserInfoList.Add(inviteUserInfo);
			_inviteIdDictionary[inviteUserInfo.userInfo.ViewerId] = inviteUserInfo.InviteId;
		}
		return num;
	}

	public string GetInviteIdFromViewerId(int viewerId)
	{
		return _inviteIdDictionary[viewerId];
	}
}
