Skip to content

Commit

Permalink
Document the used parameters for the SSB classifications provider (#15)
Browse files Browse the repository at this point in the history
Co-authored-by: Ronny Birkeli <[email protected]>
  • Loading branch information
RonnyB71 and Ronny Birkeli authored Oct 19, 2023
1 parent 0f67a8b commit b1bd7a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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");
}
}

0 comments on commit b1bd7a0

Please sign in to comment.