using System;
using Common;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Common
{
    public abstract class CommonResponse
    {
        public string? requestId { get; set; }
        public string? errorCode { get; set; }
        public string? message { get; set; }
        public string? responseTime { get; set; }
        public string? totalRow { get; set; }
        public string? totalPage { get; set; }
        public string? pageNumber { get; set; }
        public string? pageSIze { get; set; }


        public void BuildCommonResponse(String data)
        {
            JObject jObject = JObject.Parse(data);
            if (jObject != null)
            {
                requestId = (string)jObject[nameof(requestId)];
                responseTime = (string)jObject[nameof(responseTime)];
                totalRow = (string)jObject[nameof(totalRow)];
                totalPage = (string)jObject[nameof(totalPage)];
                pageNumber = (string)jObject[nameof(pageNumber)];
                pageSIze = (string)jObject[nameof(pageSIze)];
                errorCode = (string)jObject[nameof(errorCode)];
                message = (string)jObject[nameof(message)];
            }
        }
    }
}

