using System.Collections.Generic;
using LitJson;

namespace Wizard;

public class VoteDataTask : BaseTask
{
	public class VoteDataTaskParam : BaseParam
	{
		public int vote_id;
	}

	public VoteDataTask()
	{
		base.type = ApiType.Type.VoteData;
	}

	public void SetParameter(int vote_id)
	{
		VoteDataTaskParam voteDataTaskParam = new VoteDataTaskParam();
		voteDataTaskParam.vote_id = vote_id;
		base.Params = voteDataTaskParam;
	}

	protected override int Parse()
	{
		int num = base.Parse();
		if (num != 1)
		{
			return num;
		}
		Data.VoteInfo = new VoteData();
		Data.VoteInfo.is_vote = base.ResponseData["data"]["is_vote"].ToBoolean();
		if (base.ResponseData["data"].Keys.Contains("vote_name"))
		{
			Data.VoteInfo.vote_name = base.ResponseData["data"]["vote_name"].ToString();
		}
		JsonData jsonData = base.ResponseData["data"]["vote_info"];
		Data.VoteInfo.title_text = jsonData["title_text"].ToString();
		Data.VoteInfo.before_content_text = jsonData["before_content_text"].ToString().Replace("/n", "\n");
		Data.VoteInfo.after_content_text = jsonData["after_content_text"].ToString().Replace("/n", "\n");
		Data.VoteInfo.tweet_text = jsonData["tweet_text"].ToString();
		Data.VoteInfo.tweet_tag = jsonData["tweet_tag"].ToString();
		Data.VoteInfo.tweet_url = jsonData["tweet_url"].ToString();
		Data.VoteInfo.tweet_image = jsonData["tweet_image"].ToString();
		JsonData jsonData2 = base.ResponseData["data"]["vote_list"];
		Data.VoteInfo.vote_target_list = new Dictionary<int, string>();
		for (int i = 0; i < jsonData2.Count; i++)
		{
			Data.VoteInfo.vote_target_list.Add(jsonData2[i]["target_id"].ToInt(), jsonData2[i]["vote_name"].ToString());
		}
		return num;
	}
}
