From c613309c8e99dff885a7afdbb4832a299306a428 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 27 Apr 2024 11:42:32 -0400 Subject: [PATCH] fixes SetFilter key generation --- PokemonTcgSdk.Standard.Tests/FilterTests.cs | 4 ++-- PokemonTcgSdk.Standard/Extensions/StringExtensions.cs | 10 ++++++++++ .../Features/FilterBuilder/Set/SetFilter.cs | 7 ++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/PokemonTcgSdk.Standard.Tests/FilterTests.cs b/PokemonTcgSdk.Standard.Tests/FilterTests.cs index 6f62855..b3b18f2 100644 --- a/PokemonTcgSdk.Standard.Tests/FilterTests.cs +++ b/PokemonTcgSdk.Standard.Tests/FilterTests.cs @@ -14,7 +14,7 @@ public void SetFilters_ReturnPopulatedDictionary() // assemble var dicObj = new SetFilterCollection { - {"Name", "Darkness Ablaze"} + {"name", "Darkness Ablaze"} }; // act @@ -31,7 +31,7 @@ public void SetFilters_ReturnMulitplePopulatedDictionary() // assemble var dicObj = new Dictionary { - {"Name", "Darkness Ablaze,Lost Origins"} + {"name", "Darkness Ablaze,Lost Origins"} }; // act diff --git a/PokemonTcgSdk.Standard/Extensions/StringExtensions.cs b/PokemonTcgSdk.Standard/Extensions/StringExtensions.cs index d11ece0..ccc8312 100644 --- a/PokemonTcgSdk.Standard/Extensions/StringExtensions.cs +++ b/PokemonTcgSdk.Standard/Extensions/StringExtensions.cs @@ -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; + } } \ No newline at end of file diff --git a/PokemonTcgSdk.Standard/Features/FilterBuilder/Set/SetFilter.cs b/PokemonTcgSdk.Standard/Features/FilterBuilder/Set/SetFilter.cs index d2b8661..65fe10c 100644 --- a/PokemonTcgSdk.Standard/Features/FilterBuilder/Set/SetFilter.cs +++ b/PokemonTcgSdk.Standard/Features/FilterBuilder/Set/SetFilter.cs @@ -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 @@ -24,7 +25,7 @@ public static SetFilterCollection AddId(this SetFilterCollection /// The name value to add public static SetFilterCollection AddName(this SetFilterCollection dictionary, string value) { - return AddOrUpdate(dictionary, nameof(Set.Name), value); + return AddOrUpdate(dictionary, nameof(Set.Name).ToLower(), value); } /// @@ -35,7 +36,7 @@ public static SetFilterCollection AddName(this SetFilterCollecti /// The name value to add public static SetFilterCollection AddSeries(this SetFilterCollection dictionary, string value) { - return AddOrUpdate(dictionary, nameof(Set.Series), value); + return AddOrUpdate(dictionary, nameof(Set.Series).ToLower(), value); } /// @@ -46,7 +47,7 @@ public static SetFilterCollection AddSeries(this SetFilterCollec /// The name value to add public static SetFilterCollection AddPtcgoCode(this SetFilterCollection dictionary, string value) { - return AddOrUpdate(dictionary, nameof(Set.PtcgoCode), value); + return AddOrUpdate(dictionary, nameof(Set.PtcgoCode).ToCamelCase(), value); } private static SetFilterCollection AddOrUpdate(SetFilterCollection dictionary, string key, string value)