using Newtonsoft.Json.Linq;
using System.Collections.Generic;

namespace SicboSub.Web.Models
{
    public class RankingHistoryReq
    {
        public string msisdn { get; set; } = null!;
        public string? lang { get; set; }
        public string? rankType { get; set; } 
        public string? fromDate { get; set; }
        public string? toDate { get; set; }
        public int pageNumber { get; set; } = 0;
        public int pageSize { get; set; } = 20;
    }

    public class RankingHistoryItem
    {
        public decimal id { get; set; }
        public string msisdn { get; set; } 
        public string rankType { get; set; }
        public DateTime rankDate { get; set; }
        public decimal rankPosition { get; set; }
        public decimal rewardValue { get; set; }
        public string rewardUnit { get; set; }
        public DateTime rewardDate { get; set; }
        public decimal totalBetValue { get; set; }
    }

    public class RankingHistoryRes : CommonResponse
    {
        public List<RankingHistoryItem>? data { get; set; }

        public RankingHistoryRes(string dataGet)
        {
            JObject jObject = JObject.Parse(dataGet);
            BuildCommonResponse(dataGet);

            if (jObject != null && jObject["data"] != null)
            {
                // The API returns data as an object: { "history": [...], "pagination": {...} }
                var dataObj = jObject["data"];
                if (dataObj["history"] != null)
                {
                    data = dataObj["history"]!.ToObject<List<RankingHistoryItem>>();
                }
            }
        }
    }
}
