Skip to content

Commit

Permalink
Json (C#) Update
Browse files Browse the repository at this point in the history
  • Loading branch information
SlejmUr committed Sep 19, 2023
1 parent b067564 commit d05c677
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 65 deletions.
113 changes: 50 additions & 63 deletions PayCheckServerLib/Jsons/Challenges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,74 @@ 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
{
[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<string> 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<RewardStat> Stats { get; set; }
public RewardStat[] Stats { get; set; }
}

public partial class RewardStat
Expand All @@ -85,47 +85,47 @@ public partial class RewardStat

public partial class ChallengePrerequisite
{
[JsonProperty("completedChallengeIds")]
public List<string> CompletedChallengeIds { get; set; }
[JsonProperty("stats")]
public List<object> Stats { get; set; }

[JsonProperty("items")]
public List<object> Items { get; set; }

[JsonProperty("stats")]
public List<object> Stats { get; set; }
[JsonProperty("completedChallengeIds")]
public List<string> CompletedChallengeIds { get; set; }
}

public partial class Reward
{
[JsonProperty("items")]
public List<Item> Items { get; set; }

[JsonProperty("rewardId")]
public string RewardId { get; set; }

[JsonProperty("stats")]
public List<RewardStat> Stats { get; set; }

[JsonProperty("items")]
public List<Item> 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
Expand All @@ -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<CompletedChallengeId> CompletedChallengeIds { get; set; }
[JsonProperty("stats")]
public List<object> Stats { get; set; }

[JsonProperty("items")]
public List<object> Items { get; set; }

[JsonProperty("stats")]
public List<object> Stats { get; set; }
[JsonProperty("completedChallengeIds")]
public List<CompletedChallengeId> CompletedChallengeIds { get; set; }
}

public partial class CompletedChallengeId
Expand All @@ -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; }
}
}
14 changes: 14 additions & 0 deletions PayCheckServerLib/Jsons/DataPaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,18 @@ public class DataPaging<T> 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; }
}
}
6 changes: 4 additions & 2 deletions PayCheckServerLib/Responses/Items.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ public static bool GetItemsByCriteria(HttpRequest _, PC3Server.PC3Session sessio
{
ResponseCreator creator = new();
var items = JsonConvert.DeserializeObject<DataPaging<ItemDefinitionJson>>(File.ReadAllText("./Files/Items.json"));
var timeMrFreeman = DateTime.UtcNow.ToString("o");
foreach (var item in items.Data)

Check warning on line 15 in PayCheckServerLib/Responses/Items.cs

View workflow job for this annotation

GitHub Actions / .NET on windows-latest (Release)

Dereference of a possibly null reference.
{
item.UpdatedAt = DateTime.UtcNow.ToString("o");
item.UpdatedAt = timeMrFreeman;
}
creator.SetBody(JsonConvert.SerializeObject(items));
session.SendResponse(creator.GetResponse());
Expand All @@ -26,9 +27,10 @@ public static bool GetItemsByCriteriaWeaponPart(HttpRequest _, PC3Server.PC3Sess
ResponseCreator creator = new();
var items = JsonConvert.DeserializeObject<DataPaging<ItemDefinitionJson>>(File.ReadAllText("./Files/Items.json")) ?? throw new Exception("Items is null!");
var finalitems = new List<ItemDefinitionJson>();
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"))
Expand Down

0 comments on commit d05c677

Please sign in to comment.