using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Web.Script.Serialization;

namespace ZionRobot.WebService
{
    public class LawsuitPhase
    {
        internal List<Models.ZFlow.LawsuitPhase> LawsuitPhasesToSync()
        {
            string result = new ZionVault.WebService.Client(Persistence.WSProperties.UrlApi)._request("GET",
                Persistence.WSProperties.LawsuitPhasesToSync,
                Persistence.WSProperties.Token,
                null,
                string.Empty,
                null);
                
            var json = JsonConvert.DeserializeObject<List<Models.ZFlow.LawsuitPhase>>(result);

            return json;
        }
        internal string UpdateUrl(Models.ZFlow.LawsuitPhase lawsuitPhase)
        {
            var a = new JavaScriptSerializer().Serialize(new
            {
                lawsuitPhase
            });
            return new ZionVault.WebService.Client(Persistence.WSProperties.UrlApi)._request("PUT",
                Persistence.WSProperties.UpdateLawsuitPhaseLink,
                Persistence.WSProperties.Token,
                null,
                a
                ,
                null);
        }
        internal string UpdateSync(Models.ZFlow.LawsuitPhase lawsuitPhase, int status)
        {
            return new ZionVault.WebService.Client(Persistence.WSProperties.UrlApi)._request("PUT",
                Persistence.WSProperties.UpdateLawsuitPhaseSync,
                Persistence.WSProperties.Token,
                null,
                new JavaScriptSerializer().Serialize(new
                {
                    EntityId = lawsuitPhase.EntityId,
                    ClientId = lawsuitPhase.ClientId,
                    FieldOfLawId = lawsuitPhase.FieldOfLawId,
                    LawsuitId = lawsuitPhase.LawsuitId,
                    Id = lawsuitPhase.Id,
                    SyncId = lawsuitPhase.SyncId,
                    SyncStatus = status
                }),
                null);
        }
    }
}
