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

Document the used parameters for the SSB classifications provider #15

Merged
merged 3 commits into from
Oct 19, 2023
Merged
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
19 changes: 19 additions & 0 deletions src/Altinn.Codelists/SSB/ClassificationCodelistProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,25 @@ public async Task<AppOptions> GetAppOptionsAsync(string language, Dictionary<str
AppOptions appOptions = GetAppOptions(classificationCode, parentCode);
appOptions.Parameters = new Dictionary<string, string>(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<string> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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");
}
}