From b1bd7a059d9e160bc591d9df446ce1d2ad20d7c5 Mon Sep 17 00:00:00 2001 From: Ronny Birkeli Date: Thu, 19 Oct 2023 06:56:26 +0200 Subject: [PATCH] Document the used parameters for the SSB classifications provider (#15) Co-authored-by: Ronny Birkeli --- .../SSB/ClassificationCodelistProvider.cs | 19 +++++++++++++++++++ .../IndustryGroupingCodelistProviderTests.cs | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/Altinn.Codelists/SSB/ClassificationCodelistProvider.cs b/src/Altinn.Codelists/SSB/ClassificationCodelistProvider.cs index 9fdd918..35f3547 100644 --- a/src/Altinn.Codelists/SSB/ClassificationCodelistProvider.cs +++ b/src/Altinn.Codelists/SSB/ClassificationCodelistProvider.cs @@ -70,6 +70,25 @@ public async Task GetAppOptionsAsync(string language, Dictionary(mergedKeyValuePairs); + // Parameters used added to Parameters collection in AppOptions for reference and documentation purposes. + // Add well known parameters first. + appOptions.Parameters.TryAdd("id", _classificationId.ToString()); + appOptions.Parameters.TryAdd("variant", variant); + appOptions.Parameters.TryAdd("date", dateOnly.ToString()); + appOptions.Parameters.TryAdd("language", language); + appOptions.Parameters.TryAdd("level", level); + appOptions.Parameters.TryAdd("parentCode", parentCode); + + // Add any other parameters. + List knownKeys = new () { "id", "variant", "date", "language", "level", "parentCode" }; + foreach (var keyValuePair in mergedKeyValuePairs) + { + if (!knownKeys.Contains(keyValuePair.Key)) + { + appOptions.Parameters.TryAdd(keyValuePair.Key, keyValuePair.Value); + } + } + return appOptions; } diff --git a/test/Altinn.Codelists.Tests/SSB/IndustryGroupingCodelistProviderTests.cs b/test/Altinn.Codelists.Tests/SSB/IndustryGroupingCodelistProviderTests.cs index 1cf1b77..192ae99 100644 --- a/test/Altinn.Codelists.Tests/SSB/IndustryGroupingCodelistProviderTests.cs +++ b/test/Altinn.Codelists.Tests/SSB/IndustryGroupingCodelistProviderTests.cs @@ -32,6 +32,7 @@ public async Task GetAppOptionsAsync_FirstLevelOnly_ShouldReturnListOfCodes() appOptions.Options.Should().HaveCount(21); appOptions.Options.First(x => x.Value == "A").Label.Should().Be("Jordbruk, skogbruk og fiske"); + appOptions.Parameters.First(x => x.Key == "level").Value.Should().Be("1"); } [Fact] @@ -44,5 +45,6 @@ public async Task GetAppOptionsAsync_DefaultFirstLevel_ShouldReturnListOfCodes() appOptions.Options.Should().HaveCount(21); appOptions.Options.First(x => x.Value == "A").Label.Should().Be("Jordbruk, skogbruk og fiske"); + appOptions.Parameters.First(x => x.Key == "language").Value.Should().Be("nb"); } }