From d05c6772c22b1f47894c1d46db0ba7eb92e31352 Mon Sep 17 00:00:00 2001 From: SlejmUr Date: Tue, 19 Sep 2023 07:31:31 +0200 Subject: [PATCH] Json (C#) Update --- PayCheckServerLib/Jsons/Challenges.cs | 113 ++++++++++++-------------- PayCheckServerLib/Jsons/DataPaging.cs | 14 ++++ PayCheckServerLib/Responses/Items.cs | 6 +- 3 files changed, 68 insertions(+), 65 deletions(-) diff --git a/PayCheckServerLib/Jsons/Challenges.cs b/PayCheckServerLib/Jsons/Challenges.cs index 265bf54..fb14f0a 100644 --- a/PayCheckServerLib/Jsons/Challenges.cs +++ b/PayCheckServerLib/Jsons/Challenges.cs @@ -4,29 +4,29 @@ namespace PayCheckServerLib.Jsons { public partial class ChallengesData { - [JsonProperty("challenge")] - public Challenge Challenge { get; set; } - - [JsonProperty("isActive")] - public bool IsActive { get; set; } + [JsonProperty("recordId")] + public string RecordId { get; set; } [JsonProperty("namespace")] - public string Namespace { get; set; } = "pd3"; + public string Namespace { get; set; } + + [JsonProperty("userId")] + public string UserId { get; set; } + + [JsonProperty("challenge")] + public Challenge Challenge { get; set; } [JsonProperty("progress")] public Progress Progress { get; set; } - [JsonProperty("recordId")] - public string RecordId { get; set; } + [JsonProperty("updatedAt")] + public string UpdatedAt { get; set; } [JsonProperty("status")] public string Status { get; set; } - [JsonProperty("updatedAt")] - public string UpdatedAt { get; set; } - - [JsonProperty("userId")] - public string UserId { get; set; } + [JsonProperty("isActive")] + public bool IsActive { get; set; } } public partial class Challenge @@ -34,44 +34,44 @@ public partial class Challenge [JsonProperty("challengeId")] public string ChallengeId { get; set; } - [JsonProperty("createdAt")] - public string CreatedAt { get; set; } - - [JsonProperty("description")] - public string Description { get; set; } - - [JsonProperty("isActive")] - public bool IsActive { get; set; } - - [JsonProperty("name")] - public string Name { get; set; } - [JsonProperty("namespace")] public string Namespace { get; set; } - [JsonProperty("objective")] - public ChallengeObjective Objective { get; set; } + [JsonProperty("name")] + public string Name { get; set; } - [JsonProperty("orderNo")] - public long OrderNo { get; set; } + [JsonProperty("description")] + public string Description { get; set; } [JsonProperty("prerequisite")] public ChallengePrerequisite Prerequisite { get; set; } + [JsonProperty("objective")] + public ChallengeObjective Objective { get; set; } + [JsonProperty("reward")] public Reward Reward { get; set; } [JsonProperty("tags")] public List Tags { get; set; } + [JsonProperty("orderNo")] + public long OrderNo { get; set; } + + [JsonProperty("createdAt")] + public string CreatedAt { get; set; } + [JsonProperty("updatedAt")] public string UpdatedAt { get; set; } + + [JsonProperty("isActive")] + public bool IsActive { get; set; } } public partial class ChallengeObjective { [JsonProperty("stats")] - public List Stats { get; set; } + public RewardStat[] Stats { get; set; } } public partial class RewardStat @@ -85,47 +85,47 @@ public partial class RewardStat public partial class ChallengePrerequisite { - [JsonProperty("completedChallengeIds")] - public List CompletedChallengeIds { get; set; } + [JsonProperty("stats")] + public List Stats { get; set; } [JsonProperty("items")] public List Items { get; set; } - [JsonProperty("stats")] - public List Stats { get; set; } + [JsonProperty("completedChallengeIds")] + public List CompletedChallengeIds { get; set; } } public partial class Reward { - [JsonProperty("items")] - public List Items { get; set; } - [JsonProperty("rewardId")] public string RewardId { get; set; } [JsonProperty("stats")] public List Stats { get; set; } + + [JsonProperty("items")] + public List Items { get; set; } } public partial class Item { - [JsonProperty("isActive")] - public bool IsActive { get; set; } - [JsonProperty("itemId")] public string ItemId { get; set; } [JsonProperty("quantity")] public long Quantity { get; set; } + + [JsonProperty("isActive")] + public bool IsActive { get; set; } } public partial class Progress { - [JsonProperty("objective")] - public ProgressObjective Objective { get; set; } - [JsonProperty("prerequisite")] public ProgressPrerequisite Prerequisite { get; set; } + + [JsonProperty("objective")] + public ProgressObjective Objective { get; set; } } public partial class ProgressObjective @@ -136,26 +136,26 @@ public partial class ProgressObjective public partial class PurpleStat { - [JsonProperty("currentValue")] - public double CurrentValue { get; set; } - [JsonProperty("statCode")] public string StatCode { get; set; } + [JsonProperty("currentValue")] + public long CurrentValue { get; set; } + [JsonProperty("targetValue")] public long TargetValue { get; set; } } public partial class ProgressPrerequisite { - [JsonProperty("completedChallengeIds")] - public List CompletedChallengeIds { get; set; } + [JsonProperty("stats")] + public List Stats { get; set; } [JsonProperty("items")] public List Items { get; set; } - [JsonProperty("stats")] - public List Stats { get; set; } + [JsonProperty("completedChallengeIds")] + public List CompletedChallengeIds { get; set; } } public partial class CompletedChallengeId @@ -167,18 +167,5 @@ public partial class CompletedChallengeId public bool IsCompleted { get; set; } } - public partial class Paging - { - [JsonProperty("first")] - public string First { get; set; } - - [JsonProperty("last")] - public string Last { get; set; } - - [JsonProperty("next")] - public string Next { get; set; } - [JsonProperty("previous")] - public string Previous { get; set; } - } } diff --git a/PayCheckServerLib/Jsons/DataPaging.cs b/PayCheckServerLib/Jsons/DataPaging.cs index 609c7b1..3e4fff2 100644 --- a/PayCheckServerLib/Jsons/DataPaging.cs +++ b/PayCheckServerLib/Jsons/DataPaging.cs @@ -10,4 +10,18 @@ public class DataPaging where T : class [JsonProperty("paging")] public Paging Paging { get; set; } } + public partial class Paging + { + [JsonProperty("first")] + public string First { get; set; } + + [JsonProperty("last")] + public string Last { get; set; } + + [JsonProperty("next")] + public string Next { get; set; } + + [JsonProperty("previous")] + public string Previous { get; set; } + } } diff --git a/PayCheckServerLib/Responses/Items.cs b/PayCheckServerLib/Responses/Items.cs index 49689af..03c4569 100644 --- a/PayCheckServerLib/Responses/Items.cs +++ b/PayCheckServerLib/Responses/Items.cs @@ -11,9 +11,10 @@ public static bool GetItemsByCriteria(HttpRequest _, PC3Server.PC3Session sessio { ResponseCreator creator = new(); var items = JsonConvert.DeserializeObject>(File.ReadAllText("./Files/Items.json")); + var timeMrFreeman = DateTime.UtcNow.ToString("o"); foreach (var item in items.Data) { - item.UpdatedAt = DateTime.UtcNow.ToString("o"); + item.UpdatedAt = timeMrFreeman; } creator.SetBody(JsonConvert.SerializeObject(items)); session.SendResponse(creator.GetResponse()); @@ -26,9 +27,10 @@ public static bool GetItemsByCriteriaWeaponPart(HttpRequest _, PC3Server.PC3Sess ResponseCreator creator = new(); var items = JsonConvert.DeserializeObject>(File.ReadAllText("./Files/Items.json")) ?? throw new Exception("Items is null!"); var finalitems = new List(); + var timeMrFreeman = DateTime.UtcNow.ToString("o"); foreach (var item in items.Data) { - item.UpdatedAt = DateTime.UtcNow.ToString("o"); + item.UpdatedAt = timeMrFreeman; if (item.Tags != null) { if (item.Tags.Contains("WeaponPart"))