Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SetFilter key generation #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions PokemonTcgSdk.Standard.Tests/FilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void SetFilters_ReturnPopulatedDictionary()
// assemble
var dicObj = new SetFilterCollection<string, string>
{
{"Name", "Darkness Ablaze"}
{"name", "Darkness Ablaze"}
};

// act
Expand All @@ -31,7 +31,7 @@ public void SetFilters_ReturnMulitplePopulatedDictionary()
// assemble
var dicObj = new Dictionary<string, string>
{
{"Name", "Darkness Ablaze,Lost Origins"}
{"name", "Darkness Ablaze,Lost Origins"}
};

// act
Expand Down
10 changes: 10 additions & 0 deletions PokemonTcgSdk.Standard/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,14 @@ public static string HasSpaces(this string str)

return str;
}

public static string ToCamelCase(this string str)
{
if (!string.IsNullOrEmpty(str))
{
return char.ToLowerInvariant(str[0]) + str.Substring(1);
}

return str;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace PokemonTcgSdk.Standard.Features.FilterBuilder.Set;

using Infrastructure.HttpClients.Set;
using PokemonTcgSdk.Standard.Extensions;

// TODO: Legalities Filters
public static class SetFilter
Expand All @@ -24,7 +25,7 @@ public static SetFilterCollection<string, string> AddId(this SetFilterCollection
/// <param name="value">The name value to add</param>
public static SetFilterCollection<string, string> AddName(this SetFilterCollection<string, string> dictionary, string value)
{
return AddOrUpdate(dictionary, nameof(Set.Name), value);
return AddOrUpdate(dictionary, nameof(Set.Name).ToLower(), value);
}

/// <summary>
Expand All @@ -35,7 +36,7 @@ public static SetFilterCollection<string, string> AddName(this SetFilterCollecti
/// <param name="value">The name value to add</param>
public static SetFilterCollection<string, string> AddSeries(this SetFilterCollection<string, string> dictionary, string value)
{
return AddOrUpdate(dictionary, nameof(Set.Series), value);
return AddOrUpdate(dictionary, nameof(Set.Series).ToLower(), value);
}

/// <summary>
Expand All @@ -46,7 +47,7 @@ public static SetFilterCollection<string, string> AddSeries(this SetFilterCollec
/// <param name="value">The name value to add</param>
public static SetFilterCollection<string, string> AddPtcgoCode(this SetFilterCollection<string, string> dictionary, string value)
{
return AddOrUpdate(dictionary, nameof(Set.PtcgoCode), value);
return AddOrUpdate(dictionary, nameof(Set.PtcgoCode).ToCamelCase(), value);
}

private static SetFilterCollection<string, string> AddOrUpdate(SetFilterCollection<string, string> dictionary, string key, string value)
Expand Down