Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SnipeSharp/Endpoints/Models/StatusLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public string Type
set
{
// TODO: Move this logic somewhere else
string[] validTypes = { "deployable", "pending", "archived" };
string[] validTypes = {"undeployable", "deployable", "pending", "archived" };
if (validTypes.Contains(value.ToLower()))
{
_type = value;
Expand Down
18 changes: 15 additions & 3 deletions SnipeSharp/Endpoints/QueryParameterBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ public class QueryParameterBuilder : IQueryParameterBuilder
public Dictionary<string, string> GetParameters(object item)
{
var values = new Dictionary<string, string>();


if (item == null)
{
return values;
}

foreach (var property in item.GetType().GetProperties())
{
var nameAttribute = property.GetCustomAttribute<NameAttribute>();
Expand All @@ -26,10 +27,11 @@ public Dictionary<string, string> GetParameters(object item)
{
continue;
}

var propValue = property.GetValue(item)?.ToString();

var requestAttribute = nameAttribute as RequestHeaderAttribute;

// Abort in case of missing required headers.
if (string.IsNullOrEmpty(propValue) && requestAttribute?.IsRequired == true)
{
Expand All @@ -41,12 +43,22 @@ public Dictionary<string, string> GetParameters(object item)
{
continue;
}

string headerName = nameAttribute.Name.Replace("\"", "");

values.Add(headerName, propValue);
}


// Add foreach loop to run with .Replace("\"", "");
if (item.GetType() == typeof(SnipeSharp.Endpoints.Models.Asset))
{
if (item.GetType().GetProperty("CustomFields") != null) {
Dictionary<string, string> customFields = item.GetType().GetProperty("CustomFields").GetValue(item) as Dictionary<string, string>;
values = values.Concat(customFields).ToDictionary(e => e.Key, e => e.Value);
}
}

return values;
}
}
Expand Down