Skip to content

Commit

Permalink
Updates to capture the value correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
samsmithnz committed Nov 12, 2023
1 parent 5be21d2 commit 37d27d4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public async Task<int> UpdateSummaryItemNuGetPackageStats(NuGetPayload nugetPayl
string? repo = nugetPayload?.Repo;
string? owner = nugetPayload?.Owner;
string? user = nugetPayload?.User;
string? jsonPayload = nugetPayload?.JsonPayload;
//There is some weirdness when the json is embedded in this object and then the object is serialized a second time - it returns an array of strings.
string? jsonPayload = nugetPayload?.JsonPayloadString;
string? payloadType = nugetPayload?.PayloadType;

if (repo == null || owner == null || user == null || jsonPayload == null || payloadType == null)
Expand Down
30 changes: 27 additions & 3 deletions src/RepoGovernance.Service/Models/NuGetPayload.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace RepoGovernance.Service.Models
using System.Text;

namespace RepoGovernance.Service.Models
{
public class NuGetPayload
{
public NuGetPayload(string user, string owner, string repo, string jsonPayload, string payloadType)
public NuGetPayload(string user, string owner, string repo, string[] jsonPayload, string payloadType)
{
User = user;
Owner = owner;
Expand All @@ -13,7 +15,29 @@ public NuGetPayload(string user, string owner, string repo, string jsonPayload,
public string? User { get; set; }
public string? Owner { get; set; }
public string? Repo { get; set; }
public string? JsonPayload { get; set; }
//There is some weirdness when the json is embedded in this object and then the object is serialized a second time - it returns an array of strings.
public string[]? JsonPayload { get; set; }
public string JsonPayloadString
{
get
{
if (JsonPayload == null)
{
return string.Empty;
}
return UsingLoopStringBuilder(JsonPayload);
}
}
public string? PayloadType { get; set; }

private string UsingLoopStringBuilder(string[] array)
{
StringBuilder result = new();
foreach (string item in array)
{
result.Append(item);
}
return result.ToString();
}
}
}

0 comments on commit 37d27d4

Please sign in to comment.