diff --git a/.editorconfig b/.editorconfig
index 06296de..2242bb5 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -37,4 +37,65 @@ csharp_style_pattern_matching_over_is_with_cast_check = true
csharp_style_pattern_matching_over_as_with_null_check = true
csharp_style_inlined_variable_declaration = true
csharp_style_var_for_built_in_types = true
-csharp_style_var_when_type_is_apparent = true
\ No newline at end of file
+csharp_style_var_when_type_is_apparent = true
+csharp_style_var_elsewhere = true
+
+# Namespaces & usings
+csharp_style_namespace_declarations = file_scoped
+csharp_using_directive_placement = outside_namespace
+
+# Qualification & accessibility
+dotnet_style_qualification_for_field = false
+dotnet_style_qualification_for_property = false
+dotnet_style_qualification_for_method = false
+dotnet_style_qualification_for_event = false
+dotnet_style_require_accessibility_modifiers = for_non_interface_members
+dotnet_style_readonly_field = true
+
+# Modern expressions & initializers
+dotnet_style_coalesce_expression = true
+dotnet_style_null_propagation = true
+dotnet_style_object_initializer = true
+dotnet_style_collection_initializer = true
+dotnet_style_prefer_auto_properties = true
+csharp_prefer_simple_using_statement = true
+csharp_style_prefer_collection_expression = true
+
+# Naming: private instance fields -> _camelCase
+dotnet_naming_rule.private_instance_fields.symbols = private_instance_fields
+dotnet_naming_rule.private_instance_fields.style = underscore_camel_case
+dotnet_naming_rule.private_instance_fields.severity = suggestion
+dotnet_naming_symbols.private_instance_fields.applicable_kinds = field
+dotnet_naming_symbols.private_instance_fields.applicable_accessibilities = private
+
+# Naming: private const fields -> PascalCase
+dotnet_naming_rule.private_const_fields.symbols = private_const_fields
+dotnet_naming_rule.private_const_fields.style = pascal_case
+dotnet_naming_rule.private_const_fields.severity = suggestion
+dotnet_naming_symbols.private_const_fields.applicable_kinds = field
+dotnet_naming_symbols.private_const_fields.applicable_accessibilities = private
+dotnet_naming_symbols.private_const_fields.required_modifiers = const
+
+# Naming: private static readonly fields -> PascalCase
+dotnet_naming_rule.private_static_readonly_fields.symbols = private_static_readonly_fields
+dotnet_naming_rule.private_static_readonly_fields.style = pascal_case
+dotnet_naming_rule.private_static_readonly_fields.severity = suggestion
+dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field
+dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private
+dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = static, readonly
+
+# Naming: interfaces -> I-prefixed PascalCase
+dotnet_naming_rule.interfaces.symbols = interfaces
+dotnet_naming_rule.interfaces.style = i_prefix_pascal_case
+dotnet_naming_rule.interfaces.severity = suggestion
+dotnet_naming_symbols.interfaces.applicable_kinds = interface
+dotnet_naming_style.i_prefix_pascal_case.capitalization = pascal_case
+dotnet_naming_style.i_prefix_pascal_case.required_prefix = I
+
+dotnet_naming_style.underscore_camel_case.capitalization = camel_case
+dotnet_naming_style.underscore_camel_case.required_prefix = _
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+
+# Sample top-level programs require block-scoped namespaces.
+[samples/**/Program.cs]
+csharp_style_namespace_declarations = block_scoped
\ No newline at end of file
diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index 74f881a..419c0d5 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -27,12 +27,14 @@ jobs:
- name: Setup .NET 10
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6
with:
- dotnet-version: '10.0.x'
+ global-json-file: global.json
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Restore
- run: dotnet restore DotBahn.slnx --locked-mode
+ run: |
+ dotnet restore DotBahn.slnx --force-evaluate
+ git diff --exit-code -- '**/packages.lock.json'
- name: Format check
run: dotnet format DotBahn.slnx --verify-no-changes --verbosity diagnostic
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index f4a1432..4af76a9 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -33,12 +33,14 @@ jobs:
- name: Setup .NET 10
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6
with:
- dotnet-version: '10.0.x'
+ global-json-file: global.json
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Restore
- run: dotnet restore DotBahn.slnx --locked-mode
+ run: |
+ dotnet restore DotBahn.slnx --force-evaluate
+ git diff --exit-code -- '**/packages.lock.json'
- name: Pack NuGet
run: dotnet pack DotBahn.slnx --no-restore --configuration Release --output ./nupkgs
@@ -85,13 +87,14 @@ jobs:
- name: Setup .NET 10
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6
with:
- dotnet-version: '10.0.x'
+ global-json-file: global.json
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Build library (produces XML doc files)
run: |
- dotnet restore DotBahn.slnx --locked-mode
+ dotnet restore DotBahn.slnx --force-evaluate
+ git diff --exit-code -- '**/packages.lock.json'
dotnet build DotBahn.slnx --no-restore --configuration Release
- name: Build docs
@@ -169,12 +172,13 @@ jobs:
- name: Setup .NET 10
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6
with:
- dotnet-version: '10.0.x'
+ global-json-file: global.json
- name: Generate dependency SBOM
run: |
dotnet tool restore
- dotnet restore DotBahn.slnx --locked-mode
+ dotnet restore DotBahn.slnx --force-evaluate
+ git diff --exit-code -- '**/packages.lock.json'
dotnet cyclonedx DotBahn.slnx -o ./build/sbom -F Json
- name: Download packages
@@ -184,7 +188,7 @@ jobs:
path: ./nupkgs
- name: Create GitHub Release
- uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3
+ uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
diff --git a/Directory.Build.props b/Directory.Build.props
index 6034e00..1c1b195 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -5,11 +5,11 @@
latest
enable
true
+ true
enable
true
true
true
- true
true
@@ -36,7 +36,7 @@
https://github.com/rlvelte/dotbahn
https://github.com/rlvelte/dotbahn
git
- db;bahn;client;deutschebahn;deutsche-bahn;api;rest;http;dotnet;net10;stations;facilities;timetables;client-library
+ db;bahn;client;deutschebahn;deutsche-bahn;api;rest;http;dotnet;net10;stations;facilities;timetables;boards;ai
Copyright (c) Robin L. Velte 2026
icon.png
README.md
@@ -58,16 +58,8 @@
-
-
-
- all
- runtime; build; native; contentfiles; analyzers
-
-
-
-
-
+
+
Exe
false
false
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 8a3f20c..067cd0b 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -3,21 +3,36 @@
true
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DotBahn.slnx b/DotBahn.slnx
index 5e9b14e..447f9d4 100644
--- a/DotBahn.slnx
+++ b/DotBahn.slnx
@@ -5,6 +5,11 @@
+
+
+
+
+
@@ -15,23 +20,26 @@
+
+
+
+
-
-
-
-
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/Makefile b/Makefile
index 7421061..6253542 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,8 @@ NUGET_PACKAGES_DIR ?=
# Out
RESULTS_DIR := ./build/tests
+BENCH_DIR := ./build/benchmarks
+MUTATE_DIR := ./build/mutations
NUPKG_DIR := ./build/nupkgs
PUBLISH_DIR := ./build/publish
RPM_DIR := ./build/rpm
@@ -29,20 +31,24 @@ export RPM_DIR
# Main
.DEFAULT_GOAL := build
-.PHONY: format restore sbom build test coverage pack publish rpm mutate
+.PHONY: format restore vulcheck sbom build test mutate pack publish rpm
format:
- dotnet format whitespace $(SOLUTION) \
- --verbosity diagnostic
dotnet format $(SOLUTION) \
--verbosity diagnostic
restore:
dotnet restore $(SOLUTION) \
$(if $(NUGET_PACKAGES_DIR),--packages $(NUGET_PACKAGES_DIR),) \
+ --force-evaluate \
--verbosity minimal
-sbom: restore
+vulcheck:
+ dotnet list $(SOLUTION) package \
+ --vulnerable \
+ --include-transitive
+
+sbom:
dotnet cyclonedx $(SOLUTION) \
-o $(SBOM_DIR) \
-F Json
@@ -54,47 +60,40 @@ build: restore
test: build
dotnet test --solution $(SOLUTION) \
- --no-build \
--configuration $(CONFIGURATION) \
--results-directory $(RESULTS_DIR) \
- -- --coverage --coverage-output-format cobertura --ignore-exit-code 8
+ --no-build \
+ -- --coverage --coverage-output-format cobertura
-coverage: test
- dotnet reportgenerator \
- -reports:$(RESULTS_DIR)/**/*.cobertura.xml \
- -targetdir:$(RESULTS_DIR)/coverage \
- -reporttypes:Html \
- -verbosity:Warning \
- -filefilters:-**/*.g.cs
- @echo "file://$(CURDIR)/$(RESULTS_DIR)/coverage/index.html"
+mutate: export MinVerVersionOverride = 1.0.0
+mutate: build
+ mkdir -p $(MUTATE_DIR)
+ dotnet stryker \
+ --output $(MUTATE_DIR)
-pack:
+pack: build
dotnet pack $(SOLUTION) \
--configuration $(CONFIGURATION) \
--output $(NUPKG_DIR) \
+ --no-build \
--verbosity minimal
publish:
$(RUN) scripts/publish$(EXT)
-rpm: publish
+rpm:
ifeq ($(OS),Windows_NT)
- @echo "RPM packaging requires 'rpmbuild'." >&2
+ @echo "Windows does not support 'rpmbuild'." >&2
else
$(RUN) scripts/rpm$(EXT)
endif
-# Documentation
-docs-build: build
- dotnet docfx docs/docfx.json
-
-docs-serve: build
- dotnet docfx docs/docfx.json --serve
-
-# Utility
clean:
+ dotnet clean $(SOLUTION) \
+ --configuration $(CONFIGURATION) \
+ --verbosity minimal
ifeq ($(OS),Windows_NT)
- pwsh -NoProfile -Command "Remove-Item -Recurse -Force -ErrorAction SilentlyContinue build, StrykerOutput, docs/_site, docs/api"
+ powershell -NoProfile -Command "Remove-Item -Recurse -Force -ErrorAction SilentlyContinue build, docs/_site, docs/api"
else
- rm -rf build StrykerOutput docs/_site docs/api
-endif
\ No newline at end of file
+ rm -rf build docs/_site docs/api
+endif
diff --git a/README.md b/README.md
index e8f4661..8048097 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,7 @@


+



@@ -11,27 +12,28 @@
DotBahn is a collection of unofficial .NET client packages for accessing Deutsche Bahn (DB) APIs. Query train schedules, station details, and facility status directly in your application. It also provides convenience features like timetable merging, fluent queries and some additional properties. All libraries are AOT compatible and trimmable.
-> [!IMPORTANT]
-> If you are just here to use the departure monitor as a standalone tool on your system, there is also a packaged RPM on the [Open Build Service](https://build.opensuse.org/package/show/home:rvelte/dbpeek) for that.
-
| API | Description |
|------------------------|-------------|
| **Stations (StaDa)** | Station data including parking, accessibility, and opening hours. |
| **Facilities (FaSta)** | Real-time operational status of elevators and escalators at stations. |
-| **Timetables** | Scheduled departures and arrivals with real-time delay and platform change information. |
+| **Boards (OpenBoards)** | Scheduled departures and arrivals with real-time delay and platform change information. |
+
+> [!CAUTION]
+> **Deutsche Bahn is shutting down the Timetables API.** It entered parallel operation in November 2026 and is scheduled for shutdown around mid-2027. There is a replacement package with `DotBahn.Boards` that uses the new OpenBoards API.
+
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [Authorization](#authorization)
- [Samples](#samples)
-- [API Reference](https://rlvelte.github.io/dotbahn/index.html)
+- [Experimental & AI](#experimental--ai)
## Install
Install the packages you need from [NuGet](https://www.nuget.org/) or [GitHub Packages](https://docs.github.com/de/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry):
```bash
-dotnet add package DotBahn.Timetables
+dotnet add package DotBahn.Boards
dotnet add package DotBahn.Stations
dotnet add package DotBahn.Facilities
@@ -42,7 +44,6 @@ dotnet add package DotBahn.Telemetry
> [!NOTE]
> All client packages depend on **DotBahn.Common**, which provides cross-cutting abstractions such as authorization, base client infrastructure, and shared models. It is installed automatically as a transitive dependency.
-
## Usage
### Dependency Injection (Recommended)
All packages integrate seamlessly with `IServiceCollection`. Each client comes with a default endpoint, override only for custom proxies:
@@ -50,7 +51,7 @@ All packages integrate seamlessly with `IServiceCollection`. Each client comes w
```csharp
// Register clients
services.AddDotBahnStations();
-services.AddDotBahnTimetables();
+services.AddDotBahnBoards();
services.AddDotBahnFacilities();
// Configure authorization (required for API access)
@@ -101,22 +102,27 @@ A Deutsche Bahn API key is required. Register and obtain your credentials at the
> These packages only consume the credentials you provide for API authentication. They do not create, register, or manage credentials on your behalf.
## Samples
-Both samples take credentials via `--client` / `--secret` or, more conveniently, the `DOTBAHN_CLIENT` / `DOTBAHN_SECRET` environment variables.
+All samples take DB credentials via `--client` / `--secret` or, more conveniently, the `DOTBAHN_CLIENT` / `DOTBAHN_SECRET` environment variables.
### TimetablePeek (`dbpeek`)
Terminal departures board for DB timetable services. Shows customer-facing train names (service line or trip number), planned and actual times, delays, platforms, destinations, and via stops. Optional category filter, upstream time window and machine-readable JSON output.
-```bash
-dotnet run --project samples/DotBahn.Samples.TimetablePeek -- [options]
-```
+> [!NOTE]
+> If you are just here to use the departure monitor as a standalone tool on your system, there is also a packaged RPM on the [Open Build Service](https://build.opensuse.org/package/show/home:rvelte/dbpeek) for that.
+
### StationBrowser (`dbstation`)
Interactive terminal application for exploring DB station details. Search by name and navigate results with arrow keys. Shows station category, identifiers (EVA/RIL100), address, coordinates, regional area, available services, and real-time elevator/escalator status.
-```bash
-dotnet run --project samples/DotBahn.Samples.StationBrowser -- [options]
-```
-
+
+## Experimental & AI
+
+The package `DotBahn.Ai` is an early exploration of integrated AI tool support. It is experimental and has no current development priority. If you have experience with .NET AI integrations, tool calling or related designs, feel free to contribute.
+
+However, there is a minimal interactive chatbot sample that uses a local Ollama model with these tools. It defaults to `qwen3:4b` at `http://localhost:11434/v1`; override with `--model` and `--endpoint`.
+
+
+
diff --git a/docs/docfx.json b/docs/docfx.json
index 15c3a2e..f8f5ccb 100644
--- a/docs/docfx.json
+++ b/docs/docfx.json
@@ -7,6 +7,7 @@
"source/DotBahn.Facilities/bin/Release/net10.0/DotBahn.Facilities.dll",
"source/DotBahn.Stations/bin/Release/net10.0/DotBahn.Stations.dll",
"source/DotBahn.Timetables/bin/Release/net10.0/DotBahn.Timetables.dll",
+ "source/DotBahn.Boards/bin/Release/net10.0/DotBahn.Boards.dll",
"source/DotBahn.Common/bin/Release/net10.0/DotBahn.Common.dll",
"source/DotBahn.Telemetry/bin/Release/net10.0/DotBahn.Telemetry.dll"
],
diff --git a/dotnet-tools.json b/dotnet-tools.json
index f1ed0aa..b9c5349 100644
--- a/dotnet-tools.json
+++ b/dotnet-tools.json
@@ -10,21 +10,21 @@
"rollForward": false
},
"dotnet-reportgenerator-globaltool": {
- "version": "5.5.12",
+ "version": "5.6.1",
"commands": [
"reportgenerator"
],
"rollForward": false
},
"dotnet-stryker": {
- "version": "5.0.0",
+ "version": "5.1.0",
"commands": [
"dotnet-stryker"
],
"rollForward": false
},
"cyclonedx": {
- "version": "6.3.1",
+ "version": "6.3.2",
"commands": [
"dotnet-CycloneDX"
],
diff --git a/global.json b/global.json
index 3140116..1682134 100644
--- a/global.json
+++ b/global.json
@@ -1,4 +1,8 @@
{
+ "sdk": {
+ "version": "10.0.404",
+ "rollForward": "disable"
+ },
"test": {
"runner": "Microsoft.Testing.Platform"
}
diff --git a/samples/DotBahn.Samples.Chatbot/DotBahn.Samples.Chatbot.csproj b/samples/DotBahn.Samples.Chatbot/DotBahn.Samples.Chatbot.csproj
new file mode 100644
index 0000000..d57d6cf
--- /dev/null
+++ b/samples/DotBahn.Samples.Chatbot/DotBahn.Samples.Chatbot.csproj
@@ -0,0 +1,21 @@
+
+
+
+ Exe
+ dbchat
+ false
+ $(NoWarn);CS1591
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/DotBahn.Samples.Chatbot/Program.cs b/samples/DotBahn.Samples.Chatbot/Program.cs
new file mode 100644
index 0000000..1e24a4f
--- /dev/null
+++ b/samples/DotBahn.Samples.Chatbot/Program.cs
@@ -0,0 +1,157 @@
+using System.ClientModel;
+using System.CommandLine;
+using DotBahn.Ai;
+using DotBahn.Boards;
+using DotBahn.Common;
+using DotBahn.Facilities;
+using DotBahn.Samples.Chatbot;
+using DotBahn.Stations;
+using Microsoft.Extensions.AI;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using OpenAI;
+using Spectre.Console;
+
+return await DbChatCli.BuildRootCommand().Parse(args).InvokeAsync();
+
+namespace DotBahn.Samples.Chatbot {
+ internal static class DbChatCli {
+ private const string SystemPrompt =
+ "You are a helpful Deutsche Bahn assistant. Use the provided tools to answer questions " +
+ "about stations, departures, arrivals, and facility status. Keep answers concise. " +
+ "If a tool returns a structured error, explain the problem and ask for corrected input.";
+
+ private static readonly Option ClientIdOption = new("--client") {
+ Description = "DB API client id; falls back to the DOTBAHN_CLIENT environment variable"
+ };
+
+ private static readonly Option SecretOption = new("--secret") {
+ Description = "DB API secret; falls back to the DOTBAHN_SECRET environment variable"
+ };
+
+ private static readonly Option ApiKeyOption = new("--api-key") {
+ Description = "Model API key; defaults to OPENAI_API_KEY or 'ollama' for local models",
+ DefaultValueFactory = _ => Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? "ollama"
+ };
+
+ private static readonly Option EndpointOption = new("--endpoint", "-e") {
+ Description = "OpenAI-compatible endpoint",
+ DefaultValueFactory = _ => Environment.GetEnvironmentVariable("DOTBAHN_AI_ENDPOINT") ?? "http://localhost:11434/v1"
+ };
+
+ private static readonly Option ModelOption = new("--model", "-m") {
+ Description = "Model name; defaults to DOTBAHN_AI_MODEL or 'qwen3:4b'",
+ DefaultValueFactory = _ => Environment.GetEnvironmentVariable("DOTBAHN_AI_MODEL") ?? "qwen3:4b"
+ };
+
+ internal static RootCommand BuildRootCommand() {
+ var rootCommand = new RootCommand("Minimal local chatbot for Deutsche Bahn data") {
+ ClientIdOption,
+ SecretOption,
+ ApiKeyOption,
+ EndpointOption,
+ ModelOption
+ };
+
+ EndpointOption.Validators.Add(result => {
+ var endpoint = result.GetValue(EndpointOption);
+ if (!Uri.TryCreate(endpoint, UriKind.Absolute, out _)) {
+ result.AddError("--endpoint must be an absolute URI.");
+ }
+ });
+
+ ModelOption.Validators.Add(result => {
+ if (string.IsNullOrWhiteSpace(result.GetValue(ModelOption))) {
+ result.AddError("--model must not be empty.");
+ }
+ });
+
+ rootCommand.SetAction(async (parseResult, ct) => await RunAsync(
+ parseResult.GetValue(ClientIdOption),
+ parseResult.GetValue(SecretOption),
+ parseResult.GetValue(ApiKeyOption)!,
+ parseResult.GetValue(EndpointOption)!,
+ parseResult.GetValue(ModelOption)!, ct));
+
+ return rootCommand;
+ }
+
+ private static async Task RunAsync(string? clientId, string? secret, string apiKey, string endpoint, string model, CancellationToken cancellationToken) {
+ if (!ResolveCredentials(clientId, secret, out var resolvedClientId, out var resolvedSecret)) {
+ AnsiConsole.MarkupLine("[red]Usage:[/] provide --client/--secret, or set DOTBAHN_CLIENT / DOTBAHN_SECRET via env or CLI args");
+ return 1;
+ }
+
+ var services = new ServiceCollection();
+ services.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Warning));
+ services.AddDotBahnAuthorization(opt => {
+ opt.ClientId = resolvedClientId;
+ opt.ApiKey = resolvedSecret;
+ });
+
+ services.AddDotBahnStations();
+ services.AddDotBahnBoards();
+ services.AddDotBahnFacilities();
+ services.AddDotBahnAiTools();
+
+ await using var provider = services.BuildServiceProvider();
+
+ var openAiOptions = new OpenAIClientOptions {
+ Endpoint = new Uri(endpoint)
+ };
+ var openAiClient = new OpenAIClient(new ApiKeyCredential(apiKey), openAiOptions);
+
+ IChatClient inner = openAiClient.GetChatClient(model).AsIChatClient();
+ IChatClient chat = new ChatClientBuilder(inner).UseDotBahnAiTools(provider.GetService()).Build();
+
+ var chatOptions = new ChatOptions {
+ Tools = provider.GetRequiredService>()
+ .Cast()
+ .ToList()
+ };
+
+ var history = new List {
+ new(ChatRole.System, SystemPrompt)
+ };
+
+ AnsiConsole.MarkupLine($"[grey]Model:[/] {Markup.Escape(model)}");
+ while (true) {
+ var input = AnsiConsole.Ask("[blue]You[/]");
+ if (string.Equals(input, "exit", StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(input, "quit", StringComparison.OrdinalIgnoreCase)) {
+ return 0;
+ }
+
+ history.Add(new ChatMessage(ChatRole.User, input));
+ AnsiConsole.MarkupLine("[grey]Thinking...[/]");
+
+ ChatResponse response;
+ try {
+ response = await chat.GetResponseAsync(history, chatOptions, cancellationToken);
+ } catch (OperationCanceledException) {
+ return 130;
+ } catch (Exception ex) when (IsLocalEndpoint(endpoint)) {
+ AnsiConsole.MarkupLine($"[red]Local model unavailable:[/] {Markup.Escape(ex.Message)}");
+ AnsiConsole.MarkupLine($"[grey]Start Ollama with 'ollama serve' and pull the model with 'ollama pull {Markup.Escape(model)}'.[/]");
+ return 1;
+ } catch (Exception ex) {
+ AnsiConsole.MarkupLine($"[red]Error:[/] {Markup.Escape(ex.Message)}");
+ return 1;
+ }
+
+ history.AddRange(response.Messages);
+ AnsiConsole.MarkupLine($"[green]Assistant[/]: {Markup.Escape(response.Text)}");
+ }
+ }
+
+ private static bool IsLocalEndpoint(string endpoint) =>
+ endpoint.Contains("localhost", StringComparison.OrdinalIgnoreCase) ||
+ endpoint.Contains("127.0.0.1", StringComparison.OrdinalIgnoreCase);
+
+ private static bool ResolveCredentials(string? clientId, string? secret, out string resolvedClientId, out string resolvedSecret) {
+ resolvedClientId = clientId ?? Environment.GetEnvironmentVariable("DOTBAHN_CLIENT") ?? string.Empty;
+ resolvedSecret = secret ?? Environment.GetEnvironmentVariable("DOTBAHN_SECRET") ?? string.Empty;
+ return !string.IsNullOrEmpty(resolvedClientId) && !string.IsNullOrEmpty(resolvedSecret);
+ }
+ }
+}
diff --git a/samples/DotBahn.Samples.Chatbot/packages.lock.json b/samples/DotBahn.Samples.Chatbot/packages.lock.json
new file mode 100644
index 0000000..007333c
--- /dev/null
+++ b/samples/DotBahn.Samples.Chatbot/packages.lock.json
@@ -0,0 +1,437 @@
+{
+ "version": 2,
+ "dependencies": {
+ "net10.0": {
+ "Microsoft.Extensions.AI.OpenAI": {
+ "type": "Direct",
+ "requested": "[11.0.1, )",
+ "resolved": "11.0.1",
+ "contentHash": "BPyxzh96v26MfAM61x/5hj1Gt3FbUpqqnRFuKa9j+FIPewNq4qL4zmJzUJv6csyv8nMNX8tdZBKba3H3XK/OBg==",
+ "dependencies": {
+ "Microsoft.Extensions.AI.Abstractions": "11.0.1",
+ "OpenAI": "2.15.0"
+ }
+ },
+ "MinVer": {
+ "type": "Direct",
+ "requested": "[8.0.0, )",
+ "resolved": "8.0.0",
+ "contentHash": "AJy/KVjXgUbgjf6HiI8wAk4DSSq0SCmvXQF8aU6IB+pnIQq+YJvofvMczug2hqO8yEvnQY557ryew66KPpyCsA=="
+ },
+ "Spectre.Console": {
+ "type": "Direct",
+ "requested": "[0.57.2, )",
+ "resolved": "0.57.2",
+ "contentHash": "wzsB+P9i6F9G+cFOJxRotCiQWNSzZVAMxi8YMiHlGXXU1JLMXGp7zSSqBMmROZS2bzpK5jk+Saa7Evp8HwqhKg==",
+ "dependencies": {
+ "Spectre.Console.Ansi": "0.57.2"
+ }
+ },
+ "System.CommandLine": {
+ "type": "Direct",
+ "requested": "[3.0.0, )",
+ "resolved": "3.0.0",
+ "contentHash": "swNpSTl0iYJeBuvYYfaY+VxzZ5YC8wklwkqDCNOq2aTQqJzjauJfh/O3Zw93nwxspWrxvZTjT45f8VPR0ParEA=="
+ },
+ "Microsoft.Extensions.AmbientMetadata.Application": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "tm28s2ODWZ6RdysP06NI3B23DUY5OfHG35ihMHxVAO3hywZAczDVjrkYMfBY//J4HQqfDHS5op84BhnF7ROseQ==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration": "10.0.15",
+ "Microsoft.Extensions.Hosting.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.Caching.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "L+eahU5QGaFaCau3Y9qqY7WThUsR18sHASVDD1KuaSx2dy73NOY9U5Qz5eOe6bJOF3wHzkEaCl2LZhgwtlClyw==",
+ "dependencies": {
+ "Microsoft.Extensions.Primitives": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Compliance.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "DUwdXgIxJKH9zBNg/SUBqOX0FpXCq7w80CIzrr0Jcw5tBXS926AtCcidoAsEHq5e/c6KQ8rWhSt7NxFxak8N/Q==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15",
+ "Microsoft.Extensions.ObjectPool": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.Compliance.Redaction": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "2rwe98yZEn4+aXjAg5DdcROMg6m2w3tejf/mRk4/fBCHKM2EWCaFTmbHLtz1BfyBxMY00/08XFoN0wzWYNiSiQ==",
+ "dependencies": {
+ "Microsoft.Extensions.Compliance.Abstractions": "11.0.1",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.Configuration": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "VQS/GkFU9oLQmXZv0AR/zluF0YAbEAoUQ5aYMqcRc2TWeKa6m2AjInAOnDhCcoWI5a6LQUCzTcl8B3DZZaPZLg==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Primitives": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Configuration.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "oyBSWnEsEi9SZTiwAfuKIdVIiEZ7TvNOtdFaGqyzF9WtomNV+uZHCqhQbnz/ipjtM50BYJ4s0MWbYafolq2mAg==",
+ "dependencies": {
+ "Microsoft.Extensions.Primitives": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Configuration.Binder": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "3eoaKF4Stat1PSN+KFwqmy04sM9DwGuHM1o1lHwuNFM/TqwQ+PCIvaQHS4lcT3kJl5rwvDK4w/rIlR0wc024eQ==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration": "11.0.0",
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.DependencyInjection": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "KygQMITBDDPXw7+AAgdwQvVAaTXuDsc1iCAuvhO73ERxKX+d92cdbgZmpoYF7DIUq2hfs/yO2KD87uIreRy3MA==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.DependencyInjection.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "a2c4Kp55miXT6G+DSb75pczXQJHgNMzPyZEyMxrrKxuQrgvctcDWJWD9fVe/uGbQdu4Z0c3B7AVKp1DXmD64nQ=="
+ },
+ "Microsoft.Extensions.DependencyInjection.AutoActivation": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "OuVIF5TmsfonN2Fqmi2zlUtbFQNqQiflhgo/rh64ptrqYrB4wZLwKbXr/HzrQXMf+h3jIbWrjIdJFspGqcvuuQ==",
+ "dependencies": {
+ "Microsoft.Extensions.Hosting.Abstractions": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.Diagnostics": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "tX8piU+KbYHXIf5F70leczIWwtTkPKhyjRqjbo6D2uTA1PwrhcMD+Ls7rzqSMkx1U3osyrD4/kCrZeF13Lkgnw==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration": "11.0.0",
+ "Microsoft.Extensions.Diagnostics.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Diagnostics.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "o188Hh1AqAI91K+R8eY3REW5HzofGastQk8OPLIy4uS8FnJo4Niok/X+HH/nHRO1ApsxW7q1yYFoHDpAZC36fA==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0",
+ "System.Diagnostics.DiagnosticSource": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Diagnostics.ExceptionSummarization": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "mqqpmAFNRLa4cozN3RvT/T81k4aarwMc8xb8VVQgLqUE7AAoN/WWayZAvP+4hy9+KujP3dfn3taU06fZJPIbgA==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.FileProviders.Abstractions": {
+ "type": "Transitive",
+ "resolved": "10.0.15",
+ "contentHash": "1RSYAUtJeb76m2T0u5BbvwKY3s+ge9fT3cj1odvo5Bm+frc7pU9RSeXeMIlYHV8GjpqLdv2neeeomz010yYL8A==",
+ "dependencies": {
+ "Microsoft.Extensions.Primitives": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.Hosting.Abstractions": {
+ "type": "Transitive",
+ "resolved": "10.0.15",
+ "contentHash": "s/JBiwR3F/vKRCbe6WO5b6t6or1ISaZ3rllchcw6/FSWZmK8s2fAzD7elrZo7592FnMD1fhGoG/wuJL1YYtVXw==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration.Abstractions": "10.0.15",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Diagnostics.Abstractions": "10.0.15",
+ "Microsoft.Extensions.FileProviders.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.Http.Diagnostics": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "mKHY0oFYL3fkAOhBNi2LqWPuEdUJ+HiF28KKUwBkQG2sgXAUdFDDqvJAfu2PcYgtAwsAtl58zuk4SElpPzbCvA==",
+ "dependencies": {
+ "Microsoft.Extensions.Compliance.Redaction": "11.0.1",
+ "Microsoft.Extensions.Http": "10.0.15",
+ "Microsoft.Extensions.Telemetry": "11.0.1"
+ }
+ },
+ "Microsoft.Extensions.Logging": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "zsse8MOgo0bj2KAEsSkg9WtNAfZbHbTlGeqfhy5PGozomM3zQM0XzumSQzQ0451IWNSJWLqYaSIQEpCi2j1sCA==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection": "11.0.0",
+ "Microsoft.Extensions.Logging.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Logging.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "MTMO2V1eT9Dm5VIpJGLNwIjAjoBErUlfuB+DEaZ0tb8J+Nf/Xlj8he5AztK9p1iOJPIyuBeOrVy2u/CSdsfzPw==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "System.Diagnostics.DiagnosticSource": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Logging.Configuration": {
+ "type": "Transitive",
+ "resolved": "10.0.15",
+ "contentHash": "Km6Ml1/nu0T/f80Btonxf9CWmP/BXI84aJwC5fUbCxRArJ0lH++0ADQrjErZvsSIrKhusTkTSGBChKy2fYAF4w==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration": "10.0.15",
+ "Microsoft.Extensions.Configuration.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Configuration.Binder": "10.0.15",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Logging": "10.0.15",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Options": "10.0.15",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.ObjectPool": {
+ "type": "Transitive",
+ "resolved": "10.0.15",
+ "contentHash": "kvd9eyRRQ+OEu9wik7GKgTS+7XnJ5XoOtSXJqmkJtVYV/S4gsBUrobYRSdNeBcb0ymef4L5Q9pZGiTxJ8jJfyQ=="
+ },
+ "Microsoft.Extensions.Options.ConfigurationExtensions": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "s4JrxDPwxk8pE6LFVj+M5TrDHxOVIoCnQBy5lexs5uAYeggPYwAc/pSDNgVuZN14pCmZGCInygI/2ylCdLYShw==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Configuration.Binder": "11.0.0",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0",
+ "Microsoft.Extensions.Primitives": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Primitives": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "HH2akbW2HeY/xeZJA5UceuQQX+1Pv/Kxrz/x4XPoH6wYDtgPIlBeOTZlQXlT+b50b1Ym/xfP+WJCX9FW4uLBXQ=="
+ },
+ "Microsoft.Extensions.Resilience": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "xgKof6iwAByZNrxWOa7Drk4A953L7U2HleTmx7EXE2Vf6j1crp4RsvNlIVsJMtHKf3ftGKd9gOhR3xES9vxUgg==",
+ "dependencies": {
+ "Microsoft.Extensions.Diagnostics": "10.0.15",
+ "Microsoft.Extensions.Diagnostics.ExceptionSummarization": "11.0.1",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15",
+ "Microsoft.Extensions.Telemetry.Abstractions": "11.0.1",
+ "Polly.Extensions": "8.4.2",
+ "Polly.RateLimiting": "8.4.2"
+ }
+ },
+ "Microsoft.Extensions.Telemetry": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "9uuA8entTC9m00m59h6CACSt4IQh9KknB+hPvCteXUTiG67lqJ8BI65fEUJSPSfT3ZDDi01Zg2aY5kRUvD4HPw==",
+ "dependencies": {
+ "Microsoft.Extensions.AmbientMetadata.Application": "11.0.1",
+ "Microsoft.Extensions.DependencyInjection.AutoActivation": "11.0.1",
+ "Microsoft.Extensions.Logging.Configuration": "10.0.15",
+ "Microsoft.Extensions.ObjectPool": "10.0.15",
+ "Microsoft.Extensions.Telemetry.Abstractions": "11.0.1"
+ }
+ },
+ "Microsoft.Extensions.Telemetry.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "qINZz4G01Wxumqd0hLr6YdzPa3s7jexQWN28EenaiJQnmKdsR9FnBaKENdRRElLc+A5bJKQ+jYw/WHG4ZpIyAg==",
+ "dependencies": {
+ "Microsoft.Extensions.Compliance.Abstractions": "11.0.1",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.15",
+ "Microsoft.Extensions.ObjectPool": "10.0.15",
+ "Microsoft.Extensions.Options": "10.0.15"
+ }
+ },
+ "OpenAI": {
+ "type": "Transitive",
+ "resolved": "2.15.0",
+ "contentHash": "04Lvp/guze35OdYsEcQY58SmSCBWCEDCGkiLiTQXDJy5L3d20n7I/zg94ry9hQ5c4dMDF1ASqlxD/IIMy47gFg==",
+ "dependencies": {
+ "System.ClientModel": "1.16.0"
+ }
+ },
+ "Polly.Core": {
+ "type": "Transitive",
+ "resolved": "8.4.2",
+ "contentHash": "BpE2I6HBYYA5tF0Vn4eoQOGYTYIK1BlF5EXVgkWGn3mqUUjbXAr13J6fZVbp7Q3epRR8yshacBMlsHMhpOiV3g=="
+ },
+ "Polly.Extensions": {
+ "type": "Transitive",
+ "resolved": "8.4.2",
+ "contentHash": "GZ9vRVmR0jV2JtZavt+pGUsQ1O1cuRKG7R7VOZI6ZDy9y6RNPvRvXK1tuS4ffUrv8L0FTea59oEuQzgS0R7zSA==",
+ "dependencies": {
+ "Microsoft.Extensions.Logging.Abstractions": "8.0.0",
+ "Microsoft.Extensions.Options": "8.0.0",
+ "Polly.Core": "8.4.2"
+ }
+ },
+ "Polly.RateLimiting": {
+ "type": "Transitive",
+ "resolved": "8.4.2",
+ "contentHash": "ehTImQ/eUyO07VYW2WvwSmU9rRH200SKJ/3jku9rOkyWE0A2JxNFmAVms8dSn49QLSjmjFRRSgfNyOgr/2PSmA==",
+ "dependencies": {
+ "Polly.Core": "8.4.2",
+ "System.Threading.RateLimiting": "8.0.0"
+ }
+ },
+ "Spectre.Console.Ansi": {
+ "type": "Transitive",
+ "resolved": "0.57.2",
+ "contentHash": "Y1+u73shwP+JYHmrkdN6bSt2kaGBEAafhi2nrecczbXdFRey+k7J/WF9YPfcB0rqivv2S8fmif6FSBq9m/AFvw=="
+ },
+ "System.ClientModel": {
+ "type": "Transitive",
+ "resolved": "1.16.0",
+ "contentHash": "vLljZON+8lXDUtsPP8uwsPvsBSQaUHhh8NvB+D9TQsXu5n622RLtuLyZAcyIFc98b8ixrwD0AhzUQhtg2NwJnQ==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration.Abstractions": "10.0.10",
+ "Microsoft.Extensions.Hosting.Abstractions": "10.0.10",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.10",
+ "System.Memory.Data": "10.0.10"
+ }
+ },
+ "System.Diagnostics.DiagnosticSource": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "+boRR9uSKiIPtFeRLGwO5xylhDF80xpwM+dmk5jgIqqeUKLbujGkGICMTKqQrBzKO6fIp8BU8DV6YZkQukqo3A=="
+ },
+ "System.Memory.Data": {
+ "type": "Transitive",
+ "resolved": "10.0.10",
+ "contentHash": "roR+5AeOpflUxJQlqSfsZs/Bvi1uw4KBuTkIgF1e8l0RdalG4AUn84+sjJLclEfOV85gAjc8+Pp540qjDE5UIg=="
+ },
+ "System.Numerics.Tensors": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "thx6y1hMzB6LumB/aLcZoLHWq8wr+dbldk/FiNghyT+4ynxo9u2oCTFfb5iDMDG6hykDXLorXuaf4EPEij2BBg=="
+ },
+ "System.Threading.RateLimiting": {
+ "type": "Transitive",
+ "resolved": "8.0.0",
+ "contentHash": "7mu9v0QDv66ar3DpGSZHg9NuNcxDaaAcnMULuZlaTpP9+hwXhrxNGsF5GmLkSHxFdb5bBc1TzeujsRgTrPWi+Q=="
+ },
+ "dotbahn.ai": {
+ "type": "Project",
+ "dependencies": {
+ "DotBahn.Boards": "[1.0.0, )",
+ "DotBahn.Facilities": "[1.0.0, )",
+ "DotBahn.Stations": "[1.0.0, )",
+ "Microsoft.Extensions.AI": "[11.0.1, )",
+ "Microsoft.Extensions.AI.Abstractions": "[11.0.1, )"
+ }
+ },
+ "dotbahn.boards": {
+ "type": "Project",
+ "dependencies": {
+ "DotBahn.Common": "[1.0.0, )",
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Http.Resilience": "[11.0.1, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
+ }
+ },
+ "dotbahn.common": {
+ "type": "Project",
+ "dependencies": {
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
+ }
+ },
+ "dotbahn.facilities": {
+ "type": "Project",
+ "dependencies": {
+ "DotBahn.Common": "[1.0.0, )",
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Http.Resilience": "[11.0.1, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
+ }
+ },
+ "dotbahn.stations": {
+ "type": "Project",
+ "dependencies": {
+ "DotBahn.Common": "[1.0.0, )",
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Http.Resilience": "[11.0.1, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
+ }
+ },
+ "Microsoft.Extensions.AI": {
+ "type": "CentralTransitive",
+ "requested": "[11.0.1, )",
+ "resolved": "11.0.1",
+ "contentHash": "MP6zzZzPseaXu0DtZFCkPCWPXLTu7JY28ciyxqSoeDOP5Raf+wJT8+HapyLfXaI7F1CXpyr5PgiCQEE0CeVCqw==",
+ "dependencies": {
+ "Microsoft.Extensions.AI.Abstractions": "11.0.1",
+ "Microsoft.Extensions.Caching.Abstractions": "11.0.0",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Logging.Abstractions": "11.0.0",
+ "System.Numerics.Tensors": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.AI.Abstractions": {
+ "type": "CentralTransitive",
+ "requested": "[11.0.1, )",
+ "resolved": "11.0.1",
+ "contentHash": "pG3n1nHRnVcYuMAiqhDPuKefXTtUGAhAtqhBUKpNsZXYef9Vm51iZhUAVfQ2EzYhechFaA5hCcgQgK18jTzuiw=="
+ },
+ "Microsoft.Extensions.Http": {
+ "type": "CentralTransitive",
+ "requested": "[11.0.0, )",
+ "resolved": "11.0.0",
+ "contentHash": "Pa5xJYtE5weFzv8sRwei1yvqCc05PareJABDtUSigzyj0xmrnG7ZU5VBy0hf5tgh7HN3/psGiOQouw5PLaQD8w==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Diagnostics": "11.0.0",
+ "Microsoft.Extensions.Logging": "11.0.0",
+ "Microsoft.Extensions.Logging.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Http.Resilience": {
+ "type": "CentralTransitive",
+ "requested": "[11.0.1, )",
+ "resolved": "11.0.1",
+ "contentHash": "5VawCrg+VgVT2hNurSSEWUnq0pvNoH+Zt82s5Wpl/8jdnmU8DpRlr+M3DcdtVgeBG7mRyk3GtSRbf8PB/HrL3w==",
+ "dependencies": {
+ "Microsoft.Extensions.Http.Diagnostics": "11.0.1",
+ "Microsoft.Extensions.ObjectPool": "10.0.15",
+ "Microsoft.Extensions.Resilience": "11.0.1"
+ }
+ },
+ "Microsoft.Extensions.Options": {
+ "type": "CentralTransitive",
+ "requested": "[11.0.0, )",
+ "resolved": "11.0.0",
+ "contentHash": "AaNswJ3NqdNCNqQVlU7iTkvrrrzqrSSxkOC3bLlrwv/CPN7YRz3HoJk7o4ey5v6U8bOHocHsyYoJ7ihK1KUWyQ==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Primitives": "11.0.0"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/DotBahn.Samples.StationBrowser/Program.cs b/samples/DotBahn.Samples.StationBrowser/Program.cs
index b37447f..6ff61cf 100644
--- a/samples/DotBahn.Samples.StationBrowser/Program.cs
+++ b/samples/DotBahn.Samples.StationBrowser/Program.cs
@@ -6,6 +6,7 @@
using DotBahn.Facilities;
using DotBahn.Facilities.Models;
using DotBahn.Facilities.Models.Enumerations;
+using DotBahn.Samples.StationBrowser;
using DotBahn.Stations;
using DotBahn.Stations.Models;
using DotBahn.Stations.Models.Enumerations;
@@ -16,425 +17,427 @@
return await StationBrowserCli.BuildRootCommand().Parse(args).InvokeAsync();
-internal static class StationBrowserCli {
- private static readonly Argument SearchArgument = new("search") {
- Description = "Station name to search for (e.g. würzburg)",
- Arity = ArgumentArity.ZeroOrOne,
- };
-
- private static readonly Option ClientIdOption = new("--client") {
- Description = "DB API client id; falls back to the DOTBAHN_CLIENT environment variable",
- };
-
- private static readonly Option SecretOption = new("--secret") {
- Description = "DB API secret; falls back to the DOTBAHN_SECRET environment variable",
- };
-
- private static readonly Option JsonOption = new("--json", "-j") {
- Description = "Print the matched stations as JSON instead of starting the interactive browser",
- };
-
- internal static RootCommand BuildRootCommand() {
- var rootCommand = new RootCommand("Interactive browser for Deutsche Bahn stations and their facilities") {
- SearchArgument,
- ClientIdOption,
- SecretOption,
- JsonOption,
+namespace DotBahn.Samples.StationBrowser {
+ internal static class StationBrowserCli {
+ private static readonly Argument SearchArgument = new("search") {
+ Description = "Station name to search for (e.g. würzburg)",
+ Arity = ArgumentArity.ZeroOrOne
};
- rootCommand.Validators.Add(result => {
- var search = result.GetValue(SearchArgument);
- if (string.IsNullOrWhiteSpace(search)) {
- result.AddError("A search name is required: pass the station name to look up.");
- }
- });
+ private static readonly Option ClientIdOption = new("--client") {
+ Description = "DB API client id; falls back to the DOTBAHN_CLIENT environment variable"
+ };
- rootCommand.SetAction(async (parseResult, cancellationToken) => {
- var search = parseResult.GetValue(SearchArgument)!;
- var clientId = parseResult.GetValue(ClientIdOption);
- var secret = parseResult.GetValue(SecretOption);
- var json = parseResult.GetValue(JsonOption);
+ private static readonly Option SecretOption = new("--secret") {
+ Description = "DB API secret; falls back to the DOTBAHN_SECRET environment variable"
+ };
- return await RunAsync(search, clientId, secret, json, cancellationToken);
- });
+ private static readonly Option JsonOption = new("--json", "-j") {
+ Description = "Print the matched stations as JSON instead of starting the interactive browser"
+ };
- return rootCommand;
- }
+ internal static RootCommand BuildRootCommand() {
+ var rootCommand = new RootCommand("Interactive browser for Deutsche Bahn stations and their facilities") {
+ SearchArgument,
+ ClientIdOption,
+ SecretOption,
+ JsonOption
+ };
- private static async Task RunAsync(string search, string? clientId, string? secret, bool json, CancellationToken cancellationToken) {
- if (!ResolveCredentials(clientId, secret, out var resolvedClientId, out var resolvedSecret)) {
- if (json) {
- WriteJsonError("missing-credentials", "Provide --client/--secret or set DOTBAHN_CLIENT and DOTBAHN_SECRET.");
- } else {
- AnsiConsole.MarkupLine("[red]Usage:[/] provide --client/--secret, or set DOTBAHN_CLIENT / DOTBAHN_SECRET via env or CLI args");
- }
- return 1;
+ rootCommand.Validators.Add(result => {
+ var search = result.GetValue(SearchArgument);
+ if (string.IsNullOrWhiteSpace(search)) {
+ result.AddError("A search name is required: pass the station name to look up.");
+ }
+ });
+
+ rootCommand.SetAction(async (parseResult, cancellationToken) => {
+ var search = parseResult.GetValue(SearchArgument)!;
+ var clientId = parseResult.GetValue(ClientIdOption);
+ var secret = parseResult.GetValue(SecretOption);
+ var json = parseResult.GetValue(JsonOption);
+
+ return await RunAsync(search, clientId, secret, json, cancellationToken);
+ });
+
+ return rootCommand;
}
- List stations;
+ private static async Task RunAsync(string search, string? clientId, string? secret, bool json, CancellationToken cancellationToken) {
+ if (!ResolveCredentials(clientId, secret, out var resolvedClientId, out var resolvedSecret)) {
+ if (json) {
+ WriteJsonError("missing-credentials", "Provide --client/--secret or set DOTBAHN_CLIENT and DOTBAHN_SECRET.");
+ } else {
+ AnsiConsole.MarkupLine("[red]Usage:[/] provide --client/--secret, or set DOTBAHN_CLIENT / DOTBAHN_SECRET via env or CLI args");
+ }
+ return 1;
+ }
- try {
- stations = await FindStationsAsync(resolvedClientId, resolvedSecret, search, cancellationToken);
- } catch (HttpRequestException ex) {
- if (json) {
- WriteJsonError("api-error", ex.Message);
- } else {
- AnsiConsole.MarkupLine($"[red]API request failed:[/] [grey]{Markup.Escape(ex.Message)}[/]");
+ List stations;
+
+ try {
+ stations = await FindStationsAsync(resolvedClientId, resolvedSecret, search, cancellationToken);
+ } catch (HttpRequestException ex) {
+ if (json) {
+ WriteJsonError("api-error", ex.Message);
+ } else {
+ AnsiConsole.MarkupLine($"[red]API request failed:[/] [grey]{Markup.Escape(ex.Message)}[/]");
+ }
+ return 1;
+ }
+
+ if (stations.Count == 0) {
+ if (json) {
+ WriteJsonError("station-not-found", $"No stations found matching \"{search}\"");
+ } else {
+ AnsiConsole.MarkupLine($"[yellow]No stations found matching '{Markup.Escape(search)}'[/]");
+ }
+ return 1;
}
- return 1;
- }
- if (stations.Count == 0) {
if (json) {
- WriteJsonError("station-not-found", $"No stations found matching \"{search}\"");
- } else {
- AnsiConsole.MarkupLine($"[yellow]No stations found matching '{Markup.Escape(search)}'[/]");
+ Console.WriteLine(JsonSerializer.Serialize(new StationsPayload([.. stations.Select(ToStationDto)]), StationBrowserJsonContext.Default.StationsPayload));
+ return 0;
}
- return 1;
- }
- if (json) {
- Console.WriteLine(JsonSerializer.Serialize(new StationsPayload([.. stations.Select(ToStationDto)]), StationBrowserJsonContext.Default.StationsPayload));
+ await BrowseAsync(stations, resolvedClientId, resolvedSecret);
return 0;
}
- await BrowseAsync(stations, resolvedClientId, resolvedSecret);
- return 0;
- }
-
- private static bool ResolveCredentials(string? clientId, string? secret, out string resolvedClientId, out string resolvedSecret) {
- _ = TryCredentialsFromEnvironment(out var envClient, out var envSecret);
- resolvedClientId = clientId ?? envClient;
- resolvedSecret = secret ?? envSecret;
- return !string.IsNullOrEmpty(resolvedClientId) && !string.IsNullOrEmpty(resolvedSecret);
- }
-
- private static bool TryCredentialsFromEnvironment(out string clientId, out string clientSecret) {
- clientId = Environment.GetEnvironmentVariable("DOTBAHN_CLIENT") ?? string.Empty;
- clientSecret = Environment.GetEnvironmentVariable("DOTBAHN_SECRET") ?? string.Empty;
- return !string.IsNullOrEmpty(clientId) && !string.IsNullOrEmpty(clientSecret);
- }
+ private static bool ResolveCredentials(string? clientId, string? secret, out string resolvedClientId, out string resolvedSecret) {
+ _ = TryCredentialsFromEnvironment(out var envClient, out var envSecret);
+ resolvedClientId = clientId ?? envClient;
+ resolvedSecret = secret ?? envSecret;
+ return !string.IsNullOrEmpty(resolvedClientId) && !string.IsNullOrEmpty(resolvedSecret);
+ }
- private static async Task> FindStationsAsync(string clientId, string secret, string search, CancellationToken cancellationToken) {
- var services = new ServiceCollection();
- services.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Warning));
- services.AddDotBahnAuthorization(opt => {
- opt.ClientId = clientId;
- opt.ApiKey = secret;
- });
- services.AddDotBahnStations(opt => opt.BaseEndpoint = new Uri("https://apis.deutschebahn.com/db-api-marketplace/apis/station-data/v2/"));
- services.AddDotBahnFacilities(opt => opt.BaseEndpoint = new Uri("https://apis.deutschebahn.com/db-api-marketplace/apis/fasta/v2/"));
+ private static bool TryCredentialsFromEnvironment(out string clientId, out string clientSecret) {
+ clientId = Environment.GetEnvironmentVariable("DOTBAHN_CLIENT") ?? string.Empty;
+ clientSecret = Environment.GetEnvironmentVariable("DOTBAHN_SECRET") ?? string.Empty;
+ return !string.IsNullOrEmpty(clientId) && !string.IsNullOrEmpty(clientSecret);
+ }
- var serviceProvider = services.BuildServiceProvider();
- var stationsClient = serviceProvider.GetRequiredService();
+ private static async Task> FindStationsAsync(string clientId, string secret, string search, CancellationToken cancellationToken) {
+ var services = new ServiceCollection();
+ services.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Warning));
+ services.AddDotBahnAuthorization(opt => {
+ opt.ClientId = clientId;
+ opt.ApiKey = secret;
+ });
+ services.AddDotBahnStations(opt => opt.BaseEndpoint = new Uri("https://apis.deutschebahn.com/db-api-marketplace/apis/station-data/v2/"));
+ services.AddDotBahnFacilities(opt => opt.BaseEndpoint = new Uri("https://apis.deutschebahn.com/db-api-marketplace/apis/fasta/v2/"));
- var stations = new List();
- var query = new StationQuery().WithNames(search);
+ var serviceProvider = services.BuildServiceProvider();
+ var stationsClient = serviceProvider.GetRequiredService();
- await AnsiConsole.Status().Spinner(Spinner.Known.Dots).StartAsync($"Searching for stations matching '{search}'...", async _ => {
- stations.AddRange(await stationsClient.GetStationsAsync(query, cancellationToken));
- });
+ var stations = new List();
+ var query = new StationQuery().WithNames(search);
- return stations;
- }
+ await AnsiConsole.Status().Spinner(Spinner.Known.Dots).StartAsync($"Searching for stations matching '{search}'...", async _ => {
+ stations.AddRange(await stationsClient.GetStationsAsync(query, cancellationToken));
+ });
- private static StationDto ToStationDto(Station station) => new(
- station.Number,
- station.Name,
- station.PrimaryEva?.Number,
- station.Category.ToString(),
- station.Coordinates?.Latitude,
- station.Coordinates?.Longitude);
-
- private static void WriteJsonError(string code, string message) {
- var payload = new ErrorPayload(new ErrorDto(code, message));
- Console.WriteLine(JsonSerializer.Serialize(payload, StationBrowserJsonContext.Default.ErrorPayload));
- }
+ return stations;
+ }
- private static async Task BrowseAsync(List stations, string clientId, string secret) {
- var services = new ServiceCollection();
- services.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Warning));
- services.AddDotBahnAuthorization(opt => {
- opt.ClientId = clientId;
- opt.ApiKey = secret;
- });
- services.AddDotBahnStations(opt => opt.BaseEndpoint = new Uri("https://apis.deutschebahn.com/db-api-marketplace/apis/station-data/v2/"));
- services.AddDotBahnFacilities(opt => opt.BaseEndpoint = new Uri("https://apis.deutschebahn.com/db-api-marketplace/apis/fasta/v2/"));
-
- var serviceProvider = services.BuildServiceProvider();
- var facilitiesClient = serviceProvider.GetRequiredService();
-
- AnsiConsole.MarkupLine($"[green]Found {stations.Count} station(s)[/]");
- var facilitiesCache = new Dictionary>();
-
- var currentIndex = 0;
- while (true) {
- var currentStation = stations[currentIndex];
-
- if (!facilitiesCache.TryGetValue(currentStation.Number, out var facilities)) {
- await AnsiConsole.Status().Spinner(Spinner.Known.Dots).StartAsync(
- "Loading facilities...",
- async _ => {
- var query = new FacilityQuery().AtStation(currentStation.Number);
- facilities = (await facilitiesClient.GetFacilitiesAsync(query)).ToList();
- facilitiesCache[currentStation.Number] = facilities;
- });
- }
+ private static StationDto ToStationDto(Station station) => new(
+ station.Number,
+ station.Name,
+ station.PrimaryEva?.Number,
+ station.Category.ToString(),
+ station.Coordinates?.Latitude,
+ station.Coordinates?.Longitude);
+
+ private static void WriteJsonError(string code, string message) {
+ var payload = new ErrorPayload(new ErrorDto(code, message));
+ Console.WriteLine(JsonSerializer.Serialize(payload, StationBrowserJsonContext.Default.ErrorPayload));
+ }
- AnsiConsole.Clear();
- RenderStation(currentStation, facilities ?? [], currentIndex, stations.Count);
- RenderNavigation();
-
- switch (Console.ReadKey(true).Key) {
- case ConsoleKey.LeftArrow:
- if (currentIndex > 0) {
- currentIndex--;
- }
-
- break;
- case ConsoleKey.RightArrow:
- if (currentIndex < stations.Count - 1) {
- currentIndex++;
- }
-
- break;
- case ConsoleKey.Home:
- currentIndex = 0;
- break;
- case ConsoleKey.End:
- currentIndex = stations.Count - 1;
- break;
- case ConsoleKey.Escape:
- case ConsoleKey.Q:
- return;
+ private static async Task BrowseAsync(List stations, string clientId, string secret) {
+ var services = new ServiceCollection();
+ services.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Warning));
+ services.AddDotBahnAuthorization(opt => {
+ opt.ClientId = clientId;
+ opt.ApiKey = secret;
+ });
+ services.AddDotBahnStations(opt => opt.BaseEndpoint = new Uri("https://apis.deutschebahn.com/db-api-marketplace/apis/station-data/v2/"));
+ services.AddDotBahnFacilities(opt => opt.BaseEndpoint = new Uri("https://apis.deutschebahn.com/db-api-marketplace/apis/fasta/v2/"));
+
+ var serviceProvider = services.BuildServiceProvider();
+ var facilitiesClient = serviceProvider.GetRequiredService();
+
+ AnsiConsole.MarkupLine($"[green]Found {stations.Count} station(s)[/]");
+ var facilitiesCache = new Dictionary>();
+
+ var currentIndex = 0;
+ while (true) {
+ var currentStation = stations[currentIndex];
+
+ if (!facilitiesCache.TryGetValue(currentStation.Number, out var facilities)) {
+ await AnsiConsole.Status().Spinner(Spinner.Known.Dots).StartAsync(
+ "Loading facilities...",
+ async _ => {
+ var query = new FacilityQuery().AtStation(currentStation.Number);
+ facilities = (await facilitiesClient.GetFacilitiesAsync(query)).ToList();
+ facilitiesCache[currentStation.Number] = facilities;
+ });
+ }
+
+ AnsiConsole.Clear();
+ RenderStation(currentStation, facilities ?? [], currentIndex, stations.Count);
+ RenderNavigation();
+
+ switch (Console.ReadKey(true).Key) {
+ case ConsoleKey.LeftArrow:
+ if (currentIndex > 0) {
+ currentIndex--;
+ }
+
+ break;
+ case ConsoleKey.RightArrow:
+ if (currentIndex < stations.Count - 1) {
+ currentIndex++;
+ }
+
+ break;
+ case ConsoleKey.Home:
+ currentIndex = 0;
+ break;
+ case ConsoleKey.End:
+ currentIndex = stations.Count - 1;
+ break;
+ case ConsoleKey.Escape:
+ case ConsoleKey.Q:
+ return;
+ }
}
}
- }
- private static void RenderStation(Station station, List facilities, int index, int total) {
- var rule = new Rule(Markup.Escape(station.Name)) {
- Justification = Justify.Center,
- };
+ private static void RenderStation(Station station, List facilities, int index, int total) {
+ var rule = new Rule(Markup.Escape(station.Name)) {
+ Justification = Justify.Center
+ };
- AnsiConsole.Write(rule);
- RenderPositionBar(index, total);
- AnsiConsole.WriteLine();
+ AnsiConsole.Write(rule);
+ RenderPositionBar(index, total);
+ AnsiConsole.WriteLine();
- var leftPanel = BuildStationInfo(station);
- var rightPanel = BuildRightPanel(station.Services, facilities);
+ var leftPanel = BuildStationInfo(station);
+ var rightPanel = BuildRightPanel(station.Services, facilities);
- var layout = new Columns(leftPanel, rightPanel) {
- Expand = true
- };
+ var layout = new Columns(leftPanel, rightPanel) {
+ Expand = true
+ };
- AnsiConsole.Write(layout);
- }
+ AnsiConsole.Write(layout);
+ }
- private static IRenderable BuildStationInfo(Station station) {
- var rows = new List();
+ private static IRenderable BuildStationInfo(Station station) {
+ var rows = new List();
- var infoGrid = new Grid();
- infoGrid.AddColumn(new GridColumn().Width(18));
- infoGrid.AddColumn();
+ var infoGrid = new Grid();
+ infoGrid.AddColumn(new GridColumn().Width(18));
+ infoGrid.AddColumn();
- infoGrid.AddRow("[grey]Station Number[/]", $"{station.Number}");
- infoGrid.AddRow("[grey]Category[/]", FormatCategory(station.Category));
+ infoGrid.AddRow("[grey]Station Number[/]", $"{station.Number}");
+ infoGrid.AddRow("[grey]Category[/]", FormatCategory(station.Category));
- if (station.PrimaryEva != null) {
- infoGrid.AddRow("[grey]EVA Number[/]", $"{station.PrimaryEva.Number}");
- }
+ if (station.PrimaryEva != null) {
+ infoGrid.AddRow("[grey]EVA Number[/]", $"{station.PrimaryEva.Number}");
+ }
- if (station.PrimaryRil100 != null) {
- infoGrid.AddRow("[grey]RIL100[/]", Markup.Escape(station.PrimaryRil100.Identifier));
- }
+ if (station.PrimaryRil100 != null) {
+ infoGrid.AddRow("[grey]RIL100[/]", Markup.Escape(station.PrimaryRil100.Identifier));
+ }
- if (station.Coordinates != null) {
- var c = station.Coordinates.Value;
- infoGrid.AddRow("[grey]Coordinates[/]", $"{c.Latitude:F6}, {c.Longitude:F6}");
- }
+ if (station.Coordinates != null) {
+ var c = station.Coordinates.Value;
+ infoGrid.AddRow("[grey]Coordinates[/]", $"{c.Latitude:F6}, {c.Longitude:F6}");
+ }
- if (station.RegionalArea != null) {
- infoGrid.AddRow("[grey]Regional Area[/]", Markup.Escape($"{station.RegionalArea.Name} ({station.RegionalArea.ShortName})"));
- }
+ if (station.RegionalArea != null) {
+ infoGrid.AddRow("[grey]Regional Area[/]", Markup.Escape($"{station.RegionalArea.Name} ({station.RegionalArea.ShortName})"));
+ }
- rows.Add(infoGrid);
- rows.Add(new Text(""));
-
- if (station.Address != null) {
- var addressPanel = new Panel(
- Markup.Escape($"{station.Address.Street}\n{station.Address.ZipCode} {station.Address.City}")
- ) {
- Header = new PanelHeader("[blue]Address[/]"),
- Border = BoxBorder.Rounded,
- BorderStyle = Style.Parse("grey"),
- Expand = false
- };
- rows.Add(addressPanel);
+ rows.Add(infoGrid);
rows.Add(new Text(""));
- }
- if (station.EvaNumbers.Count() > 1) {
- rows.Add(new Markup("[grey]EVA Numbers:[/]"));
- rows.AddRange(station.EvaNumbers.Select(eva => new Text($" {eva.Number}{(eva.IsMain ? " (main)" : "")}")).Cast());
- rows.Add(new Text(""));
- }
+ if (station.Address != null) {
+ var addressPanel = new Panel(
+ Markup.Escape($"{station.Address.Street}\n{station.Address.ZipCode} {station.Address.City}")
+ ) {
+ Header = new PanelHeader("[blue]Address[/]"),
+ Border = BoxBorder.Rounded,
+ BorderStyle = Style.Parse("grey"),
+ Expand = false
+ };
+ rows.Add(addressPanel);
+ rows.Add(new Text(""));
+ }
+
+ if (station.EvaNumbers.Count > 1) {
+ rows.Add(new Markup("[grey]EVA Numbers:[/]"));
+ rows.AddRange(station.EvaNumbers.Select(eva => new Text($" {eva.Number}{(eva.IsMain ? " (main)" : "")}")));
+ rows.Add(new Text(""));
+ }
+
+ if (station.Ril100Identifiers.Count <= 1) {
+ return new Rows(rows);
+ }
+
+ rows.Add(new Markup("[grey]RIL100 Identifiers:[/]"));
+ foreach (var ril in station.Ril100Identifiers) {
+ rows.Add(new Text($" {Markup.Escape(ril.Identifier)}{(ril.IsMain ? " (main)" : "")}"));
+ }
- if (station.Ril100Identifiers.Count() <= 1) {
return new Rows(rows);
}
- rows.Add(new Markup("[grey]RIL100 Identifiers:[/]"));
- foreach (var ril in station.Ril100Identifiers) {
- rows.Add(new Text($" {Markup.Escape(ril.Identifier)}{(ril.IsMain ? " (main)" : "")}"));
- }
+ private static IRenderable BuildRightPanel(StationServices services, List facilities) {
+ var rows = new List();
- return new Rows(rows);
- }
+ var servicesTable = new Table {
+ Border = TableBorder.Rounded,
+ BorderStyle = Style.Parse("grey")
+ };
+ servicesTable.AddColumn(new TableColumn("[bold blue]Service[/]").LeftAligned());
+ servicesTable.AddColumn(new TableColumn("[blue]?[/]").Centered());
+
+ AddServiceRow(servicesTable, "Parking", services.HasParking);
+ AddServiceRow(servicesTable, "Bicycle Parking", services.HasBicycleParking);
+ AddServiceRow(servicesTable, "Public Facilities", services.HasPublicFacilities);
+ AddServiceRow(servicesTable, "Locker System", services.HasLockerSystem);
+ AddServiceRow(servicesTable, "Step-Free Access", services.HasStepFreeAccess);
+ AddServiceRow(servicesTable, "Stepless Access", services.HasSteplessAccess);
+ AddServiceRow(servicesTable, "Travel Center", services.HasTravelCenter);
+ AddServiceRow(servicesTable, "Travel Necessities", services.HasTravelNecessities);
+ AddServiceRow(servicesTable, "Mobility Service", services.HasMobilityService);
+ AddServiceRow(servicesTable, "WiFi", services.HasWiFi);
+
+ rows.Add(servicesTable);
+
+ if (facilities.Count <= 0) {
+ return new Rows(rows);
+ }
- private static IRenderable BuildRightPanel(StationServices services, List facilities) {
- var rows = new List();
+ rows.Add(new Text(""));
+ rows.Add(BuildFacilitiesPanel(facilities));
- var servicesTable = new Table {
- Border = TableBorder.Rounded,
- BorderStyle = Style.Parse("grey")
- };
- servicesTable.AddColumn(new TableColumn("[bold blue]Service[/]").LeftAligned());
- servicesTable.AddColumn(new TableColumn("[blue]?[/]").Centered());
-
- AddServiceRow(servicesTable, "Parking", services.HasParking);
- AddServiceRow(servicesTable, "Bicycle Parking", services.HasBicycleParking);
- AddServiceRow(servicesTable, "Public Facilities", services.HasPublicFacilities);
- AddServiceRow(servicesTable, "Locker System", services.HasLockerSystem);
- AddServiceRow(servicesTable, "Step-Free Access", services.HasStepFreeAccess);
- AddServiceRow(servicesTable, "Stepless Access", services.HasSteplessAccess);
- AddServiceRow(servicesTable, "Travel Center", services.HasTravelCenter);
- AddServiceRow(servicesTable, "Travel Necessities", services.HasTravelNecessities);
- AddServiceRow(servicesTable, "Mobility Service", services.HasMobilityService);
- AddServiceRow(servicesTable, "WiFi", services.HasWiFi);
-
- rows.Add(servicesTable);
-
- if (facilities.Count <= 0) {
return new Rows(rows);
}
- rows.Add(new Text(""));
- rows.Add(BuildFacilitiesPanel(facilities));
-
- return new Rows(rows);
- }
+ private static IRenderable BuildFacilitiesPanel(List facilities) {
+ var elevators = facilities.Where(f => f.Type == FacilityType.Elevator).ToList();
+ var escalators = facilities.Where(f => f.Type == FacilityType.Escalator).ToList();
- private static IRenderable BuildFacilitiesPanel(List facilities) {
- var elevators = facilities.Where(f => f.Type == FacilityType.Elevator).ToList();
- var escalators = facilities.Where(f => f.Type == FacilityType.Escalator).ToList();
+ var table = new Table {
+ Border = TableBorder.Rounded,
+ BorderStyle = Style.Parse("grey")
+ };
+ table.AddColumn(new TableColumn("[bold blue]Facilities[/]").LeftAligned());
+ table.AddColumn(new TableColumn("[blue]Status[/]").Centered());
+
+ var elevatorsActive = elevators.Count(f => f.State == FacilityState.Active);
+ var escalatorsActive = escalators.Count(f => f.State == FacilityState.Active);
+
+ if (elevators.Count > 0) {
+ var color = elevatorsActive == elevators.Count ? "green" :
+ elevatorsActive == 0 ? "red" : "yellow";
+ table.AddRow(
+ "Elevators",
+ $"[{color}]{elevatorsActive}/{elevators.Count}[/]"
+ );
+ }
- var table = new Table {
- Border = TableBorder.Rounded,
- BorderStyle = Style.Parse("grey")
- };
- table.AddColumn(new TableColumn("[bold blue]Facilities[/]").LeftAligned());
- table.AddColumn(new TableColumn("[blue]Status[/]").Centered());
-
- var elevatorsActive = elevators.Count(f => f.State == FacilityState.Active);
- var escalatorsActive = escalators.Count(f => f.State == FacilityState.Active);
-
- if (elevators.Count > 0) {
- var color = elevatorsActive == elevators.Count ? "green" :
- elevatorsActive == 0 ? "red" : "yellow";
- table.AddRow(
- "Elevators",
- $"[{color}]{elevatorsActive}/{elevators.Count}[/]"
- );
- }
+ if (escalators.Count > 0) {
+ var color = escalatorsActive == escalators.Count ? "green" :
+ escalatorsActive == 0 ? "red" : "yellow";
+ table.AddRow(
+ "Escalators",
+ $"[{color}]{escalatorsActive}/{escalators.Count}[/]"
+ );
+ }
- if (escalators.Count > 0) {
- var color = escalatorsActive == escalators.Count ? "green" :
- escalatorsActive == 0 ? "red" : "yellow";
- table.AddRow(
- "Escalators",
- $"[{color}]{escalatorsActive}/{escalators.Count}[/]"
- );
- }
+ var inactiveFacilities = facilities.Where(f => f.State != FacilityState.Active).ToList();
+ if (inactiveFacilities.Count <= 0) {
+ return table;
+ }
- var inactiveFacilities = facilities.Where(f => f.State != FacilityState.Active).ToList();
- if (inactiveFacilities.Count <= 0) {
- return table;
- }
+ table.AddEmptyRow();
+ table.AddRow("[red]Out of service:[/]", "");
+ foreach (var facility in inactiveFacilities.Take(5)) {
+ var typeIcon = facility.Type == FacilityType.Elevator ? "\u21c5" : "\u21f5";
+ var desc = facility.Description ?? $"#{facility.EquipmentNumber}";
+ if (desc.Length > 25) {
+ desc = desc[..22] + "...";
+ }
- table.AddEmptyRow();
- table.AddRow("[red]Out of service:[/]", "");
- foreach (var facility in inactiveFacilities.Take(5)) {
- var typeIcon = facility.Type == FacilityType.Elevator ? "\u21c5" : "\u21f5";
- var desc = facility.Description ?? $"#{facility.EquipmentNumber}";
- if (desc.Length > 25) {
- desc = desc[..22] + "...";
+ table.AddRow($"[grey]{typeIcon} {Markup.Escape(desc)}[/]", "");
+ }
+ if (inactiveFacilities.Count > 5) {
+ table.AddRow($"[grey]... and {inactiveFacilities.Count - 5} more[/]", "");
}
- table.AddRow($"[grey]{typeIcon} {Markup.Escape(desc)}[/]", "");
- }
- if (inactiveFacilities.Count > 5) {
- table.AddRow($"[grey]... and {inactiveFacilities.Count - 5} more[/]", "");
+ return table;
}
- return table;
- }
+ private static string FormatCategory(StationCategory category) {
+ var (color, description) = category switch {
+ StationCategory.Category1 => ("green", "Major Hub"),
+ StationCategory.Category2 => ("aqua", "Large Station"),
+ StationCategory.Category3 => ("blue", "Important Regional"),
+ StationCategory.Category4 => ("default", "Regional Station"),
+ StationCategory.Category5 => ("grey", "Standard Station"),
+ StationCategory.Category6 => ("grey", "Small Station"),
+ StationCategory.Category7 => ("grey", "Minor Stop"),
+ _ => ("yellow", "Unknown")
+ };
- private static string FormatCategory(StationCategory category) {
- var (color, description) = category switch {
- StationCategory.Category1 => ("green", "Major Hub"),
- StationCategory.Category2 => ("aqua", "Large Station"),
- StationCategory.Category3 => ("blue", "Important Regional"),
- StationCategory.Category4 => ("default", "Regional Station"),
- StationCategory.Category5 => ("grey", "Standard Station"),
- StationCategory.Category6 => ("grey", "Small Station"),
- StationCategory.Category7 => ("grey", "Minor Stop"),
- _ => ("yellow", "Unknown")
- };
+ var categoryNum = category switch {
+ StationCategory.Category1 => "1",
+ StationCategory.Category2 => "2",
+ StationCategory.Category3 => "3",
+ StationCategory.Category4 => "4",
+ StationCategory.Category5 => "5",
+ StationCategory.Category6 => "6",
+ StationCategory.Category7 => "7",
+ _ => "?"
+ };
- var categoryNum = category switch {
- StationCategory.Category1 => "1",
- StationCategory.Category2 => "2",
- StationCategory.Category3 => "3",
- StationCategory.Category4 => "4",
- StationCategory.Category5 => "5",
- StationCategory.Category6 => "6",
- StationCategory.Category7 => "7",
- _ => "?"
- };
+ return $"[bold {color}]{categoryNum}[/] [grey]({description})[/]";
+ }
- return $"[bold {color}]{categoryNum}[/] [grey]({description})[/]";
- }
+ private static void AddServiceRow(Table table, string name, bool available) {
+ var icon = available ? "[green]Yes[/]" : "[red]No[/]";
+ table.AddRow(name, icon);
+ }
- private static void AddServiceRow(Table table, string name, bool available) {
- var icon = available ? "[green]Yes[/]" : "[red]No[/]";
- table.AddRow(name, icon);
- }
+ private static void RenderPositionBar(int index, int total) {
+ var segments = new StringBuilder();
+ for (var i = 0; i < total; i++) {
+ segments.Append(i == index ? "[blue]\u2588[/]" : "[grey]\u2591[/]");
+ }
- private static void RenderPositionBar(int index, int total) {
- var segments = new StringBuilder();
- for (var i = 0; i < total; i++) {
- segments.Append(i == index ? "[blue]\u2588[/]" : "[grey]\u2591[/]");
+ AnsiConsole.MarkupLine(segments.ToString());
}
- AnsiConsole.MarkupLine(segments.ToString());
+ private static void RenderNavigation() {
+ AnsiConsole.WriteLine();
+ AnsiConsole.Write(new Rule());
+ AnsiConsole.MarkupLine("[grey]Navigation: [/]" + "[default]\u2190[/] Previous | [default]\u2192[/] Next | [default]Home[/] First | [default]End[/] Last | [default]Q/Esc[/] Quit");
+ }
}
- private static void RenderNavigation() {
- AnsiConsole.WriteLine();
- AnsiConsole.Write(new Rule());
- AnsiConsole.MarkupLine("[grey]Navigation: [/]" + "[default]\u2190[/] Previous | [default]\u2192[/] Next | [default]Home[/] First | [default]End[/] Last | [default]Q/Esc[/] Quit");
- }
-}
+ [JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, WriteIndented = true)]
+ [JsonSerializable(typeof(StationsPayload))]
+ [JsonSerializable(typeof(ErrorPayload))]
+ internal sealed partial class StationBrowserJsonContext : JsonSerializerContext;
-[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, WriteIndented = true)]
-[JsonSerializable(typeof(StationsPayload))]
-[JsonSerializable(typeof(ErrorPayload))]
-internal sealed partial class StationBrowserJsonContext : JsonSerializerContext;
+ internal sealed record StationsPayload(IEnumerable Stations);
-internal sealed record StationsPayload(IEnumerable Stations);
+ internal sealed record StationDto(int Number, string Name, long? Eva, string? Category, double? Latitude, double? Longitude);
-internal sealed record StationDto(int Number, string Name, long? Eva, string? Category, double? Latitude, double? Longitude);
+ internal sealed record ErrorPayload(ErrorDto Error);
-internal sealed record ErrorPayload(ErrorDto Error);
-
-internal sealed record ErrorDto(string Code, string Message);
+ internal sealed record ErrorDto(string Code, string Message);
+}
diff --git a/samples/DotBahn.Samples.StationBrowser/dbstation.spec b/samples/DotBahn.Samples.StationBrowser/dbstation.spec
index 3fb7a20..277a235 100644
--- a/samples/DotBahn.Samples.StationBrowser/dbstation.spec
+++ b/samples/DotBahn.Samples.StationBrowser/dbstation.spec
@@ -19,6 +19,7 @@ built with DotBahn (https://github.com/rlvelte/dotbahn).
%install
install -Dm755 dbstation %{buildroot}%{_bindir}/dbstation
+install -Dm644 bom.json %{buildroot}%{_datadir}/%{name}/bom.json
%check
:
@@ -26,6 +27,7 @@ install -Dm755 dbstation %{buildroot}%{_bindir}/dbstation
%files
%license LICENSE
%{_bindir}/dbstation
+%{_datadir}/%{name}/bom.json
%changelog
* Wed Oct 28 2026 Robin L. Velte - 2.1.1-0
diff --git a/samples/DotBahn.Samples.StationBrowser/packages.lock.json b/samples/DotBahn.Samples.StationBrowser/packages.lock.json
index 0e06c31..561ff90 100644
--- a/samples/DotBahn.Samples.StationBrowser/packages.lock.json
+++ b/samples/DotBahn.Samples.StationBrowser/packages.lock.json
@@ -2,23 +2,6 @@
"version": 2,
"dependencies": {
"net10.0": {
- "Microsoft.NET.ILLink.Tasks": {
- "type": "Direct",
- "requested": "[10.0.14, )",
- "resolved": "10.0.14",
- "contentHash": "YlTamXppEQls6DYWt7RdUuwWDb0lyw/vXCaGeQpLCpsLmfwGuCkOz/vIGgMTV7ECsJcavkCOkxZXv9s8rdAHkQ=="
- },
- "Microsoft.SourceLink.GitHub": {
- "type": "Direct",
- "requested": "[10.0.403, )",
- "resolved": "10.0.403",
- "contentHash": "T4WYxWydJGNQRe/EgURFlhPZ1cHYgivrCCHSomCcfQzGzhkDYGNn5bUwwjs4/PHuMxsmGaLvPv2puG8lluA1IA==",
- "dependencies": {
- "Microsoft.Build.Tasks.Git": "10.0.403",
- "Microsoft.SourceLink.Common": "10.0.403",
- "System.IO.Hashing": "10.0.14"
- }
- },
"MinVer": {
"type": "Direct",
"requested": "[8.0.0, )",
@@ -36,236 +19,235 @@
},
"System.CommandLine": {
"type": "Direct",
- "requested": "[2.0.14, )",
- "resolved": "2.0.14",
- "contentHash": "15fyVO4aG6poR6IKmhM74zf7PUzaU6FZAGm2d3SQSO9yIyGAeo44e6t9qeKjjaqyMEqYdqcb2G1B0gpLoDU2cA=="
+ "requested": "[3.0.0, )",
+ "resolved": "3.0.0",
+ "contentHash": "swNpSTl0iYJeBuvYYfaY+VxzZ5YC8wklwkqDCNOq2aTQqJzjauJfh/O3Zw93nwxspWrxvZTjT45f8VPR0ParEA=="
},
- "Microsoft.Build.Tasks.Git": {
+ "Microsoft.Extensions.AmbientMetadata.Application": {
"type": "Transitive",
- "resolved": "10.0.403",
- "contentHash": "1furteBFeemMmZ4s+ORjQb7YtO+wG63NJahbQbRUi91FV6V87BdV0U3vX1jbMC6iKSELYYoXWssSzLu3mx0i2w==",
+ "resolved": "11.0.1",
+ "contentHash": "tm28s2ODWZ6RdysP06NI3B23DUY5OfHG35ihMHxVAO3hywZAczDVjrkYMfBY//J4HQqfDHS5op84BhnF7ROseQ==",
"dependencies": {
- "System.IO.Hashing": "10.0.14"
+ "Microsoft.Extensions.Configuration": "10.0.15",
+ "Microsoft.Extensions.Hosting.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15"
}
},
- "Microsoft.Extensions.AmbientMetadata.Application": {
+ "Microsoft.Extensions.Compliance.Abstractions": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "aMCm7C6CexZT8W/p8zRp4BoxSnqRs3MmkBF7FvPIXC92b7vqs2SL0J+mVJi5W2Mk9Vb4ZRFWe9sdzFew6zUl1w==",
+ "resolved": "11.0.1",
+ "contentHash": "DUwdXgIxJKH9zBNg/SUBqOX0FpXCq7w80CIzrr0Jcw5tBXS926AtCcidoAsEHq5e/c6KQ8rWhSt7NxFxak8N/Q==",
"dependencies": {
- "Microsoft.Extensions.Configuration": "10.0.13",
- "Microsoft.Extensions.Hosting.Abstractions": "10.0.13",
- "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.13"
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15",
+ "Microsoft.Extensions.ObjectPool": "10.0.15"
}
},
- "Microsoft.Extensions.Compliance.Abstractions": {
+ "Microsoft.Extensions.Compliance.Redaction": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "2mjAb3Sm5k6uNeI+IyXpggYMpfdDDGgZSwUm9QQsm5QgZboJWbm2eU+6wNMrlfFEao11yq6JS1zXI7SVQQ0NuQ==",
+ "resolved": "11.0.1",
+ "contentHash": "2rwe98yZEn4+aXjAg5DdcROMg6m2w3tejf/mRk4/fBCHKM2EWCaFTmbHLtz1BfyBxMY00/08XFoN0wzWYNiSiQ==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.13",
- "Microsoft.Extensions.ObjectPool": "10.0.13"
+ "Microsoft.Extensions.Compliance.Abstractions": "11.0.1",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15"
}
},
"Microsoft.Extensions.Configuration": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "UcnvaEaMvRckDDhyqY1OZkFwBqpZArkHFKB6dWaQWT9XTuNttNNX8Cqsb/Sic2LfJxsMLJUXnYrxY3iX5LN9pQ==",
+ "resolved": "11.0.0",
+ "contentHash": "VQS/GkFU9oLQmXZv0AR/zluF0YAbEAoUQ5aYMqcRc2TWeKa6m2AjInAOnDhCcoWI5a6LQUCzTcl8B3DZZaPZLg==",
"dependencies": {
- "Microsoft.Extensions.Configuration.Abstractions": "10.0.14",
- "Microsoft.Extensions.Primitives": "10.0.14"
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Primitives": "11.0.0"
}
},
"Microsoft.Extensions.Configuration.Abstractions": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "4YdfvaoWn3tB1xQQHGrhRTFWJ8fGOqxThxduynSZy9ZFTiSaUi3vX4EK/kj8h2HQMwTlks9MWV1fv2WRBv5/1w==",
+ "resolved": "11.0.0",
+ "contentHash": "oyBSWnEsEi9SZTiwAfuKIdVIiEZ7TvNOtdFaGqyzF9WtomNV+uZHCqhQbnz/ipjtM50BYJ4s0MWbYafolq2mAg==",
"dependencies": {
- "Microsoft.Extensions.Primitives": "10.0.14"
+ "Microsoft.Extensions.Primitives": "11.0.0"
}
},
"Microsoft.Extensions.Configuration.Binder": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "brDb5kgle2iY2lWHgeV/KOqnBEpVnlMFigGJ/WW7KP9Nj6C/t53f/h5boYyVXB0bEhgpL+ctbewDJMI+zAMj1w==",
+ "resolved": "11.0.0",
+ "contentHash": "3eoaKF4Stat1PSN+KFwqmy04sM9DwGuHM1o1lHwuNFM/TqwQ+PCIvaQHS4lcT3kJl5rwvDK4w/rIlR0wc024eQ==",
"dependencies": {
- "Microsoft.Extensions.Configuration": "10.0.14",
- "Microsoft.Extensions.Configuration.Abstractions": "10.0.14"
+ "Microsoft.Extensions.Configuration": "11.0.0",
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0"
}
},
"Microsoft.Extensions.DependencyInjection": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "2LzcuVjemeXR+WdY9wGIr8iGb7fYsDAit+IScxXX2XJnX0b++mWcE/WO6fEGIqhdMfSQM2ZS5JGMHYZix7YXZg==",
+ "resolved": "11.0.0",
+ "contentHash": "KygQMITBDDPXw7+AAgdwQvVAaTXuDsc1iCAuvhO73ERxKX+d92cdbgZmpoYF7DIUq2hfs/yO2KD87uIreRy3MA==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.14"
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0"
}
},
"Microsoft.Extensions.DependencyInjection.Abstractions": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "QtpQzuSZVyTPCuHW058yCs9Nj0394uUkNyFHS813nOmK9UgUdBdaprJ5PPsBgsQIpxADTsTkbaMMonykem6qdw=="
+ "resolved": "11.0.0",
+ "contentHash": "a2c4Kp55miXT6G+DSb75pczXQJHgNMzPyZEyMxrrKxuQrgvctcDWJWD9fVe/uGbQdu4Z0c3B7AVKp1DXmD64nQ=="
},
"Microsoft.Extensions.DependencyInjection.AutoActivation": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "h/sovspxVmT2DTIbWORMG0Gi3zVcPQzNl3kbwtpo0LoUXYbe2+66wQqZYwaF2ZWKN8HDdHv5yoc7d0DbDBBlnA==",
+ "resolved": "11.0.1",
+ "contentHash": "OuVIF5TmsfonN2Fqmi2zlUtbFQNqQiflhgo/rh64ptrqYrB4wZLwKbXr/HzrQXMf+h3jIbWrjIdJFspGqcvuuQ==",
"dependencies": {
- "Microsoft.Extensions.Hosting.Abstractions": "10.0.13"
+ "Microsoft.Extensions.Hosting.Abstractions": "10.0.15"
}
},
"Microsoft.Extensions.Diagnostics": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "80VqW8eKxQaxBOLDNpLUdxOlxzWn/jqBSxNBCfD8GCjcshNDpFvUgKh8uvvZwvkfBbwmNPWPWHyy9F+RLd1dlQ==",
+ "resolved": "11.0.0",
+ "contentHash": "tX8piU+KbYHXIf5F70leczIWwtTkPKhyjRqjbo6D2uTA1PwrhcMD+Ls7rzqSMkx1U3osyrD4/kCrZeF13Lkgnw==",
"dependencies": {
- "Microsoft.Extensions.Configuration": "10.0.14",
- "Microsoft.Extensions.Diagnostics.Abstractions": "10.0.14",
- "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.14"
+ "Microsoft.Extensions.Configuration": "11.0.0",
+ "Microsoft.Extensions.Diagnostics.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "11.0.0"
}
},
"Microsoft.Extensions.Diagnostics.Abstractions": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "vm+PPso6vOwGeX52MdOPh6z/R6KHgxQUwqq7k7Jc9jhy2JOxO2KB4xfoJQBBp2Ni8M4zKgJ4r2a1dgrYG7+MKw==",
+ "resolved": "11.0.0",
+ "contentHash": "o188Hh1AqAI91K+R8eY3REW5HzofGastQk8OPLIy4uS8FnJo4Niok/X+HH/nHRO1ApsxW7q1yYFoHDpAZC36fA==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.14",
- "Microsoft.Extensions.Options": "10.0.14"
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0",
+ "System.Diagnostics.DiagnosticSource": "11.0.0"
}
},
"Microsoft.Extensions.Diagnostics.ExceptionSummarization": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "Dp/FaAPo3U9h3HsWT1dcdRRV//rm+MQF5iKpY/WxL5swwV+wZNE5eyJZ0kgy9Upl/kHz4ejpiLMloxDIuJaoJQ==",
+ "resolved": "11.0.1",
+ "contentHash": "mqqpmAFNRLa4cozN3RvT/T81k4aarwMc8xb8VVQgLqUE7AAoN/WWayZAvP+4hy9+KujP3dfn3taU06fZJPIbgA==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.13"
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15"
}
},
"Microsoft.Extensions.FileProviders.Abstractions": {
"type": "Transitive",
- "resolved": "10.0.13",
- "contentHash": "BZDwtN3uoWRghDi5lRRZPDjMMCg2Ds7J6YEYjqka/TLjqnzquEpXyvchrIMeoubwT1ns23ow6PPeAoBHJO81Rw==",
+ "resolved": "10.0.15",
+ "contentHash": "1RSYAUtJeb76m2T0u5BbvwKY3s+ge9fT3cj1odvo5Bm+frc7pU9RSeXeMIlYHV8GjpqLdv2neeeomz010yYL8A==",
"dependencies": {
- "Microsoft.Extensions.Primitives": "10.0.13"
+ "Microsoft.Extensions.Primitives": "10.0.15"
}
},
"Microsoft.Extensions.Hosting.Abstractions": {
"type": "Transitive",
- "resolved": "10.0.13",
- "contentHash": "zIrbe9vkIFXxW3mOApIOWXw+xMwX7Cgsptr3ZSlglJt4hW2qp4fB/JU1NHgAevteBNH4PicvU9DsFPHxlnnloA==",
+ "resolved": "10.0.15",
+ "contentHash": "s/JBiwR3F/vKRCbe6WO5b6t6or1ISaZ3rllchcw6/FSWZmK8s2fAzD7elrZo7592FnMD1fhGoG/wuJL1YYtVXw==",
"dependencies": {
- "Microsoft.Extensions.Configuration.Abstractions": "10.0.13",
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.13",
- "Microsoft.Extensions.Diagnostics.Abstractions": "10.0.13",
- "Microsoft.Extensions.FileProviders.Abstractions": "10.0.13",
- "Microsoft.Extensions.Logging.Abstractions": "10.0.13"
+ "Microsoft.Extensions.Configuration.Abstractions": "10.0.15",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Diagnostics.Abstractions": "10.0.15",
+ "Microsoft.Extensions.FileProviders.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.15"
}
},
"Microsoft.Extensions.Http.Diagnostics": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "iFcxcuMF/21LO+tDqDyzYVvokJUH03cNalmOJhmjyQSMV3dR4JAgcUBTV1iVH/yruC8wG2RNjvW0xcUgYqmrGg==",
+ "resolved": "11.0.1",
+ "contentHash": "mKHY0oFYL3fkAOhBNi2LqWPuEdUJ+HiF28KKUwBkQG2sgXAUdFDDqvJAfu2PcYgtAwsAtl58zuk4SElpPzbCvA==",
"dependencies": {
- "Microsoft.Extensions.Http": "10.0.13",
- "Microsoft.Extensions.Telemetry": "10.11.0"
+ "Microsoft.Extensions.Compliance.Redaction": "11.0.1",
+ "Microsoft.Extensions.Http": "10.0.15",
+ "Microsoft.Extensions.Telemetry": "11.0.1"
}
},
"Microsoft.Extensions.Logging": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "O2fXL6JmtkFwkigxS8fPTQpLXxGDjgZco5D+h88s++Cl0bDCs023PVkpNoifciJ+f30I82jnp8tpwF0wCLdFtA==",
+ "resolved": "11.0.0",
+ "contentHash": "zsse8MOgo0bj2KAEsSkg9WtNAfZbHbTlGeqfhy5PGozomM3zQM0XzumSQzQ0451IWNSJWLqYaSIQEpCi2j1sCA==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection": "10.0.14",
- "Microsoft.Extensions.Logging.Abstractions": "10.0.14",
- "Microsoft.Extensions.Options": "10.0.14"
+ "Microsoft.Extensions.DependencyInjection": "11.0.0",
+ "Microsoft.Extensions.Logging.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0"
}
},
"Microsoft.Extensions.Logging.Abstractions": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "SwcbEBtkECq3D2oywvHkm46fyrX9Dd2JPWphDnHUc2+cUWR1Mdo41atAjh/9iZjgQxuvbKfZKXqostT/LZfefA==",
+ "resolved": "11.0.0",
+ "contentHash": "MTMO2V1eT9Dm5VIpJGLNwIjAjoBErUlfuB+DEaZ0tb8J+Nf/Xlj8he5AztK9p1iOJPIyuBeOrVy2u/CSdsfzPw==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.14"
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "System.Diagnostics.DiagnosticSource": "11.0.0"
}
},
"Microsoft.Extensions.Logging.Configuration": {
"type": "Transitive",
- "resolved": "10.0.13",
- "contentHash": "OyYJOaE9WbBx1Hp+Dd2zrqeFM0JwH5M/x0VL6tNUv3V18vIAVpix8UjhvY9eW/iXpguEHy68JO/Z9YkBOwftIw==",
+ "resolved": "10.0.15",
+ "contentHash": "Km6Ml1/nu0T/f80Btonxf9CWmP/BXI84aJwC5fUbCxRArJ0lH++0ADQrjErZvsSIrKhusTkTSGBChKy2fYAF4w==",
"dependencies": {
- "Microsoft.Extensions.Configuration": "10.0.13",
- "Microsoft.Extensions.Configuration.Abstractions": "10.0.13",
- "Microsoft.Extensions.Configuration.Binder": "10.0.13",
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.13",
- "Microsoft.Extensions.Logging": "10.0.13",
- "Microsoft.Extensions.Logging.Abstractions": "10.0.13",
- "Microsoft.Extensions.Options": "10.0.13",
- "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.13"
+ "Microsoft.Extensions.Configuration": "10.0.15",
+ "Microsoft.Extensions.Configuration.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Configuration.Binder": "10.0.15",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Logging": "10.0.15",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Options": "10.0.15",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15"
}
},
"Microsoft.Extensions.ObjectPool": {
"type": "Transitive",
- "resolved": "10.0.13",
- "contentHash": "NX3bhcc0WitPKAVc9Zfi8jeEPClhfEmobUJM4a4bkWhJcBt5IWg6lCrItUoFy4whLjU+atXktURYCweQlR7wfg=="
+ "resolved": "10.0.15",
+ "contentHash": "kvd9eyRRQ+OEu9wik7GKgTS+7XnJ5XoOtSXJqmkJtVYV/S4gsBUrobYRSdNeBcb0ymef4L5Q9pZGiTxJ8jJfyQ=="
},
"Microsoft.Extensions.Options.ConfigurationExtensions": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "4wcIU0rE04ejEfCwHTftu9O8fgH6CRYCe+tseRapikUBn1Kic3QdO7ku22SwFyLrzdWGYPUZMEgv57ZYuuc5gA==",
+ "resolved": "11.0.0",
+ "contentHash": "s4JrxDPwxk8pE6LFVj+M5TrDHxOVIoCnQBy5lexs5uAYeggPYwAc/pSDNgVuZN14pCmZGCInygI/2ylCdLYShw==",
"dependencies": {
- "Microsoft.Extensions.Configuration.Abstractions": "10.0.14",
- "Microsoft.Extensions.Configuration.Binder": "10.0.14",
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.14",
- "Microsoft.Extensions.Options": "10.0.14",
- "Microsoft.Extensions.Primitives": "10.0.14"
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Configuration.Binder": "11.0.0",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0",
+ "Microsoft.Extensions.Primitives": "11.0.0"
}
},
"Microsoft.Extensions.Primitives": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "1bbZqqCJTPba3inTADExbp/9PsGVyvGOX3zr6tFr7ySCgVkX9Lpw7BV0TizktNItd3SsbUu1sQfSAYm1GZMoNw=="
+ "resolved": "11.0.0",
+ "contentHash": "HH2akbW2HeY/xeZJA5UceuQQX+1Pv/Kxrz/x4XPoH6wYDtgPIlBeOTZlQXlT+b50b1Ym/xfP+WJCX9FW4uLBXQ=="
},
"Microsoft.Extensions.Resilience": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "GbN7R2BOoZf3F7aK02nz9kWf6ttbvVzpw1orGG30VmrKTmRV6pasQOCfF2fjKXyHIMC/lAiBEYHCKjgf0OiGvQ==",
+ "resolved": "11.0.1",
+ "contentHash": "xgKof6iwAByZNrxWOa7Drk4A953L7U2HleTmx7EXE2Vf6j1crp4RsvNlIVsJMtHKf3ftGKd9gOhR3xES9vxUgg==",
"dependencies": {
- "Microsoft.Extensions.Diagnostics": "10.0.13",
- "Microsoft.Extensions.Diagnostics.ExceptionSummarization": "10.11.0",
- "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.13",
- "Microsoft.Extensions.Telemetry.Abstractions": "10.11.0",
+ "Microsoft.Extensions.Diagnostics": "10.0.15",
+ "Microsoft.Extensions.Diagnostics.ExceptionSummarization": "11.0.1",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15",
+ "Microsoft.Extensions.Telemetry.Abstractions": "11.0.1",
"Polly.Extensions": "8.4.2",
"Polly.RateLimiting": "8.4.2"
}
},
"Microsoft.Extensions.Telemetry": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "2meCfABvkLPtEBBwGzItIGnhrex1AEn2N+dHvxB5UoozeX/xTtBuUz5BRdjNI5oNgd5T31kC69WWw3BHDc9iZA==",
+ "resolved": "11.0.1",
+ "contentHash": "9uuA8entTC9m00m59h6CACSt4IQh9KknB+hPvCteXUTiG67lqJ8BI65fEUJSPSfT3ZDDi01Zg2aY5kRUvD4HPw==",
"dependencies": {
- "Microsoft.Extensions.AmbientMetadata.Application": "10.11.0",
- "Microsoft.Extensions.DependencyInjection.AutoActivation": "10.11.0",
- "Microsoft.Extensions.Logging.Configuration": "10.0.13",
- "Microsoft.Extensions.ObjectPool": "10.0.13",
- "Microsoft.Extensions.Telemetry.Abstractions": "10.11.0"
+ "Microsoft.Extensions.AmbientMetadata.Application": "11.0.1",
+ "Microsoft.Extensions.DependencyInjection.AutoActivation": "11.0.1",
+ "Microsoft.Extensions.Logging.Configuration": "10.0.15",
+ "Microsoft.Extensions.ObjectPool": "10.0.15",
+ "Microsoft.Extensions.Telemetry.Abstractions": "11.0.1"
}
},
"Microsoft.Extensions.Telemetry.Abstractions": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "FzcHRan/C2g5X5KD0kPlL4tTROFRpM8sqcXfOIi6FGLsw/d2yoOYMbLJ5hyb8N5QgOVW7e1TdwEN4zVUfcwfdw==",
+ "resolved": "11.0.1",
+ "contentHash": "qINZz4G01Wxumqd0hLr6YdzPa3s7jexQWN28EenaiJQnmKdsR9FnBaKENdRRElLc+A5bJKQ+jYw/WHG4ZpIyAg==",
"dependencies": {
- "Microsoft.Extensions.Compliance.Abstractions": "10.11.0",
- "Microsoft.Extensions.Logging.Abstractions": "10.0.13",
- "Microsoft.Extensions.ObjectPool": "10.0.13",
- "Microsoft.Extensions.Options": "10.0.13"
+ "Microsoft.Extensions.Compliance.Abstractions": "11.0.1",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.15",
+ "Microsoft.Extensions.ObjectPool": "10.0.15",
+ "Microsoft.Extensions.Options": "10.0.15"
}
},
- "Microsoft.SourceLink.Common": {
- "type": "Transitive",
- "resolved": "10.0.403",
- "contentHash": "SvzUeqFGrcQxlIgjmcoSGiV5UWcPa0NCTuH69/40uSDsSD/26c6p9cH7XLAxpn+I8+2Zhl1qp+WMugl0oOwBMg=="
- },
"Polly.Core": {
"type": "Transitive",
"resolved": "8.4.2",
@@ -295,10 +277,10 @@
"resolved": "0.57.2",
"contentHash": "Y1+u73shwP+JYHmrkdN6bSt2kaGBEAafhi2nrecczbXdFRey+k7J/WF9YPfcB0rqivv2S8fmif6FSBq9m/AFvw=="
},
- "System.IO.Hashing": {
+ "System.Diagnostics.DiagnosticSource": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "lVqovhCt3HlZe7ONG5ydaj6BYwYI004gldVfMMkJl/lR5ueeCtWNpW4nejOX75sPmzm8vXCxB69GqwHaYCnyUQ=="
+ "resolved": "11.0.0",
+ "contentHash": "+boRR9uSKiIPtFeRLGwO5xylhDF80xpwM+dmk5jgIqqeUKLbujGkGICMTKqQrBzKO6fIp8BU8DV6YZkQukqo3A=="
},
"System.Threading.RateLimiting": {
"type": "Transitive",
@@ -308,61 +290,61 @@
"dotbahn.common": {
"type": "Project",
"dependencies": {
- "Microsoft.Extensions.Http": "[10.0.14, )",
- "Microsoft.Extensions.Options": "[10.0.14, )"
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
}
},
"dotbahn.facilities": {
"type": "Project",
"dependencies": {
"DotBahn.Common": "[1.0.0, )",
- "Microsoft.Extensions.Http": "[10.0.14, )",
- "Microsoft.Extensions.Http.Resilience": "[10.11.0, )",
- "Microsoft.Extensions.Options": "[10.0.14, )"
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Http.Resilience": "[11.0.1, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
}
},
"dotbahn.stations": {
"type": "Project",
"dependencies": {
"DotBahn.Common": "[1.0.0, )",
- "Microsoft.Extensions.Http": "[10.0.14, )",
- "Microsoft.Extensions.Http.Resilience": "[10.11.0, )",
- "Microsoft.Extensions.Options": "[10.0.14, )"
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Http.Resilience": "[11.0.1, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
}
},
"Microsoft.Extensions.Http": {
"type": "CentralTransitive",
- "requested": "[10.0.14, )",
- "resolved": "10.0.14",
- "contentHash": "IDsXLGGz7nJMsqspWnErsP18WyAVf6V9Ixl4p47/8/95Jak3ZA1YWhQ0iesMVwubVhkVZGoO9m9ADUnK0m6HLw==",
+ "requested": "[11.0.0, )",
+ "resolved": "11.0.0",
+ "contentHash": "Pa5xJYtE5weFzv8sRwei1yvqCc05PareJABDtUSigzyj0xmrnG7ZU5VBy0hf5tgh7HN3/psGiOQouw5PLaQD8w==",
"dependencies": {
- "Microsoft.Extensions.Configuration.Abstractions": "10.0.14",
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.14",
- "Microsoft.Extensions.Diagnostics": "10.0.14",
- "Microsoft.Extensions.Logging": "10.0.14",
- "Microsoft.Extensions.Logging.Abstractions": "10.0.14",
- "Microsoft.Extensions.Options": "10.0.14"
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Diagnostics": "11.0.0",
+ "Microsoft.Extensions.Logging": "11.0.0",
+ "Microsoft.Extensions.Logging.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0"
}
},
"Microsoft.Extensions.Http.Resilience": {
"type": "CentralTransitive",
- "requested": "[10.11.0, )",
- "resolved": "10.11.0",
- "contentHash": "6/YEoPCcQLzExm4x4FH5c38JffbhkMaTtXsrDmYNozt9KRtdXK3TsDeuKSBZJno+41oIDGBONb2up0zCsuEERw==",
+ "requested": "[11.0.1, )",
+ "resolved": "11.0.1",
+ "contentHash": "5VawCrg+VgVT2hNurSSEWUnq0pvNoH+Zt82s5Wpl/8jdnmU8DpRlr+M3DcdtVgeBG7mRyk3GtSRbf8PB/HrL3w==",
"dependencies": {
- "Microsoft.Extensions.Http.Diagnostics": "10.11.0",
- "Microsoft.Extensions.ObjectPool": "10.0.13",
- "Microsoft.Extensions.Resilience": "10.11.0"
+ "Microsoft.Extensions.Http.Diagnostics": "11.0.1",
+ "Microsoft.Extensions.ObjectPool": "10.0.15",
+ "Microsoft.Extensions.Resilience": "11.0.1"
}
},
"Microsoft.Extensions.Options": {
"type": "CentralTransitive",
- "requested": "[10.0.14, )",
- "resolved": "10.0.14",
- "contentHash": "EeN/33S418m9oWEaZY4N5T+BNxtOqNTIFoFbIgBKwylh4OJPKIWFAzbIhpTdNbwUs26MhkmbLCAbdY+YCJ1dIQ==",
+ "requested": "[11.0.0, )",
+ "resolved": "11.0.0",
+ "contentHash": "AaNswJ3NqdNCNqQVlU7iTkvrrrzqrSSxkOC3bLlrwv/CPN7YRz3HoJk7o4ey5v6U8bOHocHsyYoJ7ihK1KUWyQ==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.14",
- "Microsoft.Extensions.Primitives": "10.0.14"
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Primitives": "11.0.0"
}
}
}
diff --git a/samples/DotBahn.Samples.TimetablePeek/DotBahn.Samples.TimetablePeek.csproj b/samples/DotBahn.Samples.TimetablePeek/DotBahn.Samples.TimetablePeek.csproj
index 3f18600..bf072ca 100644
--- a/samples/DotBahn.Samples.TimetablePeek/DotBahn.Samples.TimetablePeek.csproj
+++ b/samples/DotBahn.Samples.TimetablePeek/DotBahn.Samples.TimetablePeek.csproj
@@ -15,6 +15,6 @@
-
+
diff --git a/samples/DotBahn.Samples.TimetablePeek/Program.cs b/samples/DotBahn.Samples.TimetablePeek/Program.cs
index d4dd64c..9551866 100644
--- a/samples/DotBahn.Samples.TimetablePeek/Program.cs
+++ b/samples/DotBahn.Samples.TimetablePeek/Program.cs
@@ -1,14 +1,15 @@
using System.CommandLine;
using System.Diagnostics;
+using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
+using DotBahn.Boards;
+using DotBahn.Boards.Models;
+using DotBahn.Boards.Models.Entries;
using DotBahn.Common.Auth;
using DotBahn.Common.Clients;
-using DotBahn.Common.Models;
+using DotBahn.Samples.TimetablePeek;
using DotBahn.Telemetry;
-using DotBahn.Timetables;
-using DotBahn.Timetables.Models;
-using DotBahn.Timetables.Models.Enumerations;
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
@@ -16,314 +17,312 @@
return await TimetablePeekCli.BuildRootCommand().Parse(args).InvokeAsync();
-internal static class TimetablePeekCli {
- private static readonly Uri BaseEndpoint = new("https://apis.deutschebahn.com/db-api-marketplace/apis/timetables/v1/");
-
- private static readonly Argument EvaArgument = new("eva") {
- Description = "EVA station number (e.g. 8098160)",
- Arity = ArgumentArity.ZeroOrOne,
- };
-
- private static readonly Option CategoryOption = new("--category", "-c") {
- Description = "Train category to filter for (e.g. ICE, RB); defaults to all categories",
- };
-
- private static readonly Option LimitOption = new("--limit", "-n") {
- Description = "Maximum number of departures to show (1-100)",
- DefaultValueFactory = _ => 20,
- };
-
- private static readonly Option WindowOption = new("--window", "-w") {
- Description = "Look-ahead window for the timetable, in hours (1-24)",
- DefaultValueFactory = _ => 24,
- };
-
- private static readonly Option ClientIdOption = new("--client") {
- Description = "DB API client id; falls back to the DOTBAHN_CLIENT environment variable",
- };
-
- private static readonly Option SecretOption = new("--secret") {
- Description = "DB API secret; falls back to the DOTBAHN_SECRET environment variable",
- };
-
- private static readonly Option JsonOption = new("--json", "-j") {
- Description = "Print departures as JSON instead of a table",
- };
-
- internal static RootCommand BuildRootCommand() {
- var rootCommand = new RootCommand("Deutsche Bahn departure monitor showing the next departures at a station") {
- EvaArgument,
- CategoryOption,
- LimitOption,
- WindowOption,
- ClientIdOption,
- SecretOption,
- JsonOption,
+namespace DotBahn.Samples.TimetablePeek {
+ internal static class TimetablePeekCli {
+ private static readonly Uri BaseEndpoint = new("https://apis.deutschebahn.com/db-api-marketplace/apis/open-boards/v1/");
+
+ private static readonly Argument EvaArgument = new("eva") {
+ Description = "EVA station number (e.g. 8098160)",
+ Arity = ArgumentArity.ZeroOrOne
};
- rootCommand.Validators.Add(result => {
- var eva = result.GetValue(EvaArgument);
- if (string.IsNullOrWhiteSpace(eva)) {
- result.AddError("An EVA station number must be supplied: pass it as first argument (e.g. 8098160).");
- } else if (!int.TryParse(eva, out _)) {
- result.AddError("eva must be a numeric EVA station number (e.g. 8098160).");
- }
- });
+ private static readonly Option ArrivalsOption = new("--arrivals", "-a") {
+ Description = "Show arrivals instead of departures"
+ };
- CategoryOption.Validators.Add(result => {
- var category = result.GetValue(CategoryOption);
- if (category is { Length: 0 }) {
- result.AddError("--category must not be empty.");
- }
- });
-
- LimitOption.Validators.Add(result => {
- var limit = result.GetValue(LimitOption);
- if (limit < 1) {
- result.AddError("--limit must be at least 1.");
- } else if (limit > 100) {
- result.AddError("--limit must be at most 100.");
- }
- });
-
- WindowOption.Validators.Add(result => {
- var window = result.GetValue(WindowOption);
- if (window < 1) {
- result.AddError("--window must be at least 1.");
- } else if (window > 24) {
- result.AddError("--window must be at most 24.");
- }
- });
+ private static readonly Option CategoryOption = new("--category", "-c") {
+ Description = "Train category to filter for (e.g. ICE, RB); defaults to all categories"
+ };
- rootCommand.SetAction(async (parseResult, cancellationToken) => {
- var eva = parseResult.GetValue(EvaArgument);
- var category = parseResult.GetValue(CategoryOption);
- var limit = parseResult.GetValue(LimitOption);
- var window = parseResult.GetValue(WindowOption);
- var clientId = parseResult.GetValue(ClientIdOption);
- var secret = parseResult.GetValue(SecretOption);
- var json = parseResult.GetValue(JsonOption);
+ private static readonly Option LimitOption = new("--limit", "-n") {
+ Description = "Maximum number of entries to show (1-100)",
+ DefaultValueFactory = _ => 20
+ };
- return await RunAsync(eva, category, limit, window, clientId, secret, json, cancellationToken);
- });
+ private static readonly Option WindowOption = new("--window", "-w") {
+ Description = "Time window for the board, in hours (1-8)",
+ DefaultValueFactory = _ => 8
+ };
- return rootCommand;
- }
+ private static readonly Option ClientIdOption = new("--client") {
+ Description = "DB API client id; falls back to the DOTBAHN_CLIENT environment variable"
+ };
- private static async Task RunAsync(string? eva, string? category, int limit, int window, string? clientId, string? secret, bool json, CancellationToken cancellationToken) {
- if (!int.TryParse(eva, out var evaNumber)) {
- throw new UnreachableException("eva was validated but could not be parsed.");
- }
+ private static readonly Option SecretOption = new("--secret") {
+ Description = "DB API secret; falls back to the DOTBAHN_SECRET environment variable"
+ };
- if (!ResolveCredentials(clientId, secret, out var resolvedClientId, out var resolvedSecret)) {
- if (json) {
- WriteJsonError("missing-credentials", "Provide --client/--secret or set DOTBAHN_CLIENT and DOTBAHN_SECRET.");
- } else {
- AnsiConsole.MarkupLine("[red]Usage:[/] provide --client/--secret, or set DOTBAHN_CLIENT / DOTBAHN_SECRET via env or CLI args");
- }
- return 1;
- }
+ private static readonly Option JsonOption = new("--json", "-j") {
+ Description = "Print entries as JSON instead of a table"
+ };
- var services = new ServiceCollection();
- services.AddOpenTelemetry()
- .WithTracing(tracing => tracing.AddOtlpExporter())
- .WithMetrics(metrics => metrics.AddOtlpExporter());
- services.AddDotBahnTelemetry();
- await using var telemetry = services.BuildServiceProvider();
- _ = telemetry.GetRequiredService();
- _ = telemetry.GetRequiredService();
-
- using var client = new TimetableClient(
- new ClientOptions {
- BaseEndpoint = BaseEndpoint,
- },
- new AuthorizationOptions {
- ClientId = resolvedClientId,
- ApiKey = resolvedSecret,
+ internal static RootCommand BuildRootCommand() {
+ var rootCommand = new RootCommand("Deutsche Bahn arrival/departure board (OpenBoards API)") {
+ EvaArgument,
+ ArrivalsOption,
+ CategoryOption,
+ LimitOption,
+ WindowOption,
+ ClientIdOption,
+ SecretOption,
+ JsonOption
+ };
+
+ rootCommand.Validators.Add(result => {
+ var eva = result.GetValue(EvaArgument);
+ if (string.IsNullOrWhiteSpace(eva)) {
+ result.AddError("An EVA station number must be supplied: pass it as first argument (e.g. 8098160).");
+ } else if (!int.TryParse(eva, out _)) {
+ result.AddError("eva must be a numeric EVA station number (e.g. 8098160).");
+ }
});
- try {
- var (timetable, departures) = await FetchAsync(client, evaNumber, category, limit, window, cancellationToken);
-
- if (json) {
- var payload = new DeparturePayload(evaNumber, timetable.Station, [.. departures.Select(ToDepartureDto)]);
- Console.WriteLine(JsonSerializer.Serialize(payload, TimetablePeekJsonContext.Default.DeparturePayload));
- return departures.Count > 0 ? 0 : 1;
- }
+ CategoryOption.Validators.Add(result => {
+ var category = result.GetValue(CategoryOption);
+ if (category is { Length: 0 }) {
+ result.AddError("--category must not be empty.");
+ }
+ });
- AnsiConsole.Clear();
- RenderHeader(timetable.Station, evaNumber);
- if (departures.Count == 0) {
- AnsiConsole.MarkupLine("[yellow]No departures found.[/]");
- return 1;
- }
+ LimitOption.Validators.Add(result => {
+ var limit = result.GetValue(LimitOption);
+ if (limit < 1) {
+ result.AddError("--limit must be at least 1.");
+ } else if (limit > 100) {
+ result.AddError("--limit must be at most 100.");
+ }
+ });
- RenderDepartures(departures);
- return 0;
- } catch (OperationCanceledException) {
- return 130;
- } catch (HttpRequestException ex) {
- if (json) {
- WriteJsonError("api-error", ex.Message);
- } else {
- AnsiConsole.MarkupLine($"[red]Error:[/] {Markup.Escape(ex.Message)}");
- }
- return 1;
- }
- }
+ WindowOption.Validators.Add(result => {
+ var window = result.GetValue(WindowOption);
+ if (window < 1) {
+ result.AddError("--window must be at least 1.");
+ } else if (window > 8) {
+ result.AddError("--window must be at most 8 (API limit).");
+ }
+ });
- private static bool ResolveCredentials(string? clientId, string? secret, out string resolvedClientId, out string resolvedSecret) {
- _ = TryCredentialsFromEnvironment(out var envClient, out var envSecret);
- resolvedClientId = clientId ?? envClient;
- resolvedSecret = secret ?? envSecret;
- return !string.IsNullOrEmpty(resolvedClientId) && !string.IsNullOrEmpty(resolvedSecret);
- }
+ rootCommand.SetAction(async (parseResult, cancellationToken) => {
+ var eva = parseResult.GetValue(EvaArgument);
+ var arrivals = parseResult.GetValue(ArrivalsOption);
+ var category = parseResult.GetValue(CategoryOption);
+ var limit = parseResult.GetValue(LimitOption);
+ var window = parseResult.GetValue(WindowOption);
+ var clientId = parseResult.GetValue(ClientIdOption);
+ var secret = parseResult.GetValue(SecretOption);
+ var json = parseResult.GetValue(JsonOption);
+
+ return await RunAsync(eva, arrivals, category, limit, window, clientId, secret, json, cancellationToken);
+ });
- private static bool TryCredentialsFromEnvironment(out string clientId, out string clientSecret) {
- clientId = Environment.GetEnvironmentVariable("DOTBAHN_CLIENT") ?? string.Empty;
- clientSecret = Environment.GetEnvironmentVariable("DOTBAHN_SECRET") ?? string.Empty;
- return !string.IsNullOrEmpty(clientId) && !string.IsNullOrEmpty(clientSecret);
- }
+ return rootCommand;
+ }
- private static async Task LoadTimetableAsync(TimetableClient client, int eva, int window, CancellationToken cancellationToken) {
- var start = DateTime.Now;
- var stops = new Dictionary();
- Timetable? first = null;
+ private static async Task RunAsync(string? eva, bool arrivals, string? category, int limit, int window, string? clientId, string? secret, bool json, CancellationToken cancellationToken) {
+ if (!int.TryParse(eva, out var evaNumber)) {
+ throw new UnreachableException("eva was validated but could not be parsed.");
+ }
- for (var h = new DateTime(start.Year, start.Month, start.Day, start.Hour, 0, 0); h < start.AddHours(window); h = h.AddHours(1)) {
- var data = await client.GetTimetableAsync(eva, h, cancellationToken);
+ if (!ResolveCredentials(clientId, secret, out var resolvedClientId, out var resolvedSecret)) {
+ if (json) {
+ WriteJsonError("missing-credentials", "Provide --client/--secret or set DOTBAHN_CLIENT and DOTBAHN_SECRET.");
+ } else {
+ AnsiConsole.MarkupLine("[red]Usage:[/] provide --client/--secret, or set DOTBAHN_CLIENT / DOTBAHN_SECRET via env or CLI args");
+ }
+ return 1;
+ }
- first ??= data;
- foreach (var s in data.Stops) {
- stops[s.Id] = s;
+ var services = new ServiceCollection();
+ services.AddOpenTelemetry()
+ .WithTracing(tracing => tracing.AddOtlpExporter())
+ .WithMetrics(metrics => metrics.AddOtlpExporter());
+ services.AddDotBahnTelemetry();
+ await using var telemetry = services.BuildServiceProvider();
+ _ = telemetry.GetRequiredService();
+ _ = telemetry.GetRequiredService();
+
+ using var client = new BoardsClient(
+ new ClientOptions {
+ BaseEndpoint = BaseEndpoint
+ },
+ new AuthorizationOptions {
+ ClientId = resolvedClientId,
+ ApiKey = resolvedSecret
+ });
+
+ try {
+ var query = new BoardQuery()
+ .ForEvaNumbers(evaNumber.ToString(CultureInfo.InvariantCulture))
+ .StartingAt(DateTime.Now)
+ .EndingAt(DateTime.Now.AddHours(window))
+ .WithPlatformAccessibility();
+
+ var entries = new List();
+ string station;
+
+ if (arrivals) {
+ var board = await client.GetArrivalsAsync(query, cancellationToken);
+ station = BoardStation(board.ConsideredStopPlaces, evaNumber);
+ entries.AddRange(board.Entries
+ .Where(e => Matches(e.Transport.Category, category))
+ .Select(ToArrivalDto));
+ } else {
+ var board = await client.GetDeparturesAsync(query, cancellationToken);
+ station = BoardStation(board.ConsideredStopPlaces, evaNumber);
+ entries.AddRange(board.Entries
+ .Where(e => Matches(e.Transport.Category, category))
+ .Select(ToDepartureDto));
+ }
+
+ entries = entries
+ .Where(e => e.Actual >= DateTime.Now)
+ .OrderBy(e => e.Actual)
+ .Take(limit)
+ .ToList();
+
+ if (json) {
+ var payload = new BoardPayload(evaNumber, station, arrivals ? "arrivals" : "departures", entries);
+ Console.WriteLine(JsonSerializer.Serialize(payload, TimetablePeekJsonContext.Default.BoardPayload));
+ return entries.Count > 0 ? 0 : 1;
+ }
+
+ AnsiConsole.Clear();
+ RenderHeader(station, evaNumber, arrivals);
+ if (entries.Count == 0) {
+ AnsiConsole.MarkupLine($"[yellow]No {(arrivals ? "arrivals" : "departures")} found.[/]");
+ return 1;
+ }
+
+ RenderBoard(entries, arrivals);
+ return 0;
+ } catch (OperationCanceledException) {
+ return 130;
+ } catch (HttpRequestException ex) {
+ if (json) {
+ WriteJsonError("api-error", ex.Message);
+ } else {
+ AnsiConsole.MarkupLine($"[red]Error:[/] {Markup.Escape(ex.Message)}");
+ }
+ return 1;
}
}
- return new Timetable {
- Station = first?.Station ?? $"EVA {eva}",
- Stops = stops.Values,
- Messages = [],
- };
- }
-
- private static async Task<(Timetable Timetable, List Departures)> FetchAsync(TimetableClient client, int eva, string? category, int limit, int window, CancellationToken cancellationToken) {
- var timetable = await LoadTimetableAsync(client, eva, window, cancellationToken);
- timetable = await client.GetFullChangesAsync(eva, timetable, cancellationToken);
- return (timetable, SelectDepartures(timetable, category, limit));
- }
-
- private static List SelectDepartures(Timetable timetable, string? category, int limit) => timetable.Stops
- .Where(s => category is null || category.Equals(s.Train.Category, StringComparison.OrdinalIgnoreCase))
- .Where(s => s.Departure is { Status.Actual: not EventStatus.Cancelled })
- .Where(s => s.Departure!.Time.Actual >= DateTime.Now)
- .OrderBy(s => s.Departure!.Time.Actual)
- .Take(limit)
- .ToList();
-
- private static DepartureDto ToDepartureDto(TimetableStop stop) {
- var dep = stop.Departure!;
- return new DepartureDto(
- stop.Train.DisplayName,
- stop.Train.Category,
- dep.Time.Original,
- dep.Time.Actual,
- (int)(dep.Time.Actual - dep.Time.Original).TotalMinutes,
- dep.Platform.HasUpdate ? dep.Platform.Actual : dep.Platform.Original,
- dep.Path.Actual.LastOrDefault(),
- [.. dep.Path.Actual.SkipLast(1)]);
- }
-
- private static void WriteJsonError(string code, string message) {
- var payload = new ErrorPayload(new ErrorDto(code, message));
- Console.WriteLine(JsonSerializer.Serialize(payload, TimetablePeekJsonContext.Default.ErrorPayload));
- }
-
- private static void RenderHeader(string station, int eva) {
- AnsiConsole.Write(new Rule($"Departures \u2013 {Markup.Escape(station)}") {
- Justification = Justify.Center,
- });
- AnsiConsole.MarkupLine($"[grey]EVA {eva} | {DateTime.Now:HH:mm}[/]\n");
- }
-
- private static void RenderDepartures(List stops) {
- if (stops.Count == 0) {
- AnsiConsole.WriteLine("No departures found.");
- return;
+ private static bool Matches(string category, string? filter) =>
+ filter is null || filter.Equals(category, StringComparison.OrdinalIgnoreCase);
+
+ private static string BoardStation(IReadOnlyList stopPlaces, int eva) =>
+ stopPlaces.FirstOrDefault()?.Name ?? $"EVA {eva}";
+
+ private static BoardEntryDto ToArrivalDto(ArrivalEntry entry) => CreateDto(
+ entry, entry.Journey.Origin.StopPlace.Name);
+
+ private static BoardEntryDto ToDepartureDto(DepartureEntry entry) => CreateDto(
+ entry, entry.Journey.Destination.StopPlace.Name);
+
+ private static BoardEntryDto CreateDto(BoardEntry entry, string stationName) {
+ var time = entry.Time;
+ return new BoardEntryDto(
+ Train: $"{entry.Transport.Category} {entry.Transport.Number}",
+ Category: entry.Transport.Category,
+ Planned: time.Original,
+ Actual: time.Actual,
+ DelayMinutes: (int)(time.Actual - time.Original).TotalMinutes,
+ Platform: entry.Platform.Actual.Name,
+ Station: stationName,
+ Via: entry.Transport.Via
+ .Take(Math.Max(0, entry.Transport.Via.Count - 1))
+ .Select(v => v.StopPlace.Name)
+ .ToList());
}
- var table = new Table()
- .Border(TableBorder.Rounded)
- .BorderColor(Color.Grey)
- .AddColumn("[bold]Train[/]")
- .AddColumn("[bold]Departure[/]")
- .AddColumn("[bold]Platf.[/]")
- .AddColumn("[bold]Destination[/]")
- .AddColumn("[bold]Via[/]");
-
- foreach (var stop in stops) {
- var dep = stop.Departure!;
- table.AddRow(FormatTrain(stop.Train.DisplayName), FormatTime(dep.Time), FormatPlatform(dep.Platform), FormatDestination(dep.Path), FormatVia(dep.Path));
+ private static bool ResolveCredentials(string? clientId, string? secret, out string resolvedClientId, out string resolvedSecret) {
+ _ = TryCredentialsFromEnvironment(out var envClient, out var envSecret);
+ resolvedClientId = clientId ?? envClient;
+ resolvedSecret = secret ?? envSecret;
+ return !string.IsNullOrEmpty(resolvedClientId) && !string.IsNullOrEmpty(resolvedSecret);
}
- AnsiConsole.Write(table);
- AnsiConsole.MarkupLine($"[grey]Showing {stops.Count} departure(s)[/]\n");
- }
+ private static bool TryCredentialsFromEnvironment(out string clientId, out string clientSecret) {
+ clientId = Environment.GetEnvironmentVariable("DOTBAHN_CLIENT") ?? string.Empty;
+ clientSecret = Environment.GetEnvironmentVariable("DOTBAHN_SECRET") ?? string.Empty;
+ return !string.IsNullOrEmpty(clientId) && !string.IsNullOrEmpty(clientSecret);
+ }
- private static string FormatTrain(string trainName) => $"[bold]{Markup.Escape(trainName)}[/]";
+ private static void WriteJsonError(string code, string message) {
+ var payload = new ErrorPayload(new ErrorDto(code, message));
+ Console.WriteLine(JsonSerializer.Serialize(payload, TimetablePeekJsonContext.Default.ErrorPayload));
+ }
- private static string FormatTime(ChangedValue t) {
- var p = t.Original.ToString("HH:mm");
- if (!t.HasUpdate) {
- return $"[green]{p}[/]";
+ private static void RenderHeader(string station, int eva, bool arrivals) {
+ var title = arrivals ? "Arrivals" : "Departures";
+ AnsiConsole.Write(new Rule($"{title} \u2013 {Markup.Escape(station)}") {
+ Justification = Justify.Center
+ });
+ AnsiConsole.MarkupLine($"[grey]EVA {eva} | {DateTime.Now:HH:mm}[/]\n");
}
- var a = t.Actual.ToString("HH:mm");
- var d = (int)(t.Actual - t.Original).TotalMinutes;
- return d <= 0 ? $"[green]{a}[/]" : $"[strikethrough grey]{p}[/] [bold red]{a} (+{d})[/]";
- }
+ private static void RenderBoard(List entries, bool arrivals) {
+ var stationHeader = arrivals ? "[bold]Origin[/]" : "[bold]Destination[/]";
+ var table = new Table()
+ .Border(TableBorder.Rounded)
+ .BorderColor(Color.Grey)
+ .AddColumn("[bold]Train[/]")
+ .AddColumn(arrivals ? "[bold]Arrival[/]" : "[bold]Departure[/]")
+ .AddColumn("[bold]Platf.[/]")
+ .AddColumn(stationHeader)
+ .AddColumn("[bold]Via[/]");
+
+ foreach (var entry in entries) {
+ table.AddRow(
+ FormatTrain(entry.Train),
+ FormatTime(entry.Planned, entry.Actual, entry.DelayMinutes),
+ Markup.Escape(entry.Platform ?? "-"),
+ $"[bold]{Markup.Escape(entry.Station)}[/]",
+ FormatVia(entry.Via));
+ }
- private static string FormatPlatform(ChangedRef p) {
- if (!p.HasUpdate || p.Updated == p.Original) {
- return Markup.Escape(p.Original);
+ AnsiConsole.Write(table);
+ var label = arrivals ? "arrival(s)" : "departure(s)";
+ AnsiConsole.MarkupLine($"[grey]Showing {entries.Count} {label}[/]\n");
}
- return $"[strikethrough grey]{Markup.Escape(p.Original)}[/] [bold red]{Markup.Escape(p.Actual)}[/]";
- }
+ private static string FormatTrain(string trainName) => $"[bold]{Markup.Escape(trainName)}[/]";
+
+ private static string FormatTime(DateTime planned, DateTime actual, int delay) {
+ var p = planned.ToString("HH:mm", CultureInfo.InvariantCulture);
+ if (delay <= 0) {
+ return $"[green]{p}[/]";
+ }
- private static string FormatDestination(ChangedRef> p) {
- var planned = Markup.Escape(p.Original.LastOrDefault() ?? "-");
- var actual = Markup.Escape(p.Actual.LastOrDefault() ?? "-");
- if (!p.HasUpdate || planned == actual) {
- return $"[bold]{planned}[/]";
+ var a = actual.ToString("HH:mm", CultureInfo.InvariantCulture);
+ return $"[strikethrough grey]{p}[/] [bold red]{a} (+{delay})[/]";
}
- return $"[strikethrough grey]{planned}[/] [bold red]{actual}[/]";
- }
+ private static string FormatVia(IEnumerable stops) {
+ var list = stops.ToList();
+ if (list.Count == 0) {
+ return "[grey]-[/]";
+ }
- private static string FormatVia(ChangedRef> p) {
- var stops = p.Actual.ToList();
- if (stops.Count <= 1) {
- return "[grey]-[/]";
- }
+ var via = string.Join(" \u2013 ", list.Take(3).Select(Markup.Escape));
+ if (list.Count > 3) {
+ via += " \u2026";
+ }
- var via = string.Join(" \u2013 ", stops.Take(Math.Min(3, stops.Count - 1)).Select(Markup.Escape));
- if (stops.Count > 4) {
- via += " \u2026";
+ return $"[grey]{via}[/]";
}
-
- return p.HasUpdate ? $"[orange1]{via}[/]" : $"[grey]{via}[/]";
}
-}
-[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, WriteIndented = true)]
-[JsonSerializable(typeof(DeparturePayload))]
-[JsonSerializable(typeof(ErrorPayload))]
-internal sealed partial class TimetablePeekJsonContext : JsonSerializerContext;
+ [JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, WriteIndented = true)]
+ [JsonSerializable(typeof(BoardPayload))]
+ [JsonSerializable(typeof(ErrorPayload))]
+ internal sealed partial class TimetablePeekJsonContext : JsonSerializerContext;
-internal sealed record DeparturePayload(int Eva, string Station, IEnumerable Departures);
+ internal sealed record BoardPayload(int Eva, string Station, string Board, IEnumerable Entries);
-internal sealed record DepartureDto(string Train, string Category, DateTime Planned, DateTime Actual, int DelayMinutes, string? Platform, string? Destination, IEnumerable Via);
+ internal sealed record BoardEntryDto(string Train, string Category, DateTime Planned, DateTime Actual, int DelayMinutes, string? Platform, string Station, IEnumerable Via);
-internal sealed record ErrorPayload(ErrorDto Error);
+ internal sealed record ErrorPayload(ErrorDto Error);
-internal sealed record ErrorDto(string Code, string Message);
+ internal sealed record ErrorDto(string Code, string Message);
+}
diff --git a/samples/DotBahn.Samples.TimetablePeek/dbpeek.spec b/samples/DotBahn.Samples.TimetablePeek/dbpeek.spec
index ce03a6b..2d14934 100644
--- a/samples/DotBahn.Samples.TimetablePeek/dbpeek.spec
+++ b/samples/DotBahn.Samples.TimetablePeek/dbpeek.spec
@@ -1,7 +1,7 @@
Name: dbpeek
Version: %{?pkg_version}%{!?pkg_version:0.0.0}
Release: 0
-Summary: German railway departures monitor
+Summary: German railway arrival/departure board
License: MIT
URL: https://github.com/rlvelte/dotbahn
Source0: %{name}-%{version}.tar.gz
@@ -9,8 +9,8 @@ ExclusiveArch: x86_64
%define debug_package %{nil}
%description
-One-shot departures board for Deutsche Bahn timetable services,
-built with DotBahn (https://github.com/rlvelte/dotbahn).
+One-shot arrival and departure board for Deutsche Bahn, built with
+DotBahn (https://github.com/rlvelte/dotbahn) using the OpenBoards API.
%prep
%autosetup -n %{name}-%{version}
@@ -19,6 +19,7 @@ built with DotBahn (https://github.com/rlvelte/dotbahn).
%install
install -Dm755 dbpeek %{buildroot}%{_bindir}/dbpeek
+install -Dm644 bom.json %{buildroot}%{_datadir}/%{name}/bom.json
%check
:
@@ -26,7 +27,13 @@ install -Dm755 dbpeek %{buildroot}%{_bindir}/dbpeek
%files
%license LICENSE
%{_bindir}/dbpeek
+%{_datadir}/%{name}/bom.json
%changelog
+* Sun Nov 22 2026 Robin L. Velte - 2.2.0-0
+- Migrate to the new OpenBoards API (DotBahn.Boards)
+- Add arrivals mode (--arrivals/-a)
+- Support departure/arrival filtering by category, limit and time window
+- Cap --window to 8 hours per API limit
* Wed Oct 28 2026 Robin L. Velte - 2.1.1-0
- Initial package
diff --git a/samples/DotBahn.Samples.TimetablePeek/packages.lock.json b/samples/DotBahn.Samples.TimetablePeek/packages.lock.json
index e7ca0cc..e9a58bc 100644
--- a/samples/DotBahn.Samples.TimetablePeek/packages.lock.json
+++ b/samples/DotBahn.Samples.TimetablePeek/packages.lock.json
@@ -2,23 +2,6 @@
"version": 2,
"dependencies": {
"net10.0": {
- "Microsoft.NET.ILLink.Tasks": {
- "type": "Direct",
- "requested": "[10.0.14, )",
- "resolved": "10.0.14",
- "contentHash": "YlTamXppEQls6DYWt7RdUuwWDb0lyw/vXCaGeQpLCpsLmfwGuCkOz/vIGgMTV7ECsJcavkCOkxZXv9s8rdAHkQ=="
- },
- "Microsoft.SourceLink.GitHub": {
- "type": "Direct",
- "requested": "[10.0.403, )",
- "resolved": "10.0.403",
- "contentHash": "T4WYxWydJGNQRe/EgURFlhPZ1cHYgivrCCHSomCcfQzGzhkDYGNn5bUwwjs4/PHuMxsmGaLvPv2puG8lluA1IA==",
- "dependencies": {
- "Microsoft.Build.Tasks.Git": "10.0.403",
- "Microsoft.SourceLink.Common": "10.0.403",
- "System.IO.Hashing": "10.0.14"
- }
- },
"MinVer": {
"type": "Direct",
"requested": "[8.0.0, )",
@@ -27,21 +10,21 @@
},
"OpenTelemetry.Exporter.OpenTelemetryProtocol": {
"type": "Direct",
- "requested": "[1.20.1, )",
- "resolved": "1.20.1",
- "contentHash": "IlO8F0Y01ki0N5hJaeFJ5j3MVYJdbyNpDF9g7goU8wA3o8r/+ir9WJNnmte7QlUzM3iSV/aIuev1fqwF1CZOqg==",
+ "requested": "[1.21.0, )",
+ "resolved": "1.21.0",
+ "contentHash": "Xo/3lqiZhv+an00t5N9Jxt3U2vIOcY6/bu0wo5LiQrrRIwd/8dv9FdlIVB3k3ypiyG1VkbCXhWH1tiC48HQS4w==",
"dependencies": {
- "OpenTelemetry": "1.20.1"
+ "OpenTelemetry": "1.21.0"
}
},
"OpenTelemetry.Extensions.Hosting": {
"type": "Direct",
- "requested": "[1.20.1, )",
- "resolved": "1.20.1",
- "contentHash": "wnoK07COxyQBR47QwP80SIO4cpD2xeF4PrBDYFXDMnhDLmOP4nN0Szy1wCBLo5UABU1I4xwWRGzZM0bFdCbRog==",
+ "requested": "[1.21.0, )",
+ "resolved": "1.21.0",
+ "contentHash": "+cOZFDBLktHT8V/aUb2SXQVFNP5JrcX/F24TgHcbD2kd4SFcKlBMChYeU/K+Tg3nuL+4HAS7dcR7Y2+tcSnFbQ==",
"dependencies": {
"Microsoft.Extensions.Hosting.Abstractions": "10.0.0",
- "OpenTelemetry": "1.20.1"
+ "OpenTelemetry": "1.21.0"
}
},
"Spectre.Console": {
@@ -55,61 +38,62 @@
},
"System.CommandLine": {
"type": "Direct",
- "requested": "[2.0.14, )",
- "resolved": "2.0.14",
- "contentHash": "15fyVO4aG6poR6IKmhM74zf7PUzaU6FZAGm2d3SQSO9yIyGAeo44e6t9qeKjjaqyMEqYdqcb2G1B0gpLoDU2cA=="
+ "requested": "[3.0.0, )",
+ "resolved": "3.0.0",
+ "contentHash": "swNpSTl0iYJeBuvYYfaY+VxzZ5YC8wklwkqDCNOq2aTQqJzjauJfh/O3Zw93nwxspWrxvZTjT45f8VPR0ParEA=="
},
- "Microsoft.Build.Tasks.Git": {
+ "Microsoft.Extensions.AmbientMetadata.Application": {
"type": "Transitive",
- "resolved": "10.0.403",
- "contentHash": "1furteBFeemMmZ4s+ORjQb7YtO+wG63NJahbQbRUi91FV6V87BdV0U3vX1jbMC6iKSELYYoXWssSzLu3mx0i2w==",
+ "resolved": "11.0.1",
+ "contentHash": "tm28s2ODWZ6RdysP06NI3B23DUY5OfHG35ihMHxVAO3hywZAczDVjrkYMfBY//J4HQqfDHS5op84BhnF7ROseQ==",
"dependencies": {
- "System.IO.Hashing": "10.0.14"
+ "Microsoft.Extensions.Configuration": "10.0.15",
+ "Microsoft.Extensions.Hosting.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15"
}
},
- "Microsoft.Extensions.AmbientMetadata.Application": {
+ "Microsoft.Extensions.Compliance.Abstractions": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "aMCm7C6CexZT8W/p8zRp4BoxSnqRs3MmkBF7FvPIXC92b7vqs2SL0J+mVJi5W2Mk9Vb4ZRFWe9sdzFew6zUl1w==",
+ "resolved": "11.0.1",
+ "contentHash": "DUwdXgIxJKH9zBNg/SUBqOX0FpXCq7w80CIzrr0Jcw5tBXS926AtCcidoAsEHq5e/c6KQ8rWhSt7NxFxak8N/Q==",
"dependencies": {
- "Microsoft.Extensions.Configuration": "10.0.13",
- "Microsoft.Extensions.Hosting.Abstractions": "10.0.13",
- "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.13"
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15",
+ "Microsoft.Extensions.ObjectPool": "10.0.15"
}
},
- "Microsoft.Extensions.Compliance.Abstractions": {
+ "Microsoft.Extensions.Compliance.Redaction": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "2mjAb3Sm5k6uNeI+IyXpggYMpfdDDGgZSwUm9QQsm5QgZboJWbm2eU+6wNMrlfFEao11yq6JS1zXI7SVQQ0NuQ==",
+ "resolved": "11.0.1",
+ "contentHash": "2rwe98yZEn4+aXjAg5DdcROMg6m2w3tejf/mRk4/fBCHKM2EWCaFTmbHLtz1BfyBxMY00/08XFoN0wzWYNiSiQ==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.13",
- "Microsoft.Extensions.ObjectPool": "10.0.13"
+ "Microsoft.Extensions.Compliance.Abstractions": "11.0.1",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15"
}
},
"Microsoft.Extensions.Configuration": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "UcnvaEaMvRckDDhyqY1OZkFwBqpZArkHFKB6dWaQWT9XTuNttNNX8Cqsb/Sic2LfJxsMLJUXnYrxY3iX5LN9pQ==",
+ "resolved": "11.0.0",
+ "contentHash": "VQS/GkFU9oLQmXZv0AR/zluF0YAbEAoUQ5aYMqcRc2TWeKa6m2AjInAOnDhCcoWI5a6LQUCzTcl8B3DZZaPZLg==",
"dependencies": {
- "Microsoft.Extensions.Configuration.Abstractions": "10.0.14",
- "Microsoft.Extensions.Primitives": "10.0.14"
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Primitives": "11.0.0"
}
},
"Microsoft.Extensions.Configuration.Abstractions": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "4YdfvaoWn3tB1xQQHGrhRTFWJ8fGOqxThxduynSZy9ZFTiSaUi3vX4EK/kj8h2HQMwTlks9MWV1fv2WRBv5/1w==",
+ "resolved": "11.0.0",
+ "contentHash": "oyBSWnEsEi9SZTiwAfuKIdVIiEZ7TvNOtdFaGqyzF9WtomNV+uZHCqhQbnz/ipjtM50BYJ4s0MWbYafolq2mAg==",
"dependencies": {
- "Microsoft.Extensions.Primitives": "10.0.14"
+ "Microsoft.Extensions.Primitives": "11.0.0"
}
},
"Microsoft.Extensions.Configuration.Binder": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "brDb5kgle2iY2lWHgeV/KOqnBEpVnlMFigGJ/WW7KP9Nj6C/t53f/h5boYyVXB0bEhgpL+ctbewDJMI+zAMj1w==",
+ "resolved": "11.0.0",
+ "contentHash": "3eoaKF4Stat1PSN+KFwqmy04sM9DwGuHM1o1lHwuNFM/TqwQ+PCIvaQHS4lcT3kJl5rwvDK4w/rIlR0wc024eQ==",
"dependencies": {
- "Microsoft.Extensions.Configuration": "10.0.14",
- "Microsoft.Extensions.Configuration.Abstractions": "10.0.14"
+ "Microsoft.Extensions.Configuration": "11.0.0",
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0"
}
},
"Microsoft.Extensions.Configuration.EnvironmentVariables": {
@@ -123,181 +107,182 @@
},
"Microsoft.Extensions.DependencyInjection": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "2LzcuVjemeXR+WdY9wGIr8iGb7fYsDAit+IScxXX2XJnX0b++mWcE/WO6fEGIqhdMfSQM2ZS5JGMHYZix7YXZg==",
+ "resolved": "11.0.0",
+ "contentHash": "KygQMITBDDPXw7+AAgdwQvVAaTXuDsc1iCAuvhO73ERxKX+d92cdbgZmpoYF7DIUq2hfs/yO2KD87uIreRy3MA==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.14"
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0"
}
},
"Microsoft.Extensions.DependencyInjection.Abstractions": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "QtpQzuSZVyTPCuHW058yCs9Nj0394uUkNyFHS813nOmK9UgUdBdaprJ5PPsBgsQIpxADTsTkbaMMonykem6qdw=="
+ "resolved": "11.0.0",
+ "contentHash": "a2c4Kp55miXT6G+DSb75pczXQJHgNMzPyZEyMxrrKxuQrgvctcDWJWD9fVe/uGbQdu4Z0c3B7AVKp1DXmD64nQ=="
},
"Microsoft.Extensions.DependencyInjection.AutoActivation": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "h/sovspxVmT2DTIbWORMG0Gi3zVcPQzNl3kbwtpo0LoUXYbe2+66wQqZYwaF2ZWKN8HDdHv5yoc7d0DbDBBlnA==",
+ "resolved": "11.0.1",
+ "contentHash": "OuVIF5TmsfonN2Fqmi2zlUtbFQNqQiflhgo/rh64ptrqYrB4wZLwKbXr/HzrQXMf+h3jIbWrjIdJFspGqcvuuQ==",
"dependencies": {
- "Microsoft.Extensions.Hosting.Abstractions": "10.0.13"
+ "Microsoft.Extensions.Hosting.Abstractions": "10.0.15"
}
},
"Microsoft.Extensions.Diagnostics": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "80VqW8eKxQaxBOLDNpLUdxOlxzWn/jqBSxNBCfD8GCjcshNDpFvUgKh8uvvZwvkfBbwmNPWPWHyy9F+RLd1dlQ==",
+ "resolved": "11.0.0",
+ "contentHash": "tX8piU+KbYHXIf5F70leczIWwtTkPKhyjRqjbo6D2uTA1PwrhcMD+Ls7rzqSMkx1U3osyrD4/kCrZeF13Lkgnw==",
"dependencies": {
- "Microsoft.Extensions.Configuration": "10.0.14",
- "Microsoft.Extensions.Diagnostics.Abstractions": "10.0.14",
- "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.14"
+ "Microsoft.Extensions.Configuration": "11.0.0",
+ "Microsoft.Extensions.Diagnostics.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "11.0.0"
}
},
"Microsoft.Extensions.Diagnostics.Abstractions": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "vm+PPso6vOwGeX52MdOPh6z/R6KHgxQUwqq7k7Jc9jhy2JOxO2KB4xfoJQBBp2Ni8M4zKgJ4r2a1dgrYG7+MKw==",
+ "resolved": "11.0.0",
+ "contentHash": "o188Hh1AqAI91K+R8eY3REW5HzofGastQk8OPLIy4uS8FnJo4Niok/X+HH/nHRO1ApsxW7q1yYFoHDpAZC36fA==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.14",
- "Microsoft.Extensions.Options": "10.0.14"
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0",
+ "System.Diagnostics.DiagnosticSource": "11.0.0"
}
},
"Microsoft.Extensions.Diagnostics.ExceptionSummarization": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "Dp/FaAPo3U9h3HsWT1dcdRRV//rm+MQF5iKpY/WxL5swwV+wZNE5eyJZ0kgy9Upl/kHz4ejpiLMloxDIuJaoJQ==",
+ "resolved": "11.0.1",
+ "contentHash": "mqqpmAFNRLa4cozN3RvT/T81k4aarwMc8xb8VVQgLqUE7AAoN/WWayZAvP+4hy9+KujP3dfn3taU06fZJPIbgA==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.13"
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15"
}
},
"Microsoft.Extensions.FileProviders.Abstractions": {
"type": "Transitive",
- "resolved": "10.0.13",
- "contentHash": "BZDwtN3uoWRghDi5lRRZPDjMMCg2Ds7J6YEYjqka/TLjqnzquEpXyvchrIMeoubwT1ns23ow6PPeAoBHJO81Rw==",
+ "resolved": "10.0.15",
+ "contentHash": "1RSYAUtJeb76m2T0u5BbvwKY3s+ge9fT3cj1odvo5Bm+frc7pU9RSeXeMIlYHV8GjpqLdv2neeeomz010yYL8A==",
"dependencies": {
- "Microsoft.Extensions.Primitives": "10.0.13"
+ "Microsoft.Extensions.Primitives": "10.0.15"
}
},
"Microsoft.Extensions.Hosting.Abstractions": {
"type": "Transitive",
- "resolved": "10.0.13",
- "contentHash": "zIrbe9vkIFXxW3mOApIOWXw+xMwX7Cgsptr3ZSlglJt4hW2qp4fB/JU1NHgAevteBNH4PicvU9DsFPHxlnnloA==",
+ "resolved": "10.0.15",
+ "contentHash": "s/JBiwR3F/vKRCbe6WO5b6t6or1ISaZ3rllchcw6/FSWZmK8s2fAzD7elrZo7592FnMD1fhGoG/wuJL1YYtVXw==",
"dependencies": {
- "Microsoft.Extensions.Configuration.Abstractions": "10.0.13",
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.13",
- "Microsoft.Extensions.Diagnostics.Abstractions": "10.0.13",
- "Microsoft.Extensions.FileProviders.Abstractions": "10.0.13",
- "Microsoft.Extensions.Logging.Abstractions": "10.0.13"
+ "Microsoft.Extensions.Configuration.Abstractions": "10.0.15",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Diagnostics.Abstractions": "10.0.15",
+ "Microsoft.Extensions.FileProviders.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.15"
}
},
"Microsoft.Extensions.Http.Diagnostics": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "iFcxcuMF/21LO+tDqDyzYVvokJUH03cNalmOJhmjyQSMV3dR4JAgcUBTV1iVH/yruC8wG2RNjvW0xcUgYqmrGg==",
+ "resolved": "11.0.1",
+ "contentHash": "mKHY0oFYL3fkAOhBNi2LqWPuEdUJ+HiF28KKUwBkQG2sgXAUdFDDqvJAfu2PcYgtAwsAtl58zuk4SElpPzbCvA==",
"dependencies": {
- "Microsoft.Extensions.Http": "10.0.13",
- "Microsoft.Extensions.Telemetry": "10.11.0"
+ "Microsoft.Extensions.Compliance.Redaction": "11.0.1",
+ "Microsoft.Extensions.Http": "10.0.15",
+ "Microsoft.Extensions.Telemetry": "11.0.1"
}
},
"Microsoft.Extensions.Logging": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "O2fXL6JmtkFwkigxS8fPTQpLXxGDjgZco5D+h88s++Cl0bDCs023PVkpNoifciJ+f30I82jnp8tpwF0wCLdFtA==",
+ "resolved": "11.0.0",
+ "contentHash": "zsse8MOgo0bj2KAEsSkg9WtNAfZbHbTlGeqfhy5PGozomM3zQM0XzumSQzQ0451IWNSJWLqYaSIQEpCi2j1sCA==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection": "10.0.14",
- "Microsoft.Extensions.Logging.Abstractions": "10.0.14",
- "Microsoft.Extensions.Options": "10.0.14"
+ "Microsoft.Extensions.DependencyInjection": "11.0.0",
+ "Microsoft.Extensions.Logging.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0"
}
},
"Microsoft.Extensions.Logging.Abstractions": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "SwcbEBtkECq3D2oywvHkm46fyrX9Dd2JPWphDnHUc2+cUWR1Mdo41atAjh/9iZjgQxuvbKfZKXqostT/LZfefA==",
+ "resolved": "11.0.0",
+ "contentHash": "MTMO2V1eT9Dm5VIpJGLNwIjAjoBErUlfuB+DEaZ0tb8J+Nf/Xlj8he5AztK9p1iOJPIyuBeOrVy2u/CSdsfzPw==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.14"
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "System.Diagnostics.DiagnosticSource": "11.0.0"
}
},
"Microsoft.Extensions.Logging.Configuration": {
"type": "Transitive",
- "resolved": "10.0.13",
- "contentHash": "OyYJOaE9WbBx1Hp+Dd2zrqeFM0JwH5M/x0VL6tNUv3V18vIAVpix8UjhvY9eW/iXpguEHy68JO/Z9YkBOwftIw==",
+ "resolved": "10.0.15",
+ "contentHash": "Km6Ml1/nu0T/f80Btonxf9CWmP/BXI84aJwC5fUbCxRArJ0lH++0ADQrjErZvsSIrKhusTkTSGBChKy2fYAF4w==",
"dependencies": {
- "Microsoft.Extensions.Configuration": "10.0.13",
- "Microsoft.Extensions.Configuration.Abstractions": "10.0.13",
- "Microsoft.Extensions.Configuration.Binder": "10.0.13",
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.13",
- "Microsoft.Extensions.Logging": "10.0.13",
- "Microsoft.Extensions.Logging.Abstractions": "10.0.13",
- "Microsoft.Extensions.Options": "10.0.13",
- "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.13"
+ "Microsoft.Extensions.Configuration": "10.0.15",
+ "Microsoft.Extensions.Configuration.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Configuration.Binder": "10.0.15",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Logging": "10.0.15",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Options": "10.0.15",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15"
}
},
"Microsoft.Extensions.ObjectPool": {
"type": "Transitive",
- "resolved": "10.0.13",
- "contentHash": "NX3bhcc0WitPKAVc9Zfi8jeEPClhfEmobUJM4a4bkWhJcBt5IWg6lCrItUoFy4whLjU+atXktURYCweQlR7wfg=="
+ "resolved": "10.0.15",
+ "contentHash": "kvd9eyRRQ+OEu9wik7GKgTS+7XnJ5XoOtSXJqmkJtVYV/S4gsBUrobYRSdNeBcb0ymef4L5Q9pZGiTxJ8jJfyQ=="
},
"Microsoft.Extensions.Options.ConfigurationExtensions": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "4wcIU0rE04ejEfCwHTftu9O8fgH6CRYCe+tseRapikUBn1Kic3QdO7ku22SwFyLrzdWGYPUZMEgv57ZYuuc5gA==",
+ "resolved": "11.0.0",
+ "contentHash": "s4JrxDPwxk8pE6LFVj+M5TrDHxOVIoCnQBy5lexs5uAYeggPYwAc/pSDNgVuZN14pCmZGCInygI/2ylCdLYShw==",
"dependencies": {
- "Microsoft.Extensions.Configuration.Abstractions": "10.0.14",
- "Microsoft.Extensions.Configuration.Binder": "10.0.14",
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.14",
- "Microsoft.Extensions.Options": "10.0.14",
- "Microsoft.Extensions.Primitives": "10.0.14"
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Configuration.Binder": "11.0.0",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0",
+ "Microsoft.Extensions.Primitives": "11.0.0"
}
},
"Microsoft.Extensions.Primitives": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "1bbZqqCJTPba3inTADExbp/9PsGVyvGOX3zr6tFr7ySCgVkX9Lpw7BV0TizktNItd3SsbUu1sQfSAYm1GZMoNw=="
+ "resolved": "11.0.0",
+ "contentHash": "HH2akbW2HeY/xeZJA5UceuQQX+1Pv/Kxrz/x4XPoH6wYDtgPIlBeOTZlQXlT+b50b1Ym/xfP+WJCX9FW4uLBXQ=="
},
"Microsoft.Extensions.Resilience": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "GbN7R2BOoZf3F7aK02nz9kWf6ttbvVzpw1orGG30VmrKTmRV6pasQOCfF2fjKXyHIMC/lAiBEYHCKjgf0OiGvQ==",
+ "resolved": "11.0.1",
+ "contentHash": "xgKof6iwAByZNrxWOa7Drk4A953L7U2HleTmx7EXE2Vf6j1crp4RsvNlIVsJMtHKf3ftGKd9gOhR3xES9vxUgg==",
"dependencies": {
- "Microsoft.Extensions.Diagnostics": "10.0.13",
- "Microsoft.Extensions.Diagnostics.ExceptionSummarization": "10.11.0",
- "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.13",
- "Microsoft.Extensions.Telemetry.Abstractions": "10.11.0",
+ "Microsoft.Extensions.Diagnostics": "10.0.15",
+ "Microsoft.Extensions.Diagnostics.ExceptionSummarization": "11.0.1",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15",
+ "Microsoft.Extensions.Telemetry.Abstractions": "11.0.1",
"Polly.Extensions": "8.4.2",
"Polly.RateLimiting": "8.4.2"
}
},
"Microsoft.Extensions.Telemetry": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "2meCfABvkLPtEBBwGzItIGnhrex1AEn2N+dHvxB5UoozeX/xTtBuUz5BRdjNI5oNgd5T31kC69WWw3BHDc9iZA==",
+ "resolved": "11.0.1",
+ "contentHash": "9uuA8entTC9m00m59h6CACSt4IQh9KknB+hPvCteXUTiG67lqJ8BI65fEUJSPSfT3ZDDi01Zg2aY5kRUvD4HPw==",
"dependencies": {
- "Microsoft.Extensions.AmbientMetadata.Application": "10.11.0",
- "Microsoft.Extensions.DependencyInjection.AutoActivation": "10.11.0",
- "Microsoft.Extensions.Logging.Configuration": "10.0.13",
- "Microsoft.Extensions.ObjectPool": "10.0.13",
- "Microsoft.Extensions.Telemetry.Abstractions": "10.11.0"
+ "Microsoft.Extensions.AmbientMetadata.Application": "11.0.1",
+ "Microsoft.Extensions.DependencyInjection.AutoActivation": "11.0.1",
+ "Microsoft.Extensions.Logging.Configuration": "10.0.15",
+ "Microsoft.Extensions.ObjectPool": "10.0.15",
+ "Microsoft.Extensions.Telemetry.Abstractions": "11.0.1"
}
},
"Microsoft.Extensions.Telemetry.Abstractions": {
"type": "Transitive",
- "resolved": "10.11.0",
- "contentHash": "FzcHRan/C2g5X5KD0kPlL4tTROFRpM8sqcXfOIi6FGLsw/d2yoOYMbLJ5hyb8N5QgOVW7e1TdwEN4zVUfcwfdw==",
+ "resolved": "11.0.1",
+ "contentHash": "qINZz4G01Wxumqd0hLr6YdzPa3s7jexQWN28EenaiJQnmKdsR9FnBaKENdRRElLc+A5bJKQ+jYw/WHG4ZpIyAg==",
"dependencies": {
- "Microsoft.Extensions.Compliance.Abstractions": "10.11.0",
- "Microsoft.Extensions.Logging.Abstractions": "10.0.13",
- "Microsoft.Extensions.ObjectPool": "10.0.13",
- "Microsoft.Extensions.Options": "10.0.13"
+ "Microsoft.Extensions.Compliance.Abstractions": "11.0.1",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.15",
+ "Microsoft.Extensions.ObjectPool": "10.0.15",
+ "Microsoft.Extensions.Options": "10.0.15"
}
},
- "Microsoft.SourceLink.Common": {
- "type": "Transitive",
- "resolved": "10.0.403",
- "contentHash": "SvzUeqFGrcQxlIgjmcoSGiV5UWcPa0NCTuH69/40uSDsSD/26c6p9cH7XLAxpn+I8+2Zhl1qp+WMugl0oOwBMg=="
- },
"OpenTelemetry.Api": {
"type": "Transitive",
- "resolved": "1.20.1",
- "contentHash": "QO9hlwadOdJGR4vDpJyDnl9B62v7epIBSTIHUA4C+bCtrRaB4TWmYSnu3QVOIe7caH8dt7NaHRei6zebESJJyw=="
+ "resolved": "1.21.0",
+ "contentHash": "KptD6ThegQORUzwot75zW2AUH6IDyKXH1R2yhovJPYfrzqSgHQidMfVfKLjaYEnJa5ySQgQm0RjuM6X+TCJ9yw==",
+ "dependencies": {
+ "System.Diagnostics.DiagnosticSource": "11.0.0"
+ }
},
"Polly.Core": {
"type": "Transitive",
@@ -328,94 +313,94 @@
"resolved": "0.57.2",
"contentHash": "Y1+u73shwP+JYHmrkdN6bSt2kaGBEAafhi2nrecczbXdFRey+k7J/WF9YPfcB0rqivv2S8fmif6FSBq9m/AFvw=="
},
- "System.IO.Hashing": {
+ "System.Diagnostics.DiagnosticSource": {
"type": "Transitive",
- "resolved": "10.0.14",
- "contentHash": "lVqovhCt3HlZe7ONG5ydaj6BYwYI004gldVfMMkJl/lR5ueeCtWNpW4nejOX75sPmzm8vXCxB69GqwHaYCnyUQ=="
+ "resolved": "11.0.0",
+ "contentHash": "+boRR9uSKiIPtFeRLGwO5xylhDF80xpwM+dmk5jgIqqeUKLbujGkGICMTKqQrBzKO6fIp8BU8DV6YZkQukqo3A=="
},
"System.Threading.RateLimiting": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "7mu9v0QDv66ar3DpGSZHg9NuNcxDaaAcnMULuZlaTpP9+hwXhrxNGsF5GmLkSHxFdb5bBc1TzeujsRgTrPWi+Q=="
},
- "dotbahn.common": {
+ "dotbahn.boards": {
"type": "Project",
"dependencies": {
- "Microsoft.Extensions.Http": "[10.0.14, )",
- "Microsoft.Extensions.Options": "[10.0.14, )"
+ "DotBahn.Common": "[1.0.0, )",
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Http.Resilience": "[11.0.1, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
}
},
- "dotbahn.telemetry": {
+ "dotbahn.common": {
"type": "Project",
"dependencies": {
- "DotBahn.Common": "[1.0.0, )",
- "OpenTelemetry.Api.ProviderBuilderExtensions": "[1.20.1, )"
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
}
},
- "dotbahn.timetables": {
+ "dotbahn.telemetry": {
"type": "Project",
"dependencies": {
"DotBahn.Common": "[1.0.0, )",
- "Microsoft.Extensions.Http": "[10.0.14, )",
- "Microsoft.Extensions.Http.Resilience": "[10.11.0, )",
- "Microsoft.Extensions.Options": "[10.0.14, )"
+ "OpenTelemetry.Api.ProviderBuilderExtensions": "[1.21.0, )"
}
},
"Microsoft.Extensions.Http": {
"type": "CentralTransitive",
- "requested": "[10.0.14, )",
- "resolved": "10.0.14",
- "contentHash": "IDsXLGGz7nJMsqspWnErsP18WyAVf6V9Ixl4p47/8/95Jak3ZA1YWhQ0iesMVwubVhkVZGoO9m9ADUnK0m6HLw==",
+ "requested": "[11.0.0, )",
+ "resolved": "11.0.0",
+ "contentHash": "Pa5xJYtE5weFzv8sRwei1yvqCc05PareJABDtUSigzyj0xmrnG7ZU5VBy0hf5tgh7HN3/psGiOQouw5PLaQD8w==",
"dependencies": {
- "Microsoft.Extensions.Configuration.Abstractions": "10.0.14",
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.14",
- "Microsoft.Extensions.Diagnostics": "10.0.14",
- "Microsoft.Extensions.Logging": "10.0.14",
- "Microsoft.Extensions.Logging.Abstractions": "10.0.14",
- "Microsoft.Extensions.Options": "10.0.14"
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Diagnostics": "11.0.0",
+ "Microsoft.Extensions.Logging": "11.0.0",
+ "Microsoft.Extensions.Logging.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0"
}
},
"Microsoft.Extensions.Http.Resilience": {
"type": "CentralTransitive",
- "requested": "[10.11.0, )",
- "resolved": "10.11.0",
- "contentHash": "6/YEoPCcQLzExm4x4FH5c38JffbhkMaTtXsrDmYNozt9KRtdXK3TsDeuKSBZJno+41oIDGBONb2up0zCsuEERw==",
+ "requested": "[11.0.1, )",
+ "resolved": "11.0.1",
+ "contentHash": "5VawCrg+VgVT2hNurSSEWUnq0pvNoH+Zt82s5Wpl/8jdnmU8DpRlr+M3DcdtVgeBG7mRyk3GtSRbf8PB/HrL3w==",
"dependencies": {
- "Microsoft.Extensions.Http.Diagnostics": "10.11.0",
- "Microsoft.Extensions.ObjectPool": "10.0.13",
- "Microsoft.Extensions.Resilience": "10.11.0"
+ "Microsoft.Extensions.Http.Diagnostics": "11.0.1",
+ "Microsoft.Extensions.ObjectPool": "10.0.15",
+ "Microsoft.Extensions.Resilience": "11.0.1"
}
},
"Microsoft.Extensions.Options": {
"type": "CentralTransitive",
- "requested": "[10.0.14, )",
- "resolved": "10.0.14",
- "contentHash": "EeN/33S418m9oWEaZY4N5T+BNxtOqNTIFoFbIgBKwylh4OJPKIWFAzbIhpTdNbwUs26MhkmbLCAbdY+YCJ1dIQ==",
+ "requested": "[11.0.0, )",
+ "resolved": "11.0.0",
+ "contentHash": "AaNswJ3NqdNCNqQVlU7iTkvrrrzqrSSxkOC3bLlrwv/CPN7YRz3HoJk7o4ey5v6U8bOHocHsyYoJ7ihK1KUWyQ==",
"dependencies": {
- "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.14",
- "Microsoft.Extensions.Primitives": "10.0.14"
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Primitives": "11.0.0"
}
},
"OpenTelemetry": {
"type": "CentralTransitive",
- "requested": "[1.20.1, )",
- "resolved": "1.20.1",
- "contentHash": "+XDw3fYbiv1a40aFnDJSQleeuUJciXuhoIA19XmcGhT47Hy/xZRqk8NCjHUDKrg72Ixjthicecp8ygBDNeH/Jw==",
+ "requested": "[1.21.0, )",
+ "resolved": "1.21.0",
+ "contentHash": "ynAzNO/ebDTPxARbz4z/HgL8azMk/iDk4GXFuIRQ6krr1+a5QMC4eoiXRl+e7COd+3RLyL/yTuE6bevwqbv4Bw==",
"dependencies": {
"Microsoft.Extensions.Configuration.EnvironmentVariables": "10.0.0",
"Microsoft.Extensions.Diagnostics.Abstractions": "10.0.0",
"Microsoft.Extensions.Logging.Configuration": "10.0.0",
- "OpenTelemetry.Api.ProviderBuilderExtensions": "1.20.1"
+ "OpenTelemetry.Api.ProviderBuilderExtensions": "1.21.0"
}
},
"OpenTelemetry.Api.ProviderBuilderExtensions": {
"type": "CentralTransitive",
- "requested": "[1.20.1, )",
- "resolved": "1.20.1",
- "contentHash": "eDzDY/jTBqRytkYECmVKF7ZP5sKmCIqv1SSnA5BSWltIIvc3931TOMRyCW1qCGNIgmtldtJhISnsmFNxOCfauQ==",
+ "requested": "[1.21.0, )",
+ "resolved": "1.21.0",
+ "contentHash": "ZcBCBTGbzjj8Y+9UnZKbSjnRyKc2ub2IvvU68fFHKmyKzTS4hU+4/f0PO1GoIf7FTYLKTyw+l/EwLL/PPIDkxg==",
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.0",
- "OpenTelemetry.Api": "1.20.1"
+ "OpenTelemetry.Api": "1.21.0"
}
}
}
diff --git a/scripts/publish.ps1 b/scripts/publish.ps1
index 551e9f1..98556f5 100644
--- a/scripts/publish.ps1
+++ b/scripts/publish.ps1
@@ -1,4 +1,6 @@
+# Publishes all CSPROJ marked as executable in the 'SAMPLES_DIR' as binaries.
$ErrorActionPreference = 'Stop'
+
$root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
Set-Location $root
@@ -12,7 +14,7 @@ function Get-Rid {
} elseif ([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Linux)) {
'linux'
} else {
- throw "unsupported OS"
+ throw "unsupported os"
}
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
@@ -21,6 +23,7 @@ function Get-Rid {
'Arm64' { 'arm64' }
default { 'x64' }
}
+
return "$os-$archName"
}
@@ -29,11 +32,16 @@ $rid = Get-Rid
foreach ($projectDir in Get-ChildItem (Join-Path $root $samplesDir) -Directory) {
$csprojs = Get-ChildItem -Path (Join-Path $projectDir.FullName '*.csproj') -File
foreach ($csproj in $csprojs) {
- if (-not (Select-String -Path $csproj.FullName -Pattern 'Exe' -Quiet)) { continue }
+ if (-not (Select-String -Path $csproj.FullName -Pattern 'Exe' -Quiet)) {
+ continue
+ }
+
$name = $csproj.BaseName
$projectPath = $csproj.Directory.FullName
+
$source = Join-Path $projectPath "bin/$configuration/net10.0/$rid/publish"
$out = Join-Path $root "$publishDir/$rid/$name"
+
New-Item -ItemType Directory -Force -Path $out | Out-Null
dotnet publish $csproj.FullName `
@@ -42,10 +50,13 @@ foreach ($projectDir in Get-ChildItem (Join-Path $root $samplesDir) -Directory)
--self-contained `
-p:PublishAot=true `
-p:StripSymbols=true `
+ -p:NuGetLockFilePath=obj/aot.lock.json `
--verbosity minimal
- if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
+
+ if ($LASTEXITCODE -ne 0) {
+ exit $LASTEXITCODE
+ }
Copy-Item -Path (Join-Path $source '*') -Destination $out -Force
- Write-Host "published: $out"
}
}
diff --git a/scripts/publish.sh b/scripts/publish.sh
index ae59c58..dc42a7b 100755
--- a/scripts/publish.sh
+++ b/scripts/publish.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+# Publishes all '*.csproj' marked as executable in the 'SAMPLES_DIR' as binaries.
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -12,8 +12,8 @@ detect_rid() {
local os arch
case "$(uname -s)" in
Linux*) os=linux ;;
- MINGW*|MSYS*|CYGWIN*) os=win ;;
- *) echo "unsupported OS: $(uname -s)" >&2; exit 1 ;;
+ MINGW*|MSYS*|CYGWIN*) os=win ;; # really need this?
+ *) echo "unsupported os: $(uname -s)" >&2; exit 1 ;;
esac
case "$(uname -m)" in
x86_64|amd64) arch=x64 ;;
@@ -28,9 +28,11 @@ rid="$(detect_rid)"
for csproj in "$root/$samples_dir"/*/*.csproj; do
name="$(basename "$csproj" .csproj)"
grep -q 'Exe' "$csproj" || continue
+
project_dir="$(dirname "$csproj")"
source="$project_dir/bin/$configuration/net10.0/$rid/publish"
out="$root/$publish_dir/$rid/$name"
+
mkdir -p "$out"
dotnet publish "$csproj" \
@@ -39,8 +41,8 @@ for csproj in "$root/$samples_dir"/*/*.csproj; do
--self-contained \
-p:PublishAot=true \
-p:StripSymbols=true \
+ -p:NuGetLockFilePath=obj/aot.lock.json \
--verbosity minimal
cp -a "$source/." "$out/"
- echo "published: $out"
done
diff --git a/scripts/rpm.sh b/scripts/rpm.sh
index 10de46a..dea6021 100755
--- a/scripts/rpm.sh
+++ b/scripts/rpm.sh
@@ -1,16 +1,13 @@
-#!/usr/bin/env bash
-# Package all samples as RPMs from a prior publish (run `make publish` first or use `make rpm`, which chains it).
-# Usage: ./scripts/rpm.sh [version]
-
+# Packages all '*.spec' in the 'SAMPLES_DIR' as rpm.
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$root"
-configuration="${CONFIGURATION:-Release}"
samples_dir="${SAMPLES_DIR:-./samples}"
publish_dir="${PUBLISH_DIR:-./build/publish}"
rpm_dir="${RPM_DIR:-./build/rpm}"
+
version="${1:-$(git describe --tags --abbrev=0 | sed 's/^v//')}"
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
@@ -18,8 +15,8 @@ trap 'rm -rf "$work"' EXIT
detect_rid() {
local os arch
case "$(uname -s)" in
- Linux*) os=linux ;;
- *) echo "unsupported OS: $(uname -s)" >&2; exit 1 ;;
+ Linux*) os=linux ;; # really need this?
+ *) echo "unsupported os: $(uname -s)" >&2; exit 1 ;;
esac
case "$(uname -m)" in
x86_64|amd64) arch=x64 ;;
@@ -43,7 +40,7 @@ mkdir -p "$work/SOURCES"
for spec in "${specs[@]}"; do
name="$(sed -n 's/^Name:[[:space:]]*//p' "$spec" | head -1)"
if [ -z "$name" ]; then
- echo "Skipping $spec: no 'Name:' field" >&2
+ echo "Skipping $spec: no name field" >&2
continue
fi
@@ -51,22 +48,28 @@ for spec in "${specs[@]}"; do
csproj="$(basename "$(ls "$sample_dir"/*.csproj)" .csproj)"
binary="$publish_dir/$rid/$csproj/$name"
if [ ! -x "$binary" ]; then
- echo "Missing published binary: $binary" >&2
+ echo "Skipping $spec: missing binaries" >&2
exit 1
fi
- echo "Staging tarball for $name"
mkdir "$work/$name-$version"
cp "$binary" "$work/$name-$version/"
cp LICENSE "$work/$name-$version/"
+ dotnet cyclonedx "$sample_dir/$csproj.csproj" \
+ -o "$work/$name-$version" \
+ -F Json \
+ -fn bom.json \
+ -dpr
+ if [ ! -f "$work/$name-$version/bom.json" ]; then
+ echo "Skipping $spec: sbom generation failed" >&2
+ exit 1
+ fi
+
tar -czf "$work/SOURCES/$name-$version.tar.gz" -C "$work" "$name-$version"
- echo "Building RPM for $name"
rpmbuild -bb \
--define "_sourcedir $work/SOURCES" \
--define "_rpmdir $rpm_dir" \
--define "pkg_version $version" \
"$spec"
done
-
-find "$rpm_dir" -name '*.rpm'
diff --git a/source/DotBahn.Ai/AiJsonContext.cs b/source/DotBahn.Ai/AiJsonContext.cs
new file mode 100644
index 0000000..197a2f9
--- /dev/null
+++ b/source/DotBahn.Ai/AiJsonContext.cs
@@ -0,0 +1,26 @@
+using System.Text.Json.Serialization;
+using DotBahn.Ai.Input;
+using DotBahn.Boards.Models;
+using DotBahn.Boards.Models.Entries;
+using DotBahn.Facilities.Models;
+using DotBahn.Facilities.Models.Enumerations;
+using DotBahn.Stations.Models;
+
+namespace DotBahn.Ai;
+
+///
+/// Source-generated JSON metadata for AI tool contracts.
+///
+[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, GenerationMode = JsonSourceGenerationMode.Metadata)]
+[JsonSerializable(typeof(StationSearchInput))]
+[JsonSerializable(typeof(BoardToolInput))]
+[JsonSerializable(typeof(FacilityStatusInput))]
+[JsonSerializable(typeof(StationIdentifierKind))]
+[JsonSerializable(typeof(FacilityType))]
+[JsonSerializable(typeof(FacilityState))]
+[JsonSerializable(typeof(ToolError))]
+[JsonSerializable(typeof(ToolResult>))]
+[JsonSerializable(typeof(ToolResult>))]
+[JsonSerializable(typeof(ToolResult>))]
+[JsonSerializable(typeof(ToolResult>))]
+internal sealed partial class AiJsonContext : JsonSerializerContext;
diff --git a/source/DotBahn.Ai/DotBahn.Ai.csproj b/source/DotBahn.Ai/DotBahn.Ai.csproj
new file mode 100644
index 0000000..5874fe5
--- /dev/null
+++ b/source/DotBahn.Ai/DotBahn.Ai.csproj
@@ -0,0 +1,19 @@
+
+
+ true
+ DotBahn.Ai
+ AI tool definitions for DotBahn client packages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/DotBahn.Ai/Input/BoardToolInput.cs b/source/DotBahn.Ai/Input/BoardToolInput.cs
new file mode 100644
index 0000000..e039410
--- /dev/null
+++ b/source/DotBahn.Ai/Input/BoardToolInput.cs
@@ -0,0 +1,51 @@
+using System.ComponentModel;
+
+namespace DotBahn.Ai.Input;
+
+///
+/// AI optimized input DTO for the arrivals and departures tools.
+///
+public record BoardToolInput {
+ ///
+ /// Identifier returned by the station search tool.
+ ///
+ [Description("Identifier returned by search_stations, e.g. an EVA number.")]
+ public required string StationId { get; init; }
+
+ ///
+ /// Identifier scheme used by .
+ ///
+ [Description("Identifier scheme: Eva, Stada, or Dhid.")]
+ public required StationIdentifierKind StationKind { get; init; }
+
+ ///
+ /// Optional start of the time window in ISO 8601 format.
+ ///
+ [Description("Optional start of the time window in ISO 8601 format. Defaults to now.")]
+ public DateTime? Start { get; init; }
+
+ ///
+ /// Maximum number of board entries to return.
+ ///
+ [Description("Maximum number of board entries to return (1-25).")]
+ public int MaxEntries { get; init; } = 10;
+
+ ///
+ /// Validates that the DTO constraints are respected by the LLM.
+ ///
+ /// Thrown when a required value is missing or invalid.
+ /// Thrown when a value is outside the allowed range.
+ internal void Validate() {
+ if (string.IsNullOrWhiteSpace(StationId) || StationId.Length > 64) {
+ throw new ArgumentException("StationId must contain between 1 and 64 characters.", nameof(StationId));
+ }
+
+ if (!Enum.IsDefined(StationKind)) {
+ throw new ArgumentOutOfRangeException(nameof(StationKind), "StationKind must be Eva, Stada, or Dhid.");
+ }
+
+ if (MaxEntries is < 1 or > 25) {
+ throw new ArgumentOutOfRangeException(nameof(MaxEntries), "MaxEntries must be between 1 and 25.");
+ }
+ }
+}
diff --git a/source/DotBahn.Ai/Input/FacilityStatusInput.cs b/source/DotBahn.Ai/Input/FacilityStatusInput.cs
new file mode 100644
index 0000000..b744530
--- /dev/null
+++ b/source/DotBahn.Ai/Input/FacilityStatusInput.cs
@@ -0,0 +1,48 @@
+using System.ComponentModel;
+using DotBahn.Facilities.Models.Enumerations;
+
+namespace DotBahn.Ai.Input;
+
+///
+/// AI optimized input DTO for the facility status tool.
+///
+public sealed record FacilityStatusInput {
+ ///
+ /// The station number whose facilities should be queried.
+ ///
+ [Description("DB station number returned by search_stations.")]
+ public required int StationNumber { get; init; }
+
+ ///
+ /// Only return facilities of this type.
+ ///
+ [Description("Only return facilities of this type.")]
+ public FacilityType? Type { get; init; }
+
+ ///
+ /// Only return facilities in this state.
+ ///
+ [Description("Only return facilities in this state.")]
+ public FacilityState? State { get; init; }
+
+ ///
+ /// Maximum number of facilities to return.
+ ///
+ [Description("Maximum number of facilities to return (1-25).")]
+ public int MaxResults { get; init; } = 25;
+
+ ///
+ /// Validates that the DTO constraints are respected by the LLM.
+ ///
+ /// Thrown when a required value is missing or invalid.
+ /// Thrown when a value is outside the allowed range.
+ internal void Validate() {
+ if (StationNumber <= 0) {
+ throw new ArgumentOutOfRangeException(nameof(StationNumber), "StationNumber must be positive.");
+ }
+
+ if (MaxResults is < 1 or > 25) {
+ throw new ArgumentOutOfRangeException(nameof(MaxResults), "MaxResults must be between 1 and 25.");
+ }
+ }
+}
diff --git a/source/DotBahn.Ai/Input/StationIdentifierKind.cs b/source/DotBahn.Ai/Input/StationIdentifierKind.cs
new file mode 100644
index 0000000..0cad96b
--- /dev/null
+++ b/source/DotBahn.Ai/Input/StationIdentifierKind.cs
@@ -0,0 +1,21 @@
+namespace DotBahn.Ai.Input;
+
+///
+/// Identifier scheme used by .
+///
+public enum StationIdentifierKind {
+ ///
+ /// EVA station number.
+ ///
+ Eva,
+
+ ///
+ /// STADA station identifier.
+ ///
+ Stada,
+
+ ///
+ /// DHID stop-place identifier.
+ ///
+ Dhid
+}
diff --git a/source/DotBahn.Ai/Input/StationSearchInput.cs b/source/DotBahn.Ai/Input/StationSearchInput.cs
new file mode 100644
index 0000000..bfefccd
--- /dev/null
+++ b/source/DotBahn.Ai/Input/StationSearchInput.cs
@@ -0,0 +1,35 @@
+using System.ComponentModel;
+
+namespace DotBahn.Ai.Input;
+
+///
+/// AI optimized input DTO for the station search tool.
+///
+public sealed record StationSearchInput {
+ ///
+ /// Station name or fragment to search for.
+ ///
+ [Description("Station name or fragment to search for. Supports * and ? wildcards.")]
+ public required string Query { get; init; }
+
+ ///
+ /// Maximum number of stations to return.
+ ///
+ [Description("Maximum number of stations to return (1-20).")]
+ public int MaxResults { get; init; } = 20;
+
+ ///
+ /// Validates that the DTO constraints are respected by the LLM.
+ ///
+ /// Thrown when a required value is missing or invalid.
+ /// Thrown when a value is outside the allowed range.
+ internal void Validate() {
+ if (string.IsNullOrWhiteSpace(Query) || Query.Length > 200) {
+ throw new ArgumentException("Query must contain between 1 and 200 characters.", nameof(Query));
+ }
+
+ if (MaxResults is < 1 or > 20) {
+ throw new ArgumentOutOfRangeException(nameof(MaxResults), "MaxResults must be between 1 and 20.");
+ }
+ }
+}
diff --git a/source/DotBahn.Ai/ServiceCollectionExtensions.cs b/source/DotBahn.Ai/ServiceCollectionExtensions.cs
new file mode 100644
index 0000000..a4bf8f8
--- /dev/null
+++ b/source/DotBahn.Ai/ServiceCollectionExtensions.cs
@@ -0,0 +1,78 @@
+using System.Text.Json;
+using System.Text.Json.Serialization.Metadata;
+using Microsoft.Extensions.AI;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+
+namespace DotBahn.Ai;
+
+///
+/// Extension methods for registering the DotBahn AI tools.
+///
+public static class ServiceCollectionExtensions {
+ private static readonly JsonSerializerOptions FunctionJsonOptions = CreateFunctionJsonOptions();
+
+ ///
+ /// Adds function invocation middleware with safe defaults for DotBahn tools.
+ ///
+ /// The chat client builder to configure.
+ /// Optional logger factory for function invocation logging.
+ /// The chat client builder for chaining.
+ /// Thrown when is null.
+ public static ChatClientBuilder UseDotBahnAiTools(this ChatClientBuilder builder, ILoggerFactory? factory = null) {
+ ArgumentNullException.ThrowIfNull(builder);
+ return builder.UseFunctionInvocation(factory, configure: client => {
+ client.MaximumIterationsPerRequest = 5;
+ client.MaximumConsecutiveErrorsPerRequest = 2;
+ client.AllowConcurrentInvocation = false;
+ client.IncludeDetailedErrors = false;
+ client.TerminateOnUnknownCalls = true;
+ });
+ }
+
+ ///
+ /// Registers the DotBahn AI tools and their adapters.
+ ///
+ /// The service collection to add to.
+ /// The service collection for chaining.
+ /// Thrown when is null.
+ public static IServiceCollection AddDotBahnAiTools(this IServiceCollection services) {
+ ArgumentNullException.ThrowIfNull(services);
+
+ services.AddSingleton();
+
+ services.AddSingleton(CreateSearchStationsFunction);
+ services.AddSingleton(CreateDeparturesFunction);
+ services.AddSingleton(CreateArrivalsFunction);
+ services.AddSingleton(CreateFacilityStatusFunction);
+
+ services.AddSingleton>(sp => sp.GetServices().ToList());
+ return services;
+ }
+
+ private static AIFunction CreateSearchStationsFunction(IServiceProvider services) {
+ var tools = services.GetRequiredService();
+ return AIFunctionFactory.Create(tools.SearchStationsAsync, "dotbahn_search_stations", "Search for railway stations by name.", FunctionJsonOptions);
+ }
+
+ private static AIFunction CreateDeparturesFunction(IServiceProvider services) {
+ var tools = services.GetRequiredService();
+ return AIFunctionFactory.Create(tools.GetDeparturesAsync, "dotbahn_get_departures", "Get scheduled departures for a station.", FunctionJsonOptions);
+ }
+
+ private static AIFunction CreateArrivalsFunction(IServiceProvider services) {
+ var tools = services.GetRequiredService();
+ return AIFunctionFactory.Create(tools.GetArrivalsAsync, "dotbahn_get_arrivals", "Get scheduled arrivals for a station.", FunctionJsonOptions);
+ }
+
+ private static AIFunction CreateFacilityStatusFunction(IServiceProvider services) {
+ var tools = services.GetRequiredService();
+ return AIFunctionFactory.Create(tools.GetFacilityStatusAsync, "dotbahn_get_facility_status", "Get operational status for station facilities.", FunctionJsonOptions);
+ }
+
+ private static JsonSerializerOptions CreateFunctionJsonOptions() {
+ return new JsonSerializerOptions(AIJsonUtilities.DefaultOptions) {
+ TypeInfoResolver = AIJsonUtilities.DefaultOptions.TypeInfoResolver is { } resolver ? JsonTypeInfoResolver.Combine(AiJsonContext.Default, resolver) : AiJsonContext.Default
+ };
+ }
+}
diff --git a/source/DotBahn.Ai/ToolResult.cs b/source/DotBahn.Ai/ToolResult.cs
new file mode 100644
index 0000000..18b8cdf
--- /dev/null
+++ b/source/DotBahn.Ai/ToolResult.cs
@@ -0,0 +1,37 @@
+namespace DotBahn.Ai;
+
+///
+/// Structured error information returned to the model when a tool call fails.
+///
+/// Stable machine-readable error code.
+/// Sanitized, actionable error message.
+/// Optional name of the invalid input field.
+/// Whether retrying with corrected input may succeed.
+public sealed record ToolError(string Code, string Message, string? Field = null, bool Retryable = false);
+
+///
+/// Result envelope returned by AI tools, containing either data or a structured error.
+///
+/// The type of the successful result.
+/// Whether the tool completed successfully.
+/// The successful result, or null on failure.
+/// The structured error, or null on success.
+public sealed record ToolResult(bool Success, T? Data, ToolError? Error) {
+ ///
+ /// Creates a successful result.
+ ///
+ /// The successful result.
+ /// A successful .
+ public static ToolResult Ok(T data) => new(true, data, null);
+
+ ///
+ /// Creates a failed result.
+ ///
+ /// The structured error.
+ /// A failed .
+ /// Thrown when is null.
+ public static ToolResult Fail(ToolError error) {
+ ArgumentNullException.ThrowIfNull(error);
+ return new ToolResult(false, default, error);
+ }
+}
diff --git a/source/DotBahn.Ai/Tools.cs b/source/DotBahn.Ai/Tools.cs
new file mode 100644
index 0000000..930e466
--- /dev/null
+++ b/source/DotBahn.Ai/Tools.cs
@@ -0,0 +1,138 @@
+using System.Diagnostics;
+using DotBahn.Ai.Input;
+using DotBahn.Ai.Utilities;
+using DotBahn.Boards;
+using DotBahn.Boards.Models;
+using DotBahn.Boards.Models.Entries;
+using DotBahn.Common.Telemetry;
+using DotBahn.Facilities;
+using DotBahn.Facilities.Models;
+using DotBahn.Facilities.Models.Enumerations;
+using DotBahn.Stations;
+using DotBahn.Stations.Models;
+
+namespace DotBahn.Ai;
+
+///
+/// AI tools backed by the DotBahn clients.
+///
+/// The client used for station lookups.
+/// The client used for arrival and departure boards.
+/// The client used for facility status lookups.
+public sealed class Tools(IStationClient stations, IBoardsClient boards, IFacilityClient facilities) {
+ ///
+ /// Searches for railway stations by name.
+ ///
+ /// Station name or fragment to search for.
+ /// Maximum number of stations to return (1-20).
+ /// Token to cancel the request.
+ /// A result containing the matching stations, or an invalid_argument error.
+ /// Thrown when the operation is canceled.
+ public Task>> SearchStationsAsync(string query, int maxResults = 20, CancellationToken ct = default) =>
+ ExecuteToolAsync("dotbahn_search_stations", async token => {
+ var input = new StationSearchInput { Query = query, MaxResults = maxResults };
+ input.Validate();
+
+ return await stations.GetStationsAsync(new StationQuery().WithNames(input.Query).LimitTo(input.MaxResults), token).ConfigureAwait(false);
+ }, ct);
+
+ ///
+ /// Gets the operational status of facilities at a station.
+ ///
+ /// DB station number returned by search_stations.
+ /// Optional facility type filter.
+ /// Optional facility state filter.
+ /// Maximum number of facilities to return (1-25).
+ /// Token to cancel the request.
+ /// A result containing the matching facilities, or an invalid_argument error.
+ /// Thrown when the operation is canceled.
+ public Task>> GetFacilityStatusAsync(int stationNumber, FacilityType? type = null, FacilityState? state = null, int maxResults = 25, CancellationToken ct = default) =>
+ ExecuteToolAsync>("dotbahn_get_facility_status", async token => {
+ var input = new FacilityStatusInput { StationNumber = stationNumber, Type = type, State = state, MaxResults = maxResults };
+ input.Validate();
+
+ var query = new FacilityQuery().AtStation(input.StationNumber);
+ if (input.Type.HasValue) {
+ query.WithType(input.Type.Value);
+ }
+
+ if (input.State.HasValue) {
+ query.WithState(input.State.Value);
+ }
+
+ var result = await facilities.GetFacilitiesAsync(query, token).ConfigureAwait(false);
+ return result.Take(input.MaxResults).ToList();
+ }, ct);
+
+ ///
+ /// Gets the departure board for a station.
+ ///
+ /// Identifier returned by search_stations.
+ /// Identifier scheme used by stationId.
+ /// Optional start of the time window in ISO 8601 format.
+ /// Maximum number of board entries to return (1-25).
+ /// Token to cancel the request.
+ /// A result containing the departure board, or an invalid_argument error.
+ /// Thrown when the operation is canceled.
+ public Task>> GetDeparturesAsync(string stationId, StationIdentifierKind stationKind, DateTime? start = null, int maxEntries = 10, CancellationToken ct = default) =>
+ ExecuteToolAsync("dotbahn_get_departures", async token => {
+ var input = new BoardToolInput { StationId = stationId, StationKind = stationKind, Start = start, MaxEntries = maxEntries };
+ input.Validate();
+
+ return await boards.GetDeparturesAsync(CreateBoardQuery(input), token).ConfigureAwait(false);
+ }, ct);
+
+ ///
+ /// Gets the arrival board for a station.
+ ///
+ /// Identifier returned by search_stations.
+ /// Identifier scheme used by stationId.
+ /// Optional start of the time window in ISO 8601 format.
+ /// Maximum number of board entries to return (1-25).
+ /// Token to cancel the request.
+ /// A result containing the arrival board, or an invalid_argument error.
+ /// Thrown when the operation is canceled.
+ public Task>> GetArrivalsAsync(string stationId, StationIdentifierKind stationKind, DateTime? start = null, int maxEntries = 10, CancellationToken ct = default) =>
+ ExecuteToolAsync("dotbahn_get_arrivals", async token => {
+ var input = new BoardToolInput { StationId = stationId, StationKind = stationKind, Start = start, MaxEntries = maxEntries };
+ input.Validate();
+
+ return await boards.GetArrivalsAsync(CreateBoardQuery(input), token).ConfigureAwait(false);
+ }, ct);
+
+ private static async Task> ExecuteToolAsync(string name, Func> operation, CancellationToken ct) {
+ using var activity = DotBahnTelemetry.StartAiTool(name);
+ var start = Stopwatch.GetTimestamp();
+
+ try {
+ var value = await operation(ct).ConfigureAwait(false);
+ DotBahnTelemetry.RecordAiTool(Stopwatch.GetElapsedTime(start).TotalSeconds, name);
+ return ToolResult.Ok(value);
+ } catch (OperationCanceledException) {
+ DotBahnTelemetry.RecordAiTool(Stopwatch.GetElapsedTime(start).TotalSeconds, name);
+ throw;
+ } catch (Exception ex) {
+ var error = ToolErrorUtil.FromException(ex);
+
+ activity?.SetStatus(ActivityStatusCode.Error, error.Message);
+ activity?.SetTag(DotBahnTelemetry.ErrorCodeTag, error.Code);
+
+ DotBahnTelemetry.RecordAiTool(Stopwatch.GetElapsedTime(start).TotalSeconds, name, errorCode: error.Code);
+ return ToolResult.Fail(error);
+ }
+ }
+
+ private static BoardQuery CreateBoardQuery(BoardToolInput input) {
+ var query = new BoardQuery().ForNext(input.MaxEntries);
+ if (input.Start.HasValue) {
+ query = query.StartingAt(input.Start.Value);
+ }
+
+ return input.StationKind switch {
+ StationIdentifierKind.Eva => query.ForEvaNumbers(input.StationId),
+ StationIdentifierKind.Stada => query.ForStada(input.StationId),
+ StationIdentifierKind.Dhid => query.ForDhids(input.StationId),
+ _ => throw new ArgumentOutOfRangeException(nameof(input))
+ };
+ }
+}
diff --git a/source/DotBahn.Ai/Utilities/ToolErrorUtil.cs b/source/DotBahn.Ai/Utilities/ToolErrorUtil.cs
new file mode 100644
index 0000000..279dfaa
--- /dev/null
+++ b/source/DotBahn.Ai/Utilities/ToolErrorUtil.cs
@@ -0,0 +1,33 @@
+using System.Net;
+
+namespace DotBahn.Ai.Utilities;
+
+///
+/// Maps exceptions to sanitized, model-facing instances.
+///
+public static class ToolErrorUtil {
+ ///
+ /// Maps an exception to a structured tool error.
+ ///
+ /// The exception to map.
+ /// The structured tool error.
+ /// Thrown when is null.
+ public static ToolError FromException(Exception exception) {
+ ArgumentNullException.ThrowIfNull(exception);
+ return exception switch {
+ ArgumentException argument => FromArgument(argument),
+ HttpRequestException http => FromHttp(http),
+ _ => new ToolError("internal_error", "The tool could not complete the request.")
+ };
+ }
+
+ private static ToolError FromHttp(HttpRequestException http) => http.StatusCode switch {
+ HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden => new ToolError("unauthorized", "DotBahn API credentials are missing or invalid."),
+ HttpStatusCode.NotFound => new ToolError("not_found", "The requested station or board was not found."),
+ HttpStatusCode.TooManyRequests => new ToolError("rate_limited", "The DotBahn API rate limit was reached. Retry later.", null, true),
+ { } value when (int)value >= 500 => new ToolError("upstream_error", "The DotBahn API is temporarily unavailable.", null, true),
+ _ => new ToolError("upstream_error", "The DotBahn API request failed.", null, true)
+ };
+
+ private static ToolError FromArgument(ArgumentException argument) => new("invalid_argument", argument.Message, string.IsNullOrWhiteSpace(argument.ParamName) ? null : argument.ParamName, true);
+}
diff --git a/source/DotBahn.Ai/packages.lock.json b/source/DotBahn.Ai/packages.lock.json
new file mode 100644
index 0000000..55b055a
--- /dev/null
+++ b/source/DotBahn.Ai/packages.lock.json
@@ -0,0 +1,379 @@
+{
+ "version": 2,
+ "dependencies": {
+ "net10.0": {
+ "Microsoft.Extensions.AI": {
+ "type": "Direct",
+ "requested": "[11.0.1, )",
+ "resolved": "11.0.1",
+ "contentHash": "MP6zzZzPseaXu0DtZFCkPCWPXLTu7JY28ciyxqSoeDOP5Raf+wJT8+HapyLfXaI7F1CXpyr5PgiCQEE0CeVCqw==",
+ "dependencies": {
+ "Microsoft.Extensions.AI.Abstractions": "11.0.1",
+ "Microsoft.Extensions.Caching.Abstractions": "11.0.0",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Logging.Abstractions": "11.0.0",
+ "System.Numerics.Tensors": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.AI.Abstractions": {
+ "type": "Direct",
+ "requested": "[11.0.1, )",
+ "resolved": "11.0.1",
+ "contentHash": "pG3n1nHRnVcYuMAiqhDPuKefXTtUGAhAtqhBUKpNsZXYef9Vm51iZhUAVfQ2EzYhechFaA5hCcgQgK18jTzuiw=="
+ },
+ "Microsoft.NET.ILLink.Tasks": {
+ "type": "Direct",
+ "requested": "[10.0.15, )",
+ "resolved": "10.0.15",
+ "contentHash": "u0WnRcZgBZYHlVFpbe/3Adpmb9rmNJ8/fmEwqc/xjB7fFppq+gfaLJd3Sdaw+J02zV0eP/T9dneQ3Dv5jWw6bw=="
+ },
+ "MinVer": {
+ "type": "Direct",
+ "requested": "[8.0.0, )",
+ "resolved": "8.0.0",
+ "contentHash": "AJy/KVjXgUbgjf6HiI8wAk4DSSq0SCmvXQF8aU6IB+pnIQq+YJvofvMczug2hqO8yEvnQY557ryew66KPpyCsA=="
+ },
+ "Microsoft.Extensions.AmbientMetadata.Application": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "tm28s2ODWZ6RdysP06NI3B23DUY5OfHG35ihMHxVAO3hywZAczDVjrkYMfBY//J4HQqfDHS5op84BhnF7ROseQ==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration": "10.0.15",
+ "Microsoft.Extensions.Hosting.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.Caching.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "L+eahU5QGaFaCau3Y9qqY7WThUsR18sHASVDD1KuaSx2dy73NOY9U5Qz5eOe6bJOF3wHzkEaCl2LZhgwtlClyw==",
+ "dependencies": {
+ "Microsoft.Extensions.Primitives": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Compliance.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "DUwdXgIxJKH9zBNg/SUBqOX0FpXCq7w80CIzrr0Jcw5tBXS926AtCcidoAsEHq5e/c6KQ8rWhSt7NxFxak8N/Q==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15",
+ "Microsoft.Extensions.ObjectPool": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.Compliance.Redaction": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "2rwe98yZEn4+aXjAg5DdcROMg6m2w3tejf/mRk4/fBCHKM2EWCaFTmbHLtz1BfyBxMY00/08XFoN0wzWYNiSiQ==",
+ "dependencies": {
+ "Microsoft.Extensions.Compliance.Abstractions": "11.0.1",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.Configuration": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "VQS/GkFU9oLQmXZv0AR/zluF0YAbEAoUQ5aYMqcRc2TWeKa6m2AjInAOnDhCcoWI5a6LQUCzTcl8B3DZZaPZLg==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Primitives": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Configuration.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "oyBSWnEsEi9SZTiwAfuKIdVIiEZ7TvNOtdFaGqyzF9WtomNV+uZHCqhQbnz/ipjtM50BYJ4s0MWbYafolq2mAg==",
+ "dependencies": {
+ "Microsoft.Extensions.Primitives": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Configuration.Binder": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "3eoaKF4Stat1PSN+KFwqmy04sM9DwGuHM1o1lHwuNFM/TqwQ+PCIvaQHS4lcT3kJl5rwvDK4w/rIlR0wc024eQ==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration": "11.0.0",
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.DependencyInjection": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "KygQMITBDDPXw7+AAgdwQvVAaTXuDsc1iCAuvhO73ERxKX+d92cdbgZmpoYF7DIUq2hfs/yO2KD87uIreRy3MA==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.DependencyInjection.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "a2c4Kp55miXT6G+DSb75pczXQJHgNMzPyZEyMxrrKxuQrgvctcDWJWD9fVe/uGbQdu4Z0c3B7AVKp1DXmD64nQ=="
+ },
+ "Microsoft.Extensions.DependencyInjection.AutoActivation": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "OuVIF5TmsfonN2Fqmi2zlUtbFQNqQiflhgo/rh64ptrqYrB4wZLwKbXr/HzrQXMf+h3jIbWrjIdJFspGqcvuuQ==",
+ "dependencies": {
+ "Microsoft.Extensions.Hosting.Abstractions": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.Diagnostics": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "tX8piU+KbYHXIf5F70leczIWwtTkPKhyjRqjbo6D2uTA1PwrhcMD+Ls7rzqSMkx1U3osyrD4/kCrZeF13Lkgnw==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration": "11.0.0",
+ "Microsoft.Extensions.Diagnostics.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Diagnostics.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "o188Hh1AqAI91K+R8eY3REW5HzofGastQk8OPLIy4uS8FnJo4Niok/X+HH/nHRO1ApsxW7q1yYFoHDpAZC36fA==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0",
+ "System.Diagnostics.DiagnosticSource": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Diagnostics.ExceptionSummarization": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "mqqpmAFNRLa4cozN3RvT/T81k4aarwMc8xb8VVQgLqUE7AAoN/WWayZAvP+4hy9+KujP3dfn3taU06fZJPIbgA==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.FileProviders.Abstractions": {
+ "type": "Transitive",
+ "resolved": "10.0.15",
+ "contentHash": "1RSYAUtJeb76m2T0u5BbvwKY3s+ge9fT3cj1odvo5Bm+frc7pU9RSeXeMIlYHV8GjpqLdv2neeeomz010yYL8A==",
+ "dependencies": {
+ "Microsoft.Extensions.Primitives": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.Hosting.Abstractions": {
+ "type": "Transitive",
+ "resolved": "10.0.15",
+ "contentHash": "s/JBiwR3F/vKRCbe6WO5b6t6or1ISaZ3rllchcw6/FSWZmK8s2fAzD7elrZo7592FnMD1fhGoG/wuJL1YYtVXw==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration.Abstractions": "10.0.15",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Diagnostics.Abstractions": "10.0.15",
+ "Microsoft.Extensions.FileProviders.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.Http.Diagnostics": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "mKHY0oFYL3fkAOhBNi2LqWPuEdUJ+HiF28KKUwBkQG2sgXAUdFDDqvJAfu2PcYgtAwsAtl58zuk4SElpPzbCvA==",
+ "dependencies": {
+ "Microsoft.Extensions.Compliance.Redaction": "11.0.1",
+ "Microsoft.Extensions.Http": "10.0.15",
+ "Microsoft.Extensions.Telemetry": "11.0.1"
+ }
+ },
+ "Microsoft.Extensions.Logging": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "zsse8MOgo0bj2KAEsSkg9WtNAfZbHbTlGeqfhy5PGozomM3zQM0XzumSQzQ0451IWNSJWLqYaSIQEpCi2j1sCA==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection": "11.0.0",
+ "Microsoft.Extensions.Logging.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Logging.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "MTMO2V1eT9Dm5VIpJGLNwIjAjoBErUlfuB+DEaZ0tb8J+Nf/Xlj8he5AztK9p1iOJPIyuBeOrVy2u/CSdsfzPw==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "System.Diagnostics.DiagnosticSource": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Logging.Configuration": {
+ "type": "Transitive",
+ "resolved": "10.0.15",
+ "contentHash": "Km6Ml1/nu0T/f80Btonxf9CWmP/BXI84aJwC5fUbCxRArJ0lH++0ADQrjErZvsSIrKhusTkTSGBChKy2fYAF4w==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration": "10.0.15",
+ "Microsoft.Extensions.Configuration.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Configuration.Binder": "10.0.15",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Logging": "10.0.15",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.15",
+ "Microsoft.Extensions.Options": "10.0.15",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15"
+ }
+ },
+ "Microsoft.Extensions.ObjectPool": {
+ "type": "Transitive",
+ "resolved": "10.0.15",
+ "contentHash": "kvd9eyRRQ+OEu9wik7GKgTS+7XnJ5XoOtSXJqmkJtVYV/S4gsBUrobYRSdNeBcb0ymef4L5Q9pZGiTxJ8jJfyQ=="
+ },
+ "Microsoft.Extensions.Options.ConfigurationExtensions": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "s4JrxDPwxk8pE6LFVj+M5TrDHxOVIoCnQBy5lexs5uAYeggPYwAc/pSDNgVuZN14pCmZGCInygI/2ylCdLYShw==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Configuration.Binder": "11.0.0",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0",
+ "Microsoft.Extensions.Primitives": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Primitives": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "HH2akbW2HeY/xeZJA5UceuQQX+1Pv/Kxrz/x4XPoH6wYDtgPIlBeOTZlQXlT+b50b1Ym/xfP+WJCX9FW4uLBXQ=="
+ },
+ "Microsoft.Extensions.Resilience": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "xgKof6iwAByZNrxWOa7Drk4A953L7U2HleTmx7EXE2Vf6j1crp4RsvNlIVsJMtHKf3ftGKd9gOhR3xES9vxUgg==",
+ "dependencies": {
+ "Microsoft.Extensions.Diagnostics": "10.0.15",
+ "Microsoft.Extensions.Diagnostics.ExceptionSummarization": "11.0.1",
+ "Microsoft.Extensions.Options.ConfigurationExtensions": "10.0.15",
+ "Microsoft.Extensions.Telemetry.Abstractions": "11.0.1",
+ "Polly.Extensions": "8.4.2",
+ "Polly.RateLimiting": "8.4.2"
+ }
+ },
+ "Microsoft.Extensions.Telemetry": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "9uuA8entTC9m00m59h6CACSt4IQh9KknB+hPvCteXUTiG67lqJ8BI65fEUJSPSfT3ZDDi01Zg2aY5kRUvD4HPw==",
+ "dependencies": {
+ "Microsoft.Extensions.AmbientMetadata.Application": "11.0.1",
+ "Microsoft.Extensions.DependencyInjection.AutoActivation": "11.0.1",
+ "Microsoft.Extensions.Logging.Configuration": "10.0.15",
+ "Microsoft.Extensions.ObjectPool": "10.0.15",
+ "Microsoft.Extensions.Telemetry.Abstractions": "11.0.1"
+ }
+ },
+ "Microsoft.Extensions.Telemetry.Abstractions": {
+ "type": "Transitive",
+ "resolved": "11.0.1",
+ "contentHash": "qINZz4G01Wxumqd0hLr6YdzPa3s7jexQWN28EenaiJQnmKdsR9FnBaKENdRRElLc+A5bJKQ+jYw/WHG4ZpIyAg==",
+ "dependencies": {
+ "Microsoft.Extensions.Compliance.Abstractions": "11.0.1",
+ "Microsoft.Extensions.Logging.Abstractions": "10.0.15",
+ "Microsoft.Extensions.ObjectPool": "10.0.15",
+ "Microsoft.Extensions.Options": "10.0.15"
+ }
+ },
+ "Polly.Core": {
+ "type": "Transitive",
+ "resolved": "8.4.2",
+ "contentHash": "BpE2I6HBYYA5tF0Vn4eoQOGYTYIK1BlF5EXVgkWGn3mqUUjbXAr13J6fZVbp7Q3epRR8yshacBMlsHMhpOiV3g=="
+ },
+ "Polly.Extensions": {
+ "type": "Transitive",
+ "resolved": "8.4.2",
+ "contentHash": "GZ9vRVmR0jV2JtZavt+pGUsQ1O1cuRKG7R7VOZI6ZDy9y6RNPvRvXK1tuS4ffUrv8L0FTea59oEuQzgS0R7zSA==",
+ "dependencies": {
+ "Microsoft.Extensions.Logging.Abstractions": "8.0.0",
+ "Microsoft.Extensions.Options": "8.0.0",
+ "Polly.Core": "8.4.2"
+ }
+ },
+ "Polly.RateLimiting": {
+ "type": "Transitive",
+ "resolved": "8.4.2",
+ "contentHash": "ehTImQ/eUyO07VYW2WvwSmU9rRH200SKJ/3jku9rOkyWE0A2JxNFmAVms8dSn49QLSjmjFRRSgfNyOgr/2PSmA==",
+ "dependencies": {
+ "Polly.Core": "8.4.2",
+ "System.Threading.RateLimiting": "8.0.0"
+ }
+ },
+ "System.Diagnostics.DiagnosticSource": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "+boRR9uSKiIPtFeRLGwO5xylhDF80xpwM+dmk5jgIqqeUKLbujGkGICMTKqQrBzKO6fIp8BU8DV6YZkQukqo3A=="
+ },
+ "System.Numerics.Tensors": {
+ "type": "Transitive",
+ "resolved": "11.0.0",
+ "contentHash": "thx6y1hMzB6LumB/aLcZoLHWq8wr+dbldk/FiNghyT+4ynxo9u2oCTFfb5iDMDG6hykDXLorXuaf4EPEij2BBg=="
+ },
+ "System.Threading.RateLimiting": {
+ "type": "Transitive",
+ "resolved": "8.0.0",
+ "contentHash": "7mu9v0QDv66ar3DpGSZHg9NuNcxDaaAcnMULuZlaTpP9+hwXhrxNGsF5GmLkSHxFdb5bBc1TzeujsRgTrPWi+Q=="
+ },
+ "dotbahn.boards": {
+ "type": "Project",
+ "dependencies": {
+ "DotBahn.Common": "[1.0.0, )",
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Http.Resilience": "[11.0.1, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
+ }
+ },
+ "dotbahn.common": {
+ "type": "Project",
+ "dependencies": {
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
+ }
+ },
+ "dotbahn.facilities": {
+ "type": "Project",
+ "dependencies": {
+ "DotBahn.Common": "[1.0.0, )",
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Http.Resilience": "[11.0.1, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
+ }
+ },
+ "dotbahn.stations": {
+ "type": "Project",
+ "dependencies": {
+ "DotBahn.Common": "[1.0.0, )",
+ "Microsoft.Extensions.Http": "[11.0.0, )",
+ "Microsoft.Extensions.Http.Resilience": "[11.0.1, )",
+ "Microsoft.Extensions.Options": "[11.0.0, )"
+ }
+ },
+ "Microsoft.Extensions.Http": {
+ "type": "CentralTransitive",
+ "requested": "[11.0.0, )",
+ "resolved": "11.0.0",
+ "contentHash": "Pa5xJYtE5weFzv8sRwei1yvqCc05PareJABDtUSigzyj0xmrnG7ZU5VBy0hf5tgh7HN3/psGiOQouw5PLaQD8w==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration.Abstractions": "11.0.0",
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Diagnostics": "11.0.0",
+ "Microsoft.Extensions.Logging": "11.0.0",
+ "Microsoft.Extensions.Logging.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Options": "11.0.0"
+ }
+ },
+ "Microsoft.Extensions.Http.Resilience": {
+ "type": "CentralTransitive",
+ "requested": "[11.0.1, )",
+ "resolved": "11.0.1",
+ "contentHash": "5VawCrg+VgVT2hNurSSEWUnq0pvNoH+Zt82s5Wpl/8jdnmU8DpRlr+M3DcdtVgeBG7mRyk3GtSRbf8PB/HrL3w==",
+ "dependencies": {
+ "Microsoft.Extensions.Http.Diagnostics": "11.0.1",
+ "Microsoft.Extensions.ObjectPool": "10.0.15",
+ "Microsoft.Extensions.Resilience": "11.0.1"
+ }
+ },
+ "Microsoft.Extensions.Options": {
+ "type": "CentralTransitive",
+ "requested": "[11.0.0, )",
+ "resolved": "11.0.0",
+ "contentHash": "AaNswJ3NqdNCNqQVlU7iTkvrrrzqrSSxkOC3bLlrwv/CPN7YRz3HoJk7o4ey5v6U8bOHocHsyYoJ7ihK1KUWyQ==",
+ "dependencies": {
+ "Microsoft.Extensions.DependencyInjection.Abstractions": "11.0.0",
+ "Microsoft.Extensions.Primitives": "11.0.0"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/source/DotBahn.Boards/BoardQuery.cs b/source/DotBahn.Boards/BoardQuery.cs
new file mode 100644
index 0000000..258ef0e
--- /dev/null
+++ b/source/DotBahn.Boards/BoardQuery.cs
@@ -0,0 +1,214 @@
+namespace DotBahn.Boards;
+
+///
+/// Query for an arrival or departure board.
+///
+public sealed record BoardQuery {
+ ///
+ /// EVA numbers of stop places. Mutually exclusive with and .
+ ///
+ public IReadOnlyList? EvaNumbers { get; init; }
+
+ ///
+ /// Stada ID of a station. Mutually exclusive with and .
+ ///
+ public string? StadaId { get; init; }
+
+ ///
+ /// DHIDs of stop places. Mutually exclusive with and .
+ ///
+ public IReadOnlyList? Dhids { get; init; }
+
+ ///
+ /// Optional platform names to filter the board.
+ ///
+ public IReadOnlyList? Platforms { get; init; }
+
+ ///
+ /// Board configuration modes to extend the board to nearby stop places.
+ ///
+ public IReadOnlyList? BoardConfigurations { get; init; }
+
+ ///
+ /// Start of the time window. If omitted, the API uses the current time.
+ ///
+ public DateTime? Start { get; init; }
+
+ ///
+ /// End of the time window. Mutually exclusive with .
+ ///
+ public DateTime? End { get; init; }
+
+ ///
+ /// Fixed number of entries to return from .
+ ///
+ /// Mutually exclusive with .
+ ///
+ ///
+ public int? EntryCount { get; init; }
+
+ ///
+ /// Transport types to include. If empty, the API defaults to rail transports.
+ ///
+ public IReadOnlyList TransportTypes { get; init; } = [];
+
+ ///
+ /// Languages to request, as ISO-639-3 codes.
+ ///
+ public IReadOnlyList Languages { get; init; } = ["deu", "eng"];
+
+ ///
+ /// Maximum number of entries returned per transport type.
+ ///
+ public int MaxEntriesPerTransportType { get; init; } = 25;
+
+ ///
+ /// Maximum number of via stops returned per journey.
+ ///
+ public int? MaxViaStops { get; init; }
+
+ ///
+ /// Whether to include line colors in the response.
+ ///
+ public bool IncludeLineColours { get; init; }
+
+ ///
+ /// Whether to include platform accessibility information in the response.
+ ///
+ public bool IncludePlatformAccessibility { get; init; }
+
+ ///
+ /// Whether to exclude canceled entries.
+ ///
+ public bool NoCancellations { get; init; }
+
+ ///
+ /// Whether to return only replacement transports.
+ ///
+ public bool OnlyReplacementTransports { get; init; }
+
+ ///
+ /// Sorting order, either TIME or TIME_SCHEDULE.
+ ///
+ public string SortBy { get; init; } = "TIME";
+
+ ///
+ /// Restricts the board to one or more EVA numbers.
+ ///
+ /// EVA numbers of stop places.
+ /// A new query with the selector applied.
+ public BoardQuery ForEvaNumbers(params string[] evaNumbers) => this with { EvaNumbers = evaNumbers };
+
+ ///
+ /// Restricts the board to a Stada station id.
+ ///
+ /// Stada identifier.
+ /// A new query with the selector applied.
+ public BoardQuery ForStada(string stadaId) => this with { StadaId = stadaId };
+
+ ///
+ /// Restricts the board to one or more DHIDs.
+ ///
+ /// DHIDs of stop places.
+ /// A new query with the selector applied.
+ public BoardQuery ForDhids(params string[] dhids) => this with { Dhids = dhids };
+
+ ///
+ /// Filters the board to one or more platforms.
+ ///
+ /// Platform names.
+ /// A new query with the selector applied.
+ public BoardQuery OnPlatforms(params string[] platforms) => this with { Platforms = platforms };
+
+ ///
+ /// Sets the board configuration modes for extending the board to nearby stop places.
+ ///
+ /// Configuration modes.
+ /// A new query with the selector applied.
+ public BoardQuery WithBoardConfigurations(params string[] configurations) => this with { BoardConfigurations = configurations };
+
+ ///
+ /// Sets the start of the time window.
+ ///
+ /// Start date and time.
+ /// A new query with the time window applied.
+ public BoardQuery StartingAt(DateTime start) => this with { Start = start };
+
+ ///
+ /// Sets the end of the time window.
+ ///
+ /// End date and time.
+ /// A new query with the time window applied.
+ public BoardQuery EndingAt(DateTime end) => this with { End = end };
+
+ ///
+ /// Requests a fixed number of entries starting at .
+ ///
+ /// Number of entries.
+ /// A new query with the time window applied.
+ public BoardQuery ForNext(int entryCount) => this with { EntryCount = entryCount };
+
+ ///
+ /// Sets the transport types to include.
+ ///
+ /// Transport types.
+ /// A new query with the transport types applied.
+ public BoardQuery WithTransportTypes(params string[] transportTypes) => this with { TransportTypes = transportTypes };
+
+ ///
+ /// Sets the requested languages.
+ ///
+ /// ISO-639-3 language codes.
+ /// A new query with the languages applied.
+ public BoardQuery InLanguages(params string[] languages) => this with { Languages = languages };
+
+ ///
+ /// Sets the maximum number of entries per transport type.
+ ///
+ /// Maximum entries.
+ /// A new query with the limit applied.
+ public BoardQuery WithMaxEntriesPerTransportType(int max) => this with { MaxEntriesPerTransportType = max };
+
+ ///
+ /// Sets the maximum number of via stops per journey.
+ ///
+ /// Maximum via stops.
+ /// A new query with the limit applied.
+ public BoardQuery WithMaxViaStops(int max) => this with { MaxViaStops = max };
+
+ ///
+ /// Requests line colors in the response.
+ ///
+ /// A new query with the flag applied.
+ public BoardQuery WithLineColours() => this with { IncludeLineColours = true };
+
+ ///
+ /// Requests platform accessibility information in the response.
+ ///
+ /// A new query with the flag applied.
+ public BoardQuery WithPlatformAccessibility() => this with { IncludePlatformAccessibility = true };
+
+ ///
+ /// Excludes canceled entries from the response.
+ ///
+ /// A new query with the flag applied.
+ public BoardQuery WithoutCancellations() => this with { NoCancellations = true };
+
+ ///
+ /// Requests only replacement transports.
+ ///
+ /// A new query with the flag applied.
+ public BoardQuery WithOnlyReplacementTransports() => this with { OnlyReplacementTransports = true };
+
+ ///
+ /// Sorts results by best-known time.
+ ///
+ /// A new query with the sort order applied.
+ public BoardQuery SortByTime() => this with { SortBy = "TIME" };
+
+ ///
+ /// Sorts results by scheduled time.
+ ///
+ /// A new query with the sort order applied.
+ public BoardQuery SortByTimeSchedule() => this with { SortBy = "TIME_SCHEDULE" };
+}
diff --git a/source/DotBahn.Boards/BoardsClient.cs b/source/DotBahn.Boards/BoardsClient.cs
new file mode 100644
index 0000000..f5e77e4
--- /dev/null
+++ b/source/DotBahn.Boards/BoardsClient.cs
@@ -0,0 +1,80 @@
+using DotBahn.Boards.Internal.Contracts;
+using DotBahn.Boards.Internal.Json;
+using DotBahn.Boards.Internal.Transformers;
+using DotBahn.Boards.Internal.Utilities;
+using DotBahn.Boards.Models;
+using DotBahn.Boards.Models.Entries;
+using DotBahn.Common.Auth;
+using DotBahn.Common.Clients;
+using DotBahn.Common.Parsing;
+using DotBahn.Common.Transformer;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace DotBahn.Boards;
+
+///
+/// Client for accessing the Deutsche Bahn OpenBoards API.
+///
+public class BoardsClient : ClientBase, IBoardsClient {
+ private readonly IParser _arrivalParser;
+ private readonly IParser _departureParser;
+ private readonly ITransformer, ArrivalBoardResponseContract> _arrivalTransformer;
+ private readonly ITransformer, DepartureBoardResponseContract> _departureTransformer;
+
+ ///
+ protected override string ApiName => "boards";
+
+ ///
+ /// Client for accessing the Deutsche Bahn OpenBoards API.
+ ///
+ /// The HTTP client used for requests.
+ /// The provider used for retrieving access tokens.
+ /// The parser for arrival-board responses.
+ /// The parser for departure-board responses.
+ /// The transformer for arrival-board responses.
+ /// The transformer for departure-board responses.
+ [ActivatorUtilitiesConstructor]
+ internal BoardsClient(HttpClient http, IAuthorization authorization, IParser arrivalParser, IParser departureParser, ITransformer, ArrivalBoardResponseContract> arrivalTransformer, ITransformer, DepartureBoardResponseContract> departureTransformer) : base(http, authorization) {
+ _arrivalParser = arrivalParser;
+ _departureParser = departureParser;
+ _arrivalTransformer = arrivalTransformer;
+ _departureTransformer = departureTransformer;
+ }
+
+ ///
+ /// Client for accessing the Deutsche Bahn OpenBoards API.
+ ///
+ ///
+ /// Creates and owns its own . Dispose this instance to release it.
+ /// Use only when instantiating manually without a DI container.
+ ///
+ /// The options for this instance.
+ /// The auth credentials for the client.
+ /// Thrown when or is null.
+ public BoardsClient(ClientOptions options, AuthorizationOptions auth) : base(options, auth) {
+ _arrivalParser = new JsonParser(BoardsJsonContext.Default.ArrivalBoardResponseContract);
+ _departureParser = new JsonParser(BoardsJsonContext.Default.DepartureBoardResponseContract);
+ _arrivalTransformer = new ArrivalBoardTransformer();
+ _departureTransformer = new DepartureBoardTransformer();
+ }
+
+ ///
+ public async Task> GetArrivalsAsync(BoardQuery query, CancellationToken ct = default) {
+ ArgumentNullException.ThrowIfNull(query);
+
+ var request = QueryUtil.ToArrivalContract(query);
+ var response = await PostAsync("/arrivals", request, BoardsJsonContext.Default.OpenArrivalBoardRequestContract, _arrivalParser, "application/json", ct).ConfigureAwait(false);
+
+ return _arrivalTransformer.Transform(response);
+ }
+
+ ///
+ public async Task> GetDeparturesAsync(BoardQuery query, CancellationToken ct = default) {
+ ArgumentNullException.ThrowIfNull(query);
+
+ var request = QueryUtil.ToDepartureContract(query);
+ var response = await PostAsync("/departures", request, BoardsJsonContext.Default.OpenDepartureBoardRequestContract, _departureParser, "application/json", ct).ConfigureAwait(false);
+
+ return _departureTransformer.Transform(response);
+ }
+}
diff --git a/source/DotBahn.Boards/DotBahn.Boards.csproj b/source/DotBahn.Boards/DotBahn.Boards.csproj
new file mode 100644
index 0000000..3ef9abd
--- /dev/null
+++ b/source/DotBahn.Boards/DotBahn.Boards.csproj
@@ -0,0 +1,22 @@
+
+
+
+ true
+ DotBahn.Boards
+ .NET client for DB OpenBoards API.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/DotBahn.Boards/IBoardsClient.cs b/source/DotBahn.Boards/IBoardsClient.cs
new file mode 100644
index 0000000..1277b88
--- /dev/null
+++ b/source/DotBahn.Boards/IBoardsClient.cs
@@ -0,0 +1,31 @@
+using DotBahn.Boards.Models;
+using DotBahn.Boards.Models.Entries;
+
+namespace DotBahn.Boards;
+
+///
+/// Client for accessing the Deutsche Bahn OpenBoards API.
+///
+public interface IBoardsClient {
+ ///
+ /// Gets an arrival board for the specified query.
+ ///
+ /// The board query.
+ /// Cancellation token.
+ /// The arrival board.
+ /// Thrown when is null.
+ /// Thrown when the API responds with a non-success status code.
+ /// Thrown when the operation is canceled.
+ Task> GetArrivalsAsync(BoardQuery query, CancellationToken ct = default);
+
+ ///
+ /// Gets a departure board for the specified query.
+ ///
+ /// The board query.
+ /// Cancellation token.
+ /// The departure board.
+ /// Thrown when is null.
+ /// Thrown when the API responds with a non-success status code.
+ /// Thrown when the operation is canceled.
+ Task> GetDeparturesAsync(BoardQuery query, CancellationToken ct = default);
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/AdministrationExtendedMultiLanguageContract.cs b/source/DotBahn.Boards/Internal/Contracts/AdministrationExtendedMultiLanguageContract.cs
new file mode 100644
index 0000000..c037a21
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/AdministrationExtendedMultiLanguageContract.cs
@@ -0,0 +1,34 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for an extended administration multi-language.
+///
+[ExcludeFromCodeCoverage]
+internal record AdministrationExtendedMultiLanguageContract {
+ ///
+ /// Gets the administration identifier.
+ ///
+ [JsonPropertyName("administrationId")]
+ public string AdministrationId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the operator code.
+ ///
+ [JsonPropertyName("operatorCode")]
+ public string OperatorCode { get; init; } = string.Empty;
+
+ ///
+ /// Gets the operator name.
+ ///
+ [JsonPropertyName("operatorName")]
+ public string OperatorName { get; init; } = string.Empty;
+
+ ///
+ /// Gets the transport companies.
+ ///
+ [JsonPropertyName("transportCompanies")]
+ public List? TransportCompanies { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/ArrivalBoardResponseContract.cs b/source/DotBahn.Boards/Internal/Contracts/ArrivalBoardResponseContract.cs
new file mode 100644
index 0000000..c9ae02d
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/ArrivalBoardResponseContract.cs
@@ -0,0 +1,52 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for an arrival-board response.
+///
+[ExcludeFromCodeCoverage]
+internal record ArrivalBoardResponseContract {
+ ///
+ /// Gets the administrations.
+ ///
+ [JsonPropertyName("administrations")]
+ public List? Administrations { get; init; }
+
+ ///
+ /// Gets the arrivals.
+ ///
+ [JsonPropertyName("arrivals")]
+ public List? Arrivals { get; init; }
+
+ ///
+ /// Gets the disruption communications.
+ ///
+ [JsonPropertyName("disruptionCommunications")]
+ public List? DisruptionCommunications { get; init; }
+
+ ///
+ /// Gets the messages.
+ ///
+ [JsonPropertyName("messages")]
+ public MessagesMultiLanguageContract? Messages { get; init; }
+
+ ///
+ /// Gets the meta.
+ ///
+ [JsonPropertyName("meta")]
+ public BoardMetaContract Meta { get; init; } = new();
+
+ ///
+ /// Gets the stations.
+ ///
+ [JsonPropertyName("stations")]
+ public List? Stations { get; init; }
+
+ ///
+ /// Gets the stop places.
+ ///
+ [JsonPropertyName("stopPlaces")]
+ public List? StopPlaces { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/ArrivalContract.cs b/source/DotBahn.Boards/Internal/Contracts/ArrivalContract.cs
new file mode 100644
index 0000000..3b0f102
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/ArrivalContract.cs
@@ -0,0 +1,167 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+using DotBahn.Common.Parsing.Converters;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for an arrival.
+///
+[ExcludeFromCodeCoverage]
+internal record ArrivalContract {
+ ///
+ /// Gets a value indicating whether this is additional.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("additional")]
+ public bool Additional { get; init; }
+
+ ///
+ /// Gets the arrival identifier.
+ ///
+ [JsonPropertyName("arrivalId")]
+ public string ArrivalId { get; init; } = string.Empty;
+
+ ///
+ /// Gets a value indicating whether this is cancelled.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("cancelled")]
+ public bool Cancelled { get; init; }
+
+ ///
+ /// Gets the codeshares.
+ ///
+ [JsonPropertyName("codeshares")]
+ public List? Codeshares { get; init; }
+
+ ///
+ /// Gets the continuation by.
+ ///
+ [JsonPropertyName("continuationBy")]
+ public List? ContinuationBy { get; init; }
+
+ ///
+ /// Gets the EVA number.
+ ///
+ [JsonPropertyName("evaNumber")]
+ public string EvaNumber { get; init; } = string.Empty;
+
+ ///
+ /// Gets the journey identifier.
+ ///
+ [JsonPropertyName("journeyId")]
+ public string JourneyId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the journey information.
+ ///
+ [JsonPropertyName("journeyInfo")]
+ public JourneyInfoContract JourneyInfo { get; init; } = new();
+
+ ///
+ /// Gets the messages.
+ ///
+ [JsonPropertyName("messages")]
+ public List? Messages { get; init; }
+
+ ///
+ /// Gets a value indicating whether there is no passenger change.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("noPassengerChange")]
+ public bool NoPassengerChange { get; init; }
+
+ ///
+ /// Gets a value indicating whether this is on demand.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("onDemand")]
+ public bool OnDemand { get; init; }
+
+ ///
+ /// Gets a value indicating whether there were past disruptions.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("pastDisruptions")]
+ public bool? PastDisruptions { get; init; }
+
+ ///
+ /// Gets the platform.
+ ///
+ [JsonPropertyName("platform")]
+ public PlatformContract? Platform { get; init; }
+
+ ///
+ /// Gets the platform history.
+ ///
+ [JsonPropertyName("platformHistory")]
+ public List? PlatformHistory { get; init; }
+
+ ///
+ /// Gets the platform schedule.
+ ///
+ [JsonPropertyName("platformSchedule")]
+ public PlatformContract? PlatformSchedule { get; init; }
+
+ ///
+ /// Gets the relief by.
+ ///
+ [JsonPropertyName("reliefBy")]
+ public List? ReliefBy { get; init; }
+
+ ///
+ /// Gets the relief for.
+ ///
+ [JsonPropertyName("reliefFor")]
+ public List? ReliefFor { get; init; }
+
+ ///
+ /// Gets the replaced by.
+ ///
+ [JsonPropertyName("replacedBy")]
+ public List? ReplacedBy { get; init; }
+
+ ///
+ /// Gets the replacement for.
+ ///
+ [JsonPropertyName("replacementFor")]
+ public List? ReplacementFor { get; init; }
+
+ ///
+ /// Gets the time.
+ ///
+ [JsonPropertyName("time")]
+ public string Time { get; init; } = string.Empty;
+
+ ///
+ /// Gets the time schedule.
+ ///
+ [JsonPropertyName("timeSchedule")]
+ public string TimeSchedule { get; init; } = string.Empty;
+
+ ///
+ /// Gets the time type.
+ ///
+ [JsonPropertyName("timeType")]
+ public string TimeType { get; init; } = string.Empty;
+
+ ///
+ /// Gets the transport.
+ ///
+ [JsonPropertyName("transport")]
+ public TransportWithDirectionAndViaContract Transport { get; init; } = new();
+
+ ///
+ /// Gets the travels with.
+ ///
+ [JsonPropertyName("travelsWith")]
+ public List? TravelsWith { get; init; }
+
+ ///
+ /// Gets a value indicating whether the vehicle sequence is available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("vehicleSequenceAvailable")]
+ public bool? VehicleSequenceAvailable { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/BoardMetaContract.cs b/source/DotBahn.Boards/Internal/Contracts/BoardMetaContract.cs
new file mode 100644
index 0000000..1becedc
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/BoardMetaContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a board meta.
+///
+[ExcludeFromCodeCoverage]
+internal record BoardMetaContract {
+ ///
+ /// Gets the considered stop places.
+ ///
+ [JsonPropertyName("consideredStopPlaces")]
+ public List? ConsideredStopPlaces { get; init; }
+
+ ///
+ /// Gets the truncated transport types.
+ ///
+ [JsonPropertyName("truncatedTransportTypes")]
+ public List? TruncatedTransportTypes { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/CodeShareContract.cs b/source/DotBahn.Boards/Internal/Contracts/CodeShareContract.cs
new file mode 100644
index 0000000..7b57f96
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/CodeShareContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a codeshare.
+///
+[ExcludeFromCodeCoverage]
+internal record CodeShareContract {
+ ///
+ /// Gets the airline code.
+ ///
+ [JsonPropertyName("airlineCode")]
+ public string AirlineCode { get; init; } = string.Empty;
+
+ ///
+ /// Gets the flight number.
+ ///
+ [JsonPropertyName("flightnumber")]
+ public int Flightnumber { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/DepartureBoardResponseContract.cs b/source/DotBahn.Boards/Internal/Contracts/DepartureBoardResponseContract.cs
new file mode 100644
index 0000000..0194625
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/DepartureBoardResponseContract.cs
@@ -0,0 +1,52 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a departure-board response.
+///
+[ExcludeFromCodeCoverage]
+internal record DepartureBoardResponseContract {
+ ///
+ /// Gets the administrations.
+ ///
+ [JsonPropertyName("administrations")]
+ public List? Administrations { get; init; }
+
+ ///
+ /// Gets the departures.
+ ///
+ [JsonPropertyName("departures")]
+ public List? Departures { get; init; }
+
+ ///
+ /// Gets the disruption communications.
+ ///
+ [JsonPropertyName("disruptionCommunications")]
+ public List? DisruptionCommunications { get; init; }
+
+ ///
+ /// Gets the messages.
+ ///
+ [JsonPropertyName("messages")]
+ public MessagesMultiLanguageContract? Messages { get; init; }
+
+ ///
+ /// Gets the meta.
+ ///
+ [JsonPropertyName("meta")]
+ public BoardMetaContract Meta { get; init; } = new();
+
+ ///
+ /// Gets the stations.
+ ///
+ [JsonPropertyName("stations")]
+ public List? Stations { get; init; }
+
+ ///
+ /// Gets the stop places.
+ ///
+ [JsonPropertyName("stopPlaces")]
+ public List? StopPlaces { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/DepartureContract.cs b/source/DotBahn.Boards/Internal/Contracts/DepartureContract.cs
new file mode 100644
index 0000000..e2444a8
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/DepartureContract.cs
@@ -0,0 +1,167 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+using DotBahn.Common.Parsing.Converters;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a departure.
+///
+[ExcludeFromCodeCoverage]
+internal record DepartureContract {
+ ///
+ /// Gets a value indicating whether this is additional.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("additional")]
+ public bool Additional { get; init; }
+
+ ///
+ /// Gets a value indicating whether this is cancelled.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("cancelled")]
+ public bool Cancelled { get; init; }
+
+ ///
+ /// Gets the codeshares.
+ ///
+ [JsonPropertyName("codeshares")]
+ public List? Codeshares { get; init; }
+
+ ///
+ /// Gets the continuation for.
+ ///
+ [JsonPropertyName("continuationFor")]
+ public List? ContinuationFor { get; init; }
+
+ ///
+ /// Gets the departure identifier.
+ ///
+ [JsonPropertyName("departureId")]
+ public string DepartureId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the EVA number.
+ ///
+ [JsonPropertyName("evaNumber")]
+ public string EvaNumber { get; init; } = string.Empty;
+
+ ///
+ /// Gets a value indicating whether there are future disruptions.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("futureDisruptions")]
+ public bool? FutureDisruptions { get; init; }
+
+ ///
+ /// Gets the journey identifier.
+ ///
+ [JsonPropertyName("journeyId")]
+ public string JourneyId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the journey information.
+ ///
+ [JsonPropertyName("journeyInfo")]
+ public JourneyInfoContract JourneyInfo { get; init; } = new();
+
+ ///
+ /// Gets the messages.
+ ///
+ [JsonPropertyName("messages")]
+ public List? Messages { get; init; }
+
+ ///
+ /// Gets a value indicating whether there is no passenger change.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("noPassengerChange")]
+ public bool NoPassengerChange { get; init; }
+
+ ///
+ /// Gets a value indicating whether this is on demand.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("onDemand")]
+ public bool OnDemand { get; init; }
+
+ ///
+ /// Gets the platform.
+ ///
+ [JsonPropertyName("platform")]
+ public PlatformContract? Platform { get; init; }
+
+ ///
+ /// Gets the platform history.
+ ///
+ [JsonPropertyName("platformHistory")]
+ public List? PlatformHistory { get; init; }
+
+ ///
+ /// Gets the platform schedule.
+ ///
+ [JsonPropertyName("platformSchedule")]
+ public PlatformContract? PlatformSchedule { get; init; }
+
+ ///
+ /// Gets the relief by.
+ ///
+ [JsonPropertyName("reliefBy")]
+ public List? ReliefBy { get; init; }
+
+ ///
+ /// Gets the relief for.
+ ///
+ [JsonPropertyName("reliefFor")]
+ public List? ReliefFor { get; init; }
+
+ ///
+ /// Gets the replaced by.
+ ///
+ [JsonPropertyName("replacedBy")]
+ public List? ReplacedBy { get; init; }
+
+ ///
+ /// Gets the replacement for.
+ ///
+ [JsonPropertyName("replacementFor")]
+ public List? ReplacementFor { get; init; }
+
+ ///
+ /// Gets the time.
+ ///
+ [JsonPropertyName("time")]
+ public string Time { get; init; } = string.Empty;
+
+ ///
+ /// Gets the time schedule.
+ ///
+ [JsonPropertyName("timeSchedule")]
+ public string TimeSchedule { get; init; } = string.Empty;
+
+ ///
+ /// Gets the time type.
+ ///
+ [JsonPropertyName("timeType")]
+ public string TimeType { get; init; } = string.Empty;
+
+ ///
+ /// Gets the transport.
+ ///
+ [JsonPropertyName("transport")]
+ public TransportWithDirectionAndViaContract Transport { get; init; } = new();
+
+ ///
+ /// Gets the travels with.
+ ///
+ [JsonPropertyName("travelsWith")]
+ public List? TravelsWith { get; init; }
+
+ ///
+ /// Gets a value indicating whether the vehicle sequence is available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("vehicleSequenceAvailable")]
+ public bool? VehicleSequenceAvailable { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/DirectionInfoContract.cs b/source/DotBahn.Boards/Internal/Contracts/DirectionInfoContract.cs
new file mode 100644
index 0000000..5137dcc
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/DirectionInfoContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a direction information.
+///
+[ExcludeFromCodeCoverage]
+internal record DirectionInfoContract {
+ ///
+ /// Gets the stop places.
+ ///
+ [JsonPropertyName("stopPlaces")]
+ public List? StopPlaces { get; init; }
+
+ ///
+ /// Gets the texts.
+ ///
+ [JsonPropertyName("texts")]
+ public List? Texts { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/DisruptionCommunicationAttachmentContract.cs b/source/DotBahn.Boards/Internal/Contracts/DisruptionCommunicationAttachmentContract.cs
new file mode 100644
index 0000000..780f66f
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/DisruptionCommunicationAttachmentContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a disruption-communication attachment.
+///
+[ExcludeFromCodeCoverage]
+internal record DisruptionCommunicationAttachmentContract {
+ ///
+ /// Gets the label.
+ ///
+ [JsonPropertyName("label")]
+ public string Label { get; init; } = string.Empty;
+
+ ///
+ /// Gets the URL.
+ ///
+ [JsonPropertyName("url")]
+ public string Url { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/DisruptionCommunicationImageContract.cs b/source/DotBahn.Boards/Internal/Contracts/DisruptionCommunicationImageContract.cs
new file mode 100644
index 0000000..b53744f
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/DisruptionCommunicationImageContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a disruption-communication image.
+///
+[ExcludeFromCodeCoverage]
+internal record DisruptionCommunicationImageContract {
+ ///
+ /// Gets the label.
+ ///
+ [JsonPropertyName("label")]
+ public string Label { get; init; } = string.Empty;
+
+ ///
+ /// Gets the URL.
+ ///
+ [JsonPropertyName("url")]
+ public string Url { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/DisruptionCommunicationLinkContract.cs b/source/DotBahn.Boards/Internal/Contracts/DisruptionCommunicationLinkContract.cs
new file mode 100644
index 0000000..1c749dc
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/DisruptionCommunicationLinkContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a disruption-communication link.
+///
+[ExcludeFromCodeCoverage]
+internal record DisruptionCommunicationLinkContract {
+ ///
+ /// Gets the label.
+ ///
+ [JsonPropertyName("label")]
+ public string Label { get; init; } = string.Empty;
+
+ ///
+ /// Gets the URL.
+ ///
+ [JsonPropertyName("url")]
+ public string Url { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/ErrorDetailContract.cs b/source/DotBahn.Boards/Internal/Contracts/ErrorDetailContract.cs
new file mode 100644
index 0000000..fe230fe
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/ErrorDetailContract.cs
@@ -0,0 +1,34 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for an error detail.
+///
+[ExcludeFromCodeCoverage]
+internal record ErrorDetailContract {
+ ///
+ /// Gets the detail.
+ ///
+ [JsonPropertyName("detail")]
+ public string Detail { get; init; } = string.Empty;
+
+ ///
+ /// Gets the error code.
+ ///
+ [JsonPropertyName("errorCode")]
+ public string? ErrorCode { get; init; }
+
+ ///
+ /// Gets the field.
+ ///
+ [JsonPropertyName("field")]
+ public string Field { get; init; } = string.Empty;
+
+ ///
+ /// Gets the title.
+ ///
+ [JsonPropertyName("title")]
+ public string Title { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/ErrorResponseContract.cs b/source/DotBahn.Boards/Internal/Contracts/ErrorResponseContract.cs
new file mode 100644
index 0000000..5681baa
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/ErrorResponseContract.cs
@@ -0,0 +1,46 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for an error response.
+///
+[ExcludeFromCodeCoverage]
+internal record ErrorResponseContract {
+ ///
+ /// Gets the detail.
+ ///
+ [JsonPropertyName("detail")]
+ public string Detail { get; init; } = string.Empty;
+
+ ///
+ /// Gets the error code.
+ ///
+ [JsonPropertyName("errorCode")]
+ public string? ErrorCode { get; init; }
+
+ ///
+ /// Gets the errors.
+ ///
+ [JsonPropertyName("errors")]
+ public List? Errors { get; init; }
+
+ ///
+ /// Gets the instance identifier.
+ ///
+ [JsonPropertyName("instanceId")]
+ public string? InstanceId { get; init; }
+
+ ///
+ /// Gets the status.
+ ///
+ [JsonPropertyName("status")]
+ public string? Status { get; init; }
+
+ ///
+ /// Gets the title.
+ ///
+ [JsonPropertyName("title")]
+ public string Title { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/JourneyInfoContract.cs b/source/DotBahn.Boards/Internal/Contracts/JourneyInfoContract.cs
new file mode 100644
index 0000000..81d09f7
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/JourneyInfoContract.cs
@@ -0,0 +1,72 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+using DotBahn.Common.Parsing.Converters;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a journey information.
+///
+[ExcludeFromCodeCoverage]
+internal record JourneyInfoContract {
+ ///
+ /// Gets the destination.
+ ///
+ [JsonPropertyName("destination")]
+ public StopPlaceRefWithCancelContract Destination { get; init; } = new();
+
+ ///
+ /// Gets the differing destination.
+ ///
+ [JsonPropertyName("differingDestination")]
+ public StopPlaceRefContract? DifferingDestination { get; init; }
+
+ ///
+ /// Gets the differing origin.
+ ///
+ [JsonPropertyName("differingOrigin")]
+ public StopPlaceRefContract? DifferingOrigin { get; init; }
+
+ ///
+ /// Gets the header administration identifier.
+ ///
+ [JsonPropertyName("headerAdministrationId")]
+ public string HeaderAdministrationId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the header journey number.
+ ///
+ [JsonPropertyName("headerJourneyNumber")]
+ public int HeaderJourneyNumber { get; init; }
+
+ ///
+ /// Gets a value indicating whether the journey is cancelled.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("journeyCancelled")]
+ public bool JourneyCancelled { get; init; }
+
+ ///
+ /// Gets the origin.
+ ///
+ [JsonPropertyName("origin")]
+ public StopPlaceRefWithCancelContract Origin { get; init; } = new();
+
+ ///
+ /// Gets the scheduled start time.
+ ///
+ [JsonPropertyName("scheduledStartTime")]
+ public string ScheduledStartTime { get; init; } = string.Empty;
+
+ ///
+ /// Gets the transport at start.
+ ///
+ [JsonPropertyName("transportAtStart")]
+ public TransportContract TransportAtStart { get; init; } = new();
+
+ ///
+ /// Gets the type.
+ ///
+ [JsonPropertyName("type")]
+ public string Type { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/LineChipVisualizationContract.cs b/source/DotBahn.Boards/Internal/Contracts/LineChipVisualizationContract.cs
new file mode 100644
index 0000000..b69c15d
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/LineChipVisualizationContract.cs
@@ -0,0 +1,34 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a line chip visualization.
+///
+[ExcludeFromCodeCoverage]
+internal record LineChipVisualizationContract {
+ ///
+ /// Gets the differing boundary colour.
+ ///
+ [JsonPropertyName("differingBoundaryColour")]
+ public string? DifferingBoundaryColour { get; init; }
+
+ ///
+ /// Gets the differing fill colour.
+ ///
+ [JsonPropertyName("differingFillColour")]
+ public string? DifferingFillColour { get; init; }
+
+ ///
+ /// Gets the differing text colour.
+ ///
+ [JsonPropertyName("differingTextColour")]
+ public string? DifferingTextColour { get; init; }
+
+ ///
+ /// Gets the secondary fill colour.
+ ///
+ [JsonPropertyName("secondaryFillColour")]
+ public string? SecondaryFillColour { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/LineColourContract.cs b/source/DotBahn.Boards/Internal/Contracts/LineColourContract.cs
new file mode 100644
index 0000000..ad022e8
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/LineColourContract.cs
@@ -0,0 +1,34 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a line colour.
+///
+[ExcludeFromCodeCoverage]
+internal record LineColourContract {
+ ///
+ /// Gets the chip visualization.
+ ///
+ [JsonPropertyName("chipVisualization")]
+ public LineChipVisualizationContract? ChipVisualization { get; init; }
+
+ ///
+ /// Gets the primary colour.
+ ///
+ [JsonPropertyName("primaryColour")]
+ public string PrimaryColour { get; init; } = string.Empty;
+
+ ///
+ /// Gets the primary text colour.
+ ///
+ [JsonPropertyName("primaryTextColour")]
+ public string PrimaryTextColour { get; init; } = string.Empty;
+
+ ///
+ /// Gets the stroke visualization.
+ ///
+ [JsonPropertyName("strokeVisualization")]
+ public LineStrokeVisualizationContract? StrokeVisualization { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/LineInfoContract.cs b/source/DotBahn.Boards/Internal/Contracts/LineInfoContract.cs
new file mode 100644
index 0000000..0f95d2c
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/LineInfoContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a line information.
+///
+[ExcludeFromCodeCoverage]
+internal record LineInfoContract {
+ ///
+ /// Gets the colour.
+ ///
+ [JsonPropertyName("colour")]
+ public LineColourContract? Colour { get; init; }
+
+ ///
+ /// Gets the name.
+ ///
+ [JsonPropertyName("name")]
+ public string Name { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/LineStrokeVisualizationContract.cs b/source/DotBahn.Boards/Internal/Contracts/LineStrokeVisualizationContract.cs
new file mode 100644
index 0000000..b9a9ad5
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/LineStrokeVisualizationContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a line stroke visualization.
+///
+[ExcludeFromCodeCoverage]
+internal record LineStrokeVisualizationContract {
+ ///
+ /// Gets the differing boundary colour.
+ ///
+ [JsonPropertyName("differingBoundaryColour")]
+ public string? DifferingBoundaryColour { get; init; }
+
+ ///
+ /// Gets the secondary fill colour.
+ ///
+ [JsonPropertyName("secondaryFillColour")]
+ public string? SecondaryFillColour { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/MessageAttributeDescriptionContract.cs b/source/DotBahn.Boards/Internal/Contracts/MessageAttributeDescriptionContract.cs
new file mode 100644
index 0000000..2d8b3d2
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/MessageAttributeDescriptionContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a message attribute description.
+///
+[ExcludeFromCodeCoverage]
+internal record MessageAttributeDescriptionContract {
+ ///
+ /// Gets the language.
+ ///
+ [JsonPropertyName("language")]
+ public string Language { get; init; } = string.Empty;
+
+ ///
+ /// Gets the text.
+ ///
+ [JsonPropertyName("text")]
+ public string Text { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/MessageAttributeMultiLanguageContract.cs b/source/DotBahn.Boards/Internal/Contracts/MessageAttributeMultiLanguageContract.cs
new file mode 100644
index 0000000..d4c2619
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/MessageAttributeMultiLanguageContract.cs
@@ -0,0 +1,40 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a journey attribute multi-language.
+///
+[ExcludeFromCodeCoverage]
+internal record MessageAttributeMultiLanguageContract {
+ ///
+ /// Gets the code.
+ ///
+ [JsonPropertyName("code")]
+ public string Code { get; init; } = string.Empty;
+
+ ///
+ /// Gets the descriptions.
+ ///
+ [JsonPropertyName("descriptions")]
+ public List? Descriptions { get; init; }
+
+ ///
+ /// Gets the display priority.
+ ///
+ [JsonPropertyName("displayPriority")]
+ public int? DisplayPriority { get; init; }
+
+ ///
+ /// Gets the display priority detail.
+ ///
+ [JsonPropertyName("displayPriorityDetail")]
+ public int? DisplayPriorityDetail { get; init; }
+
+ ///
+ /// Gets the message identifier.
+ ///
+ [JsonPropertyName("messageID")]
+ public int MessageId { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/MessageDisruptionCommunicationDescriptionContract.cs b/source/DotBahn.Boards/Internal/Contracts/MessageDisruptionCommunicationDescriptionContract.cs
new file mode 100644
index 0000000..159d4c5
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/MessageDisruptionCommunicationDescriptionContract.cs
@@ -0,0 +1,46 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a disruption-communication description.
+///
+[ExcludeFromCodeCoverage]
+internal record MessageDisruptionCommunicationDescriptionContract {
+ ///
+ /// Gets the attachments.
+ ///
+ [JsonPropertyName("attachments")]
+ public List? Attachments { get; init; }
+
+ ///
+ /// Gets the images.
+ ///
+ [JsonPropertyName("images")]
+ public List? Images { get; init; }
+
+ ///
+ /// Gets the language.
+ ///
+ [JsonPropertyName("language")]
+ public string Language { get; init; } = string.Empty;
+
+ ///
+ /// Gets the links.
+ ///
+ [JsonPropertyName("links")]
+ public List? Links { get; init; }
+
+ ///
+ /// Gets the text.
+ ///
+ [JsonPropertyName("text")]
+ public string Text { get; init; } = string.Empty;
+
+ ///
+ /// Gets the short text.
+ ///
+ [JsonPropertyName("textShort")]
+ public string? TextShort { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/MessageDisruptionCommunicationMultiLanguageContract.cs b/source/DotBahn.Boards/Internal/Contracts/MessageDisruptionCommunicationMultiLanguageContract.cs
new file mode 100644
index 0000000..3050471
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/MessageDisruptionCommunicationMultiLanguageContract.cs
@@ -0,0 +1,60 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+using DotBahn.Common.Parsing.Converters;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a disruption-communication multi-language.
+///
+[ExcludeFromCodeCoverage]
+internal record MessageDisruptionCommunicationMultiLanguageContract {
+ ///
+ /// Gets the cause.
+ ///
+ [JsonPropertyName("cause")]
+ public string? Cause { get; init; }
+
+ ///
+ /// Gets the descriptions.
+ ///
+ [JsonPropertyName("descriptions")]
+ public List? Descriptions { get; init; }
+
+ ///
+ /// Gets the display priority.
+ ///
+ [JsonPropertyName("displayPriority")]
+ public int? DisplayPriority { get; init; }
+
+ ///
+ /// Gets the disruption communication identifier.
+ ///
+ [JsonPropertyName("disruptionCommunicationID")]
+ public string DisruptionCommunicationId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the disruption identifier.
+ ///
+ [JsonPropertyName("disruptionID")]
+ public string DisruptionId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the effect.
+ ///
+ [JsonPropertyName("effect")]
+ public string Effect { get; init; } = string.Empty;
+
+ ///
+ /// Gets a value indicating whether alternatives are available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("hasAlternatives")]
+ public bool? HasAlternatives { get; init; }
+
+ ///
+ /// Gets the message identifier.
+ ///
+ [JsonPropertyName("messageID")]
+ public int MessageId { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/MessageNoteDescriptionContract.cs b/source/DotBahn.Boards/Internal/Contracts/MessageNoteDescriptionContract.cs
new file mode 100644
index 0000000..82369e7
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/MessageNoteDescriptionContract.cs
@@ -0,0 +1,46 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a note description.
+///
+[ExcludeFromCodeCoverage]
+internal record MessageNoteDescriptionContract {
+ ///
+ /// Gets the attachments.
+ ///
+ [JsonPropertyName("attachments")]
+ public List? Attachments { get; init; }
+
+ ///
+ /// Gets the images.
+ ///
+ [JsonPropertyName("images")]
+ public List? Images { get; init; }
+
+ ///
+ /// Gets the language.
+ ///
+ [JsonPropertyName("language")]
+ public string Language { get; init; } = string.Empty;
+
+ ///
+ /// Gets the links.
+ ///
+ [JsonPropertyName("links")]
+ public List? Links { get; init; }
+
+ ///
+ /// Gets the text.
+ ///
+ [JsonPropertyName("text")]
+ public string Text { get; init; } = string.Empty;
+
+ ///
+ /// Gets the short text.
+ ///
+ [JsonPropertyName("textShort")]
+ public string? TextShort { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/MessageNoteMultiLanguageContract.cs b/source/DotBahn.Boards/Internal/Contracts/MessageNoteMultiLanguageContract.cs
new file mode 100644
index 0000000..2f213d9
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/MessageNoteMultiLanguageContract.cs
@@ -0,0 +1,52 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a note multi-language.
+///
+[ExcludeFromCodeCoverage]
+internal record MessageNoteMultiLanguageContract {
+ ///
+ /// Gets the category.
+ ///
+ [JsonPropertyName("category")]
+ public string? Category { get; init; }
+
+ ///
+ /// Gets the code.
+ ///
+ [JsonPropertyName("code")]
+ public string? Code { get; init; }
+
+ ///
+ /// Gets the descriptions.
+ ///
+ [JsonPropertyName("descriptions")]
+ public List? Descriptions { get; init; }
+
+ ///
+ /// Gets the display priority.
+ ///
+ [JsonPropertyName("displayPriority")]
+ public int? DisplayPriority { get; init; }
+
+ ///
+ /// Gets the disruption communication identifier.
+ ///
+ [JsonPropertyName("disruptionCommunicationID")]
+ public string? DisruptionCommunicationId { get; init; }
+
+ ///
+ /// Gets the disruption identifier.
+ ///
+ [JsonPropertyName("disruptionID")]
+ public string? DisruptionId { get; init; }
+
+ ///
+ /// Gets the message identifier.
+ ///
+ [JsonPropertyName("messageID")]
+ public int MessageId { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/MessageRisCauseCodeDescriptionContract.cs b/source/DotBahn.Boards/Internal/Contracts/MessageRisCauseCodeDescriptionContract.cs
new file mode 100644
index 0000000..540bc2c
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/MessageRisCauseCodeDescriptionContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a RIS cause-code description.
+///
+[ExcludeFromCodeCoverage]
+internal record MessageRisCauseCodeDescriptionContract {
+ ///
+ /// Gets the language.
+ ///
+ [JsonPropertyName("language")]
+ public string Language { get; init; } = string.Empty;
+
+ ///
+ /// Gets the text.
+ ///
+ [JsonPropertyName("text")]
+ public string Text { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/MessageRisCauseCodeMultiLanguageContract.cs b/source/DotBahn.Boards/Internal/Contracts/MessageRisCauseCodeMultiLanguageContract.cs
new file mode 100644
index 0000000..00ff9a4
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/MessageRisCauseCodeMultiLanguageContract.cs
@@ -0,0 +1,28 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a RIS cause-code multi-language.
+///
+[ExcludeFromCodeCoverage]
+internal record MessageRisCauseCodeMultiLanguageContract {
+ ///
+ /// Gets the code.
+ ///
+ [JsonPropertyName("code")]
+ public string Code { get; init; } = string.Empty;
+
+ ///
+ /// Gets the descriptions.
+ ///
+ [JsonPropertyName("descriptions")]
+ public List? Descriptions { get; init; }
+
+ ///
+ /// Gets the message identifier.
+ ///
+ [JsonPropertyName("messageID")]
+ public int MessageId { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/MessageRisQualityDeviationDescriptionContract.cs b/source/DotBahn.Boards/Internal/Contracts/MessageRisQualityDeviationDescriptionContract.cs
new file mode 100644
index 0000000..a22bcc2
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/MessageRisQualityDeviationDescriptionContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a RIS quality-deviation description.
+///
+[ExcludeFromCodeCoverage]
+internal record MessageRisQualityDeviationDescriptionContract {
+ ///
+ /// Gets the language.
+ ///
+ [JsonPropertyName("language")]
+ public string Language { get; init; } = string.Empty;
+
+ ///
+ /// Gets the text.
+ ///
+ [JsonPropertyName("text")]
+ public string Text { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/MessageRisQualityDeviationMultiLanguageContract.cs b/source/DotBahn.Boards/Internal/Contracts/MessageRisQualityDeviationMultiLanguageContract.cs
new file mode 100644
index 0000000..0de3dd7
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/MessageRisQualityDeviationMultiLanguageContract.cs
@@ -0,0 +1,28 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a RIS quality-deviation multi-language.
+///
+[ExcludeFromCodeCoverage]
+internal record MessageRisQualityDeviationMultiLanguageContract {
+ ///
+ /// Gets the code.
+ ///
+ [JsonPropertyName("code")]
+ public string Code { get; init; } = string.Empty;
+
+ ///
+ /// Gets the descriptions.
+ ///
+ [JsonPropertyName("descriptions")]
+ public List? Descriptions { get; init; }
+
+ ///
+ /// Gets the message identifier.
+ ///
+ [JsonPropertyName("messageID")]
+ public int MessageId { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/MessagesMultiLanguageContract.cs b/source/DotBahn.Boards/Internal/Contracts/MessagesMultiLanguageContract.cs
new file mode 100644
index 0000000..8e3df42
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/MessagesMultiLanguageContract.cs
@@ -0,0 +1,40 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a messages multi-language.
+///
+[ExcludeFromCodeCoverage]
+internal record MessagesMultiLanguageContract {
+ ///
+ /// Gets the attributes.
+ ///
+ [JsonPropertyName("attributes")]
+ public List? Attributes { get; init; }
+
+ ///
+ /// Gets the disruptions.
+ ///
+ [JsonPropertyName("disruptions")]
+ public List? Disruptions { get; init; }
+
+ ///
+ /// Gets the notes.
+ ///
+ [JsonPropertyName("notes")]
+ public List? Notes { get; init; }
+
+ ///
+ /// Gets the RIS cause codes.
+ ///
+ [JsonPropertyName("risCauseCodes")]
+ public List? RisCauseCodes { get; init; }
+
+ ///
+ /// Gets the RIS quality deviations.
+ ///
+ [JsonPropertyName("risQualityDeviations")]
+ public List? RisQualityDeviations { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/OpenArrivalBoardRequestContract.cs b/source/DotBahn.Boards/Internal/Contracts/OpenArrivalBoardRequestContract.cs
new file mode 100644
index 0000000..06a0cba
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/OpenArrivalBoardRequestContract.cs
@@ -0,0 +1,81 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+using DotBahn.Common.Parsing.Converters;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for an arrival-board request.
+///
+[ExcludeFromCodeCoverage]
+internal record OpenArrivalBoardRequestContract {
+ ///
+ /// Gets a value indicating whether line colours are included.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("includeLineColours")]
+ public bool IncludeLineColours { get; init; }
+
+ ///
+ /// Gets a value indicating whether platform accessibility is included.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("includePlatformAccessibility")]
+ public bool IncludePlatformAccessibility { get; init; }
+
+ ///
+ /// Gets the languages.
+ ///
+ [JsonPropertyName("languages")]
+ public List? Languages { get; init; }
+
+ ///
+ /// Gets the maximum entries per transport type.
+ ///
+ [JsonPropertyName("maxEntriesPerTransportType")]
+ public int MaxEntriesPerTransportType { get; init; } = 25;
+
+ ///
+ /// Gets the maximum via stops.
+ ///
+ [JsonPropertyName("maxViaStops")]
+ public int MaxViaStops { get; init; } = 3;
+
+ ///
+ /// Gets a value indicating whether cancellations are excluded.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("noCancellations")]
+ public bool NoCancellations { get; init; }
+
+ ///
+ /// Gets a value indicating whether only replacement transports are included.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("onlyReplacementTransports")]
+ public bool OnlyReplacementTransports { get; init; }
+
+ ///
+ /// Gets the sort by.
+ ///
+ [JsonPropertyName("sortBy")]
+ public string? SortBy { get; init; }
+
+ ///
+ /// Gets the stop-place or station.
+ ///
+ [JsonPropertyName("stopPlaceOrStation")]
+ public StopPlaceOrStationRequestContract StopPlaceOrStation { get; init; } = new();
+
+ ///
+ /// Gets the time window.
+ ///
+ [JsonPropertyName("timeWindow")]
+ public TimeWindowContract? TimeWindow { get; init; }
+
+ ///
+ /// Gets the transport types.
+ ///
+ [JsonPropertyName("transportTypes")]
+ public List? TransportTypes { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/OpenDepartureBoardRequestContract.cs b/source/DotBahn.Boards/Internal/Contracts/OpenDepartureBoardRequestContract.cs
new file mode 100644
index 0000000..f78359a
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/OpenDepartureBoardRequestContract.cs
@@ -0,0 +1,81 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+using DotBahn.Common.Parsing.Converters;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a departure-board request.
+///
+[ExcludeFromCodeCoverage]
+internal record OpenDepartureBoardRequestContract {
+ ///
+ /// Gets a value indicating whether line colours are included.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("includeLineColours")]
+ public bool IncludeLineColours { get; init; }
+
+ ///
+ /// Gets a value indicating whether platform accessibility is included.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("includePlatformAccessibility")]
+ public bool IncludePlatformAccessibility { get; init; }
+
+ ///
+ /// Gets the languages.
+ ///
+ [JsonPropertyName("languages")]
+ public List? Languages { get; init; }
+
+ ///
+ /// Gets the maximum entries per transport type.
+ ///
+ [JsonPropertyName("maxEntriesPerTransportType")]
+ public int MaxEntriesPerTransportType { get; init; } = 25;
+
+ ///
+ /// Gets the maximum via stops.
+ ///
+ [JsonPropertyName("maxViaStops")]
+ public int MaxViaStops { get; init; } = 3;
+
+ ///
+ /// Gets a value indicating whether cancellations are excluded.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("noCancellations")]
+ public bool NoCancellations { get; init; }
+
+ ///
+ /// Gets a value indicating whether only replacement transports are included.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("onlyReplacementTransports")]
+ public bool OnlyReplacementTransports { get; init; }
+
+ ///
+ /// Gets the sort by.
+ ///
+ [JsonPropertyName("sortBy")]
+ public string? SortBy { get; init; }
+
+ ///
+ /// Gets the stop-place or station.
+ ///
+ [JsonPropertyName("stopPlaceOrStation")]
+ public StopPlaceOrStationRequestContract StopPlaceOrStation { get; init; } = new();
+
+ ///
+ /// Gets the time window.
+ ///
+ [JsonPropertyName("timeWindow")]
+ public TimeWindowContract? TimeWindow { get; init; }
+
+ ///
+ /// Gets the transport types.
+ ///
+ [JsonPropertyName("transportTypes")]
+ public List? TransportTypes { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/PlatformAccessibilityContract.cs b/source/DotBahn.Boards/Internal/Contracts/PlatformAccessibilityContract.cs
new file mode 100644
index 0000000..a1ed60b
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/PlatformAccessibilityContract.cs
@@ -0,0 +1,88 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+using DotBahn.Common.Parsing.Converters;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a platform accessibility.
+///
+[ExcludeFromCodeCoverage]
+internal record PlatformAccessibilityContract {
+ ///
+ /// Gets a value indicating whether audible signals are available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("audibleSignalsAvailable")]
+ public bool AudibleSignalsAvailable { get; init; }
+
+ ///
+ /// Gets a value indicating whether an automatic door is available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("automaticDoor")]
+ public bool AutomaticDoor { get; init; }
+
+ ///
+ /// Gets a value indicating whether boarding aid is available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("boardingAid")]
+ public bool BoardingAid { get; init; }
+
+ ///
+ /// Gets a value indicating whether a passenger information display is available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("passengerInformationDisplay")]
+ public bool PassengerInformationDisplay { get; init; }
+
+ ///
+ /// Gets a value indicating whether a platform sign is available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("platformSign")]
+ public bool PlatformSign { get; init; }
+
+ ///
+ /// Gets a value indicating whether stairs marking is available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("stairsMarking")]
+ public bool StairsMarking { get; init; }
+
+ ///
+ /// Gets a value indicating whether a standard platform height is available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("standardPlatformHeight")]
+ public bool StandardPlatformHeight { get; init; }
+
+ ///
+ /// Gets a value indicating whether step-free access is available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("stepFreeAccess")]
+ public bool StepFreeAccess { get; init; }
+
+ ///
+ /// Gets a value indicating whether tactile guiding strips are available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("tactileGuidingStrips")]
+ public bool TactileGuidingStrips { get; init; }
+
+ ///
+ /// Gets a value indicating whether a tactile handrail label is available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("tactileHandrailLabel")]
+ public bool TactileHandrailLabel { get; init; }
+
+ ///
+ /// Gets a value indicating whether tactile platform access is available.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("tactilePlatformAccess")]
+ public bool TactilePlatformAccess { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/PlatformContract.cs b/source/DotBahn.Boards/Internal/Contracts/PlatformContract.cs
new file mode 100644
index 0000000..5768648
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/PlatformContract.cs
@@ -0,0 +1,28 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a platform.
+///
+[ExcludeFromCodeCoverage]
+internal record PlatformContract {
+ ///
+ /// Gets the accessibility.
+ ///
+ [JsonPropertyName("accessibility")]
+ public PlatformAccessibilityContract? Accessibility { get; init; }
+
+ ///
+ /// Gets the IFOPT.
+ ///
+ [JsonPropertyName("ifopt")]
+ public string? Ifopt { get; init; }
+
+ ///
+ /// Gets the name.
+ ///
+ [JsonPropertyName("name")]
+ public string Name { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/PlatformHistoryContract.cs b/source/DotBahn.Boards/Internal/Contracts/PlatformHistoryContract.cs
new file mode 100644
index 0000000..d42337a
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/PlatformHistoryContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a platform history entry.
+///
+[ExcludeFromCodeCoverage]
+internal record PlatformHistoryContract {
+ ///
+ /// Gets the IFOPT.
+ ///
+ [JsonPropertyName("ifopt")]
+ public string? Ifopt { get; init; }
+
+ ///
+ /// Gets the name.
+ ///
+ [JsonPropertyName("name")]
+ public string Name { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/ReplacementTransportContract.cs b/source/DotBahn.Boards/Internal/Contracts/ReplacementTransportContract.cs
new file mode 100644
index 0000000..c8c1403
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/ReplacementTransportContract.cs
@@ -0,0 +1,16 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a replacement transport.
+///
+[ExcludeFromCodeCoverage]
+internal record ReplacementTransportContract {
+ ///
+ /// Gets the real type.
+ ///
+ [JsonPropertyName("realType")]
+ public string RealType { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/StationMultiLanguageContract.cs b/source/DotBahn.Boards/Internal/Contracts/StationMultiLanguageContract.cs
new file mode 100644
index 0000000..64f82fa
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/StationMultiLanguageContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a station multi-language.
+///
+[ExcludeFromCodeCoverage]
+internal record StationMultiLanguageContract {
+ ///
+ /// Gets the localized names.
+ ///
+ [JsonPropertyName("localizedNames")]
+ public List? LocalizedNames { get; init; }
+
+ ///
+ /// Gets the STADA identifier.
+ ///
+ [JsonPropertyName("stada")]
+ public string Stada { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/StationNameMultiLanguageContract.cs b/source/DotBahn.Boards/Internal/Contracts/StationNameMultiLanguageContract.cs
new file mode 100644
index 0000000..783c0d5
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/StationNameMultiLanguageContract.cs
@@ -0,0 +1,22 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a station name multi-language.
+///
+[ExcludeFromCodeCoverage]
+internal record StationNameMultiLanguageContract {
+ ///
+ /// Gets the language.
+ ///
+ [JsonPropertyName("language")]
+ public string Language { get; init; } = string.Empty;
+
+ ///
+ /// Gets the name.
+ ///
+ [JsonPropertyName("name")]
+ public string Name { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/StopPlaceMultiLanguageContract.cs b/source/DotBahn.Boards/Internal/Contracts/StopPlaceMultiLanguageContract.cs
new file mode 100644
index 0000000..3d71bd4
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/StopPlaceMultiLanguageContract.cs
@@ -0,0 +1,34 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a stop-place multi-language.
+///
+[ExcludeFromCodeCoverage]
+internal record StopPlaceMultiLanguageContract {
+ ///
+ /// Gets the EVA number.
+ ///
+ [JsonPropertyName("evaNumber")]
+ public string EvaNumber { get; init; } = string.Empty;
+
+ ///
+ /// Gets the IFOPT.
+ ///
+ [JsonPropertyName("ifopt")]
+ public string? Ifopt { get; init; }
+
+ ///
+ /// Gets the localized names.
+ ///
+ [JsonPropertyName("localizedNames")]
+ public List? LocalizedNames { get; init; }
+
+ ///
+ /// Gets the STADA identifier.
+ ///
+ [JsonPropertyName("stada")]
+ public string? Stada { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/StopPlaceNameMultiLanguageContract.cs b/source/DotBahn.Boards/Internal/Contracts/StopPlaceNameMultiLanguageContract.cs
new file mode 100644
index 0000000..021851a
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/StopPlaceNameMultiLanguageContract.cs
@@ -0,0 +1,34 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a stop-place name multi-language.
+///
+[ExcludeFromCodeCoverage]
+internal record StopPlaceNameMultiLanguageContract {
+ ///
+ /// Gets the language.
+ ///
+ [JsonPropertyName("language")]
+ public string Language { get; init; } = string.Empty;
+
+ ///
+ /// Gets the name.
+ ///
+ [JsonPropertyName("name")]
+ public string Name { get; init; } = string.Empty;
+
+ ///
+ /// Gets the symbol.
+ ///
+ [JsonPropertyName("symbol")]
+ public string? Symbol { get; init; }
+
+ ///
+ /// Gets the symbol name.
+ ///
+ [JsonPropertyName("symbolName")]
+ public string? SymbolName { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/StopPlaceOrStationRequestContract.cs b/source/DotBahn.Boards/Internal/Contracts/StopPlaceOrStationRequestContract.cs
new file mode 100644
index 0000000..29e0c26
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/StopPlaceOrStationRequestContract.cs
@@ -0,0 +1,40 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a stop-place or station request.
+///
+[ExcludeFromCodeCoverage]
+internal record StopPlaceOrStationRequestContract {
+ ///
+ /// Gets the board configurations.
+ ///
+ [JsonPropertyName("boardConfigurations")]
+ public List? BoardConfigurations { get; init; }
+
+ ///
+ /// Gets the DHIDs.
+ ///
+ [JsonPropertyName("dhids")]
+ public List? Dhids { get; init; }
+
+ ///
+ /// Gets the EVA numbers.
+ ///
+ [JsonPropertyName("evaNumbers")]
+ public List? EvaNumbers { get; init; }
+
+ ///
+ /// Gets the platforms.
+ ///
+ [JsonPropertyName("platforms")]
+ public List? Platforms { get; init; }
+
+ ///
+ /// Gets the STADA identifier.
+ ///
+ [JsonPropertyName("stada")]
+ public string? Stada { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/StopPlaceRefContract.cs b/source/DotBahn.Boards/Internal/Contracts/StopPlaceRefContract.cs
new file mode 100644
index 0000000..57e634d
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/StopPlaceRefContract.cs
@@ -0,0 +1,16 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a stop-place reference.
+///
+[ExcludeFromCodeCoverage]
+internal record StopPlaceRefContract {
+ ///
+ /// Gets the EVA number.
+ ///
+ [JsonPropertyName("evaNumber")]
+ public string EvaNumber { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/StopPlaceRefViaContract.cs b/source/DotBahn.Boards/Internal/Contracts/StopPlaceRefViaContract.cs
new file mode 100644
index 0000000..3ae1d4f
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/StopPlaceRefViaContract.cs
@@ -0,0 +1,37 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+using DotBahn.Common.Parsing.Converters;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a via stop-place reference.
+///
+[ExcludeFromCodeCoverage]
+internal record StopPlaceRefViaContract {
+ ///
+ /// Gets a value indicating whether this is additional.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("additional")]
+ public bool Additional { get; init; }
+
+ ///
+ /// Gets a value indicating whether this is cancelled.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("cancelled")]
+ public bool Cancelled { get; init; }
+
+ ///
+ /// Gets the display priority.
+ ///
+ [JsonPropertyName("displayPriority")]
+ public int DisplayPriority { get; init; }
+
+ ///
+ /// Gets the EVA number.
+ ///
+ [JsonPropertyName("evaNumber")]
+ public string EvaNumber { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/StopPlaceRefWithCancelContract.cs b/source/DotBahn.Boards/Internal/Contracts/StopPlaceRefWithCancelContract.cs
new file mode 100644
index 0000000..7f78d62
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/StopPlaceRefWithCancelContract.cs
@@ -0,0 +1,24 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+using DotBahn.Common.Parsing.Converters;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a stop-place reference with cancellation.
+///
+[ExcludeFromCodeCoverage]
+internal record StopPlaceRefWithCancelContract {
+ ///
+ /// Gets a value indicating whether this is cancelled.
+ ///
+ [JsonConverter(typeof(BahnDialectJsonConverter))]
+ [JsonPropertyName("cancelled")]
+ public bool Cancelled { get; init; }
+
+ ///
+ /// Gets the EVA number.
+ ///
+ [JsonPropertyName("evaNumber")]
+ public string EvaNumber { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/TimeWindowContract.cs b/source/DotBahn.Boards/Internal/Contracts/TimeWindowContract.cs
new file mode 100644
index 0000000..6241bdb
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/TimeWindowContract.cs
@@ -0,0 +1,28 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a time window.
+///
+[ExcludeFromCodeCoverage]
+internal record TimeWindowContract {
+ ///
+ /// Gets the entry count.
+ ///
+ [JsonPropertyName("entryCount")]
+ public int? EntryCount { get; init; }
+
+ ///
+ /// Gets the time end.
+ ///
+ [JsonPropertyName("timeEnd")]
+ public string? TimeEnd { get; init; }
+
+ ///
+ /// Gets the time start.
+ ///
+ [JsonPropertyName("timeStart")]
+ public string? TimeStart { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/TransportCompanyMultiLanguageContract.cs b/source/DotBahn.Boards/Internal/Contracts/TransportCompanyMultiLanguageContract.cs
new file mode 100644
index 0000000..82b9a34
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/TransportCompanyMultiLanguageContract.cs
@@ -0,0 +1,58 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a transport-company multi-language.
+///
+[ExcludeFromCodeCoverage]
+internal record TransportCompanyMultiLanguageContract {
+ ///
+ /// Gets the email.
+ ///
+ [JsonPropertyName("email")]
+ public string? Email { get; init; }
+
+ ///
+ /// Gets the language.
+ ///
+ [JsonPropertyName("language")]
+ public string Language { get; init; } = string.Empty;
+
+ ///
+ /// Gets the name.
+ ///
+ [JsonPropertyName("name")]
+ public string Name { get; init; } = string.Empty;
+
+ ///
+ /// Gets the phone number.
+ ///
+ [JsonPropertyName("phoneNumber")]
+ public string? PhoneNumber { get; init; }
+
+ ///
+ /// Gets the short name.
+ ///
+ [JsonPropertyName("shortName")]
+ public string ShortName { get; init; } = string.Empty;
+
+ ///
+ /// Gets the website.
+ ///
+ [JsonPropertyName("website")]
+ public string Website { get; init; } = string.Empty;
+
+ ///
+ /// Gets the website digital assistant.
+ ///
+ [JsonPropertyName("websiteDigitalAssistant")]
+ public string? WebsiteDigitalAssistant { get; init; }
+
+ ///
+ /// Gets the website ticketing.
+ ///
+ [JsonPropertyName("websiteTicketing")]
+ public string? WebsiteTicketing { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/TransportContract.cs b/source/DotBahn.Boards/Internal/Contracts/TransportContract.cs
new file mode 100644
index 0000000..f2c6a83
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/TransportContract.cs
@@ -0,0 +1,76 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a transport.
+///
+[ExcludeFromCodeCoverage]
+internal record TransportContract {
+ ///
+ /// Gets the administration identifier.
+ ///
+ [JsonPropertyName("administrationId")]
+ public string AdministrationId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the category.
+ ///
+ [JsonPropertyName("category")]
+ public string Category { get; init; } = string.Empty;
+
+ ///
+ /// Gets the internal category.
+ ///
+ [JsonPropertyName("categoryInternal")]
+ public string CategoryInternal { get; init; } = string.Empty;
+
+ ///
+ /// Gets the DFID.
+ ///
+ [JsonPropertyName("dfid")]
+ public string? Dfid { get; init; }
+
+ ///
+ /// Gets the DTID.
+ ///
+ [JsonPropertyName("dtid")]
+ public string? Dtid { get; init; }
+
+ ///
+ /// Gets the journey description.
+ ///
+ [JsonPropertyName("journeyDescription")]
+ public string JourneyDescription { get; init; } = string.Empty;
+
+ ///
+ /// Gets the journey number.
+ ///
+ [JsonPropertyName("journeyNumber")]
+ public int JourneyNumber { get; init; }
+
+ ///
+ /// Gets the label.
+ ///
+ [JsonPropertyName("label")]
+ public string? Label { get; init; }
+
+ ///
+ /// Gets the line.
+ ///
+ [JsonPropertyName("line")]
+ public LineInfoContract? Line { get; init; }
+
+ ///
+ /// Gets the operational journey number.
+ ///
+ [JsonPropertyName("operationalJourneyNumber")]
+ public string OperationalJourneyNumber { get; init; } = string.Empty;
+
+ ///
+ /// Gets the type.
+ ///
+ [JsonPropertyName("type")]
+ public string Type { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/TransportDestinationPortionWorkingRefContract.cs b/source/DotBahn.Boards/Internal/Contracts/TransportDestinationPortionWorkingRefContract.cs
new file mode 100644
index 0000000..f9887fa
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/TransportDestinationPortionWorkingRefContract.cs
@@ -0,0 +1,100 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a transport destination reference for portion-working journeys.
+///
+[ExcludeFromCodeCoverage]
+internal record TransportDestinationPortionWorkingRefContract {
+ ///
+ /// Gets the administration identifier.
+ ///
+ [JsonPropertyName("administrationId")]
+ public string AdministrationId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the category.
+ ///
+ [JsonPropertyName("category")]
+ public string Category { get; init; } = string.Empty;
+
+ ///
+ /// Gets the internal category.
+ ///
+ [JsonPropertyName("categoryInternal")]
+ public string CategoryInternal { get; init; } = string.Empty;
+
+ ///
+ /// Gets the destination.
+ ///
+ [JsonPropertyName("destination")]
+ public StopPlaceRefWithCancelContract Destination { get; init; } = new();
+
+ ///
+ /// Gets the DFID.
+ ///
+ [JsonPropertyName("dfid")]
+ public string? Dfid { get; init; }
+
+ ///
+ /// Gets the differing destination.
+ ///
+ [JsonPropertyName("differingDestination")]
+ public StopPlaceRefContract? DifferingDestination { get; init; }
+
+ ///
+ /// Gets the DTID.
+ ///
+ [JsonPropertyName("dtid")]
+ public string? Dtid { get; init; }
+
+ ///
+ /// Gets the journey description.
+ ///
+ [JsonPropertyName("journeyDescription")]
+ public string JourneyDescription { get; init; } = string.Empty;
+
+ ///
+ /// Gets the journey identifier.
+ ///
+ [JsonPropertyName("journeyID")]
+ public string JourneyId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the journey number.
+ ///
+ [JsonPropertyName("journeyNumber")]
+ public int JourneyNumber { get; init; }
+
+ ///
+ /// Gets the label.
+ ///
+ [JsonPropertyName("label")]
+ public string? Label { get; init; }
+
+ ///
+ /// Gets the line.
+ ///
+ [JsonPropertyName("line")]
+ public LineInfoContract? Line { get; init; }
+
+ ///
+ /// Gets the operational journey number.
+ ///
+ [JsonPropertyName("operationalJourneyNumber")]
+ public string OperationalJourneyNumber { get; init; } = string.Empty;
+
+ ///
+ /// Gets the separation at.
+ ///
+ [JsonPropertyName("separationAt")]
+ public StopPlaceRefContract? SeparationAt { get; init; }
+
+ ///
+ /// Gets the type.
+ ///
+ [JsonPropertyName("type")]
+ public string Type { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/TransportDestinationRefContract.cs b/source/DotBahn.Boards/Internal/Contracts/TransportDestinationRefContract.cs
new file mode 100644
index 0000000..cd05544
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/TransportDestinationRefContract.cs
@@ -0,0 +1,94 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a transport destination reference.
+///
+[ExcludeFromCodeCoverage]
+internal record TransportDestinationRefContract {
+ ///
+ /// Gets the administration identifier.
+ ///
+ [JsonPropertyName("administrationId")]
+ public string AdministrationId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the category.
+ ///
+ [JsonPropertyName("category")]
+ public string Category { get; init; } = string.Empty;
+
+ ///
+ /// Gets the internal category.
+ ///
+ [JsonPropertyName("categoryInternal")]
+ public string CategoryInternal { get; init; } = string.Empty;
+
+ ///
+ /// Gets the destination.
+ ///
+ [JsonPropertyName("destination")]
+ public StopPlaceRefWithCancelContract Destination { get; init; } = new();
+
+ ///
+ /// Gets the DFID.
+ ///
+ [JsonPropertyName("dfid")]
+ public string? Dfid { get; init; }
+
+ ///
+ /// Gets the differing destination.
+ ///
+ [JsonPropertyName("differingDestination")]
+ public StopPlaceRefContract? DifferingDestination { get; init; }
+
+ ///
+ /// Gets the DTID.
+ ///
+ [JsonPropertyName("dtid")]
+ public string? Dtid { get; init; }
+
+ ///
+ /// Gets the journey description.
+ ///
+ [JsonPropertyName("journeyDescription")]
+ public string JourneyDescription { get; init; } = string.Empty;
+
+ ///
+ /// Gets the journey identifier.
+ ///
+ [JsonPropertyName("journeyID")]
+ public string JourneyId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the journey number.
+ ///
+ [JsonPropertyName("journeyNumber")]
+ public int JourneyNumber { get; init; }
+
+ ///
+ /// Gets the label.
+ ///
+ [JsonPropertyName("label")]
+ public string? Label { get; init; }
+
+ ///
+ /// Gets the line.
+ ///
+ [JsonPropertyName("line")]
+ public LineInfoContract? Line { get; init; }
+
+ ///
+ /// Gets the operational journey number.
+ ///
+ [JsonPropertyName("operationalJourneyNumber")]
+ public string OperationalJourneyNumber { get; init; } = string.Empty;
+
+ ///
+ /// Gets the type.
+ ///
+ [JsonPropertyName("type")]
+ public string Type { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/TransportOriginRefContract.cs b/source/DotBahn.Boards/Internal/Contracts/TransportOriginRefContract.cs
new file mode 100644
index 0000000..4a7cb45
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/TransportOriginRefContract.cs
@@ -0,0 +1,94 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a transport origin reference.
+///
+[ExcludeFromCodeCoverage]
+internal record TransportOriginRefContract {
+ ///
+ /// Gets the administration identifier.
+ ///
+ [JsonPropertyName("administrationId")]
+ public string AdministrationId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the category.
+ ///
+ [JsonPropertyName("category")]
+ public string Category { get; init; } = string.Empty;
+
+ ///
+ /// Gets the internal category.
+ ///
+ [JsonPropertyName("categoryInternal")]
+ public string CategoryInternal { get; init; } = string.Empty;
+
+ ///
+ /// Gets the DFID.
+ ///
+ [JsonPropertyName("dfid")]
+ public string? Dfid { get; init; }
+
+ ///
+ /// Gets the differing origin.
+ ///
+ [JsonPropertyName("differingOrigin")]
+ public StopPlaceRefContract? DifferingOrigin { get; init; }
+
+ ///
+ /// Gets the DTID.
+ ///
+ [JsonPropertyName("dtid")]
+ public string? Dtid { get; init; }
+
+ ///
+ /// Gets the journey description.
+ ///
+ [JsonPropertyName("journeyDescription")]
+ public string JourneyDescription { get; init; } = string.Empty;
+
+ ///
+ /// Gets the journey identifier.
+ ///
+ [JsonPropertyName("journeyID")]
+ public string JourneyId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the journey number.
+ ///
+ [JsonPropertyName("journeyNumber")]
+ public int JourneyNumber { get; init; }
+
+ ///
+ /// Gets the label.
+ ///
+ [JsonPropertyName("label")]
+ public string? Label { get; init; }
+
+ ///
+ /// Gets the line.
+ ///
+ [JsonPropertyName("line")]
+ public LineInfoContract? Line { get; init; }
+
+ ///
+ /// Gets the operational journey number.
+ ///
+ [JsonPropertyName("operationalJourneyNumber")]
+ public string OperationalJourneyNumber { get; init; } = string.Empty;
+
+ ///
+ /// Gets the origin.
+ ///
+ [JsonPropertyName("origin")]
+ public StopPlaceRefWithCancelContract Origin { get; init; } = new();
+
+ ///
+ /// Gets the type.
+ ///
+ [JsonPropertyName("type")]
+ public string Type { get; init; } = string.Empty;
+}
diff --git a/source/DotBahn.Boards/Internal/Contracts/TransportWithDirectionAndViaContract.cs b/source/DotBahn.Boards/Internal/Contracts/TransportWithDirectionAndViaContract.cs
new file mode 100644
index 0000000..52f3e0f
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Contracts/TransportWithDirectionAndViaContract.cs
@@ -0,0 +1,94 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+
+namespace DotBahn.Boards.Internal.Contracts;
+
+///
+/// Raw structure for a transport with direction and via stops.
+///
+[ExcludeFromCodeCoverage]
+internal record TransportWithDirectionAndViaContract {
+ ///
+ /// Gets the administration identifier.
+ ///
+ [JsonPropertyName("administrationId")]
+ public string AdministrationId { get; init; } = string.Empty;
+
+ ///
+ /// Gets the category.
+ ///
+ [JsonPropertyName("category")]
+ public string Category { get; init; } = string.Empty;
+
+ ///
+ /// Gets the internal category.
+ ///
+ [JsonPropertyName("categoryInternal")]
+ public string CategoryInternal { get; init; } = string.Empty;
+
+ ///
+ /// Gets the DFID.
+ ///
+ [JsonPropertyName("dfid")]
+ public string? Dfid { get; init; }
+
+ ///
+ /// Gets the direction.
+ ///
+ [JsonPropertyName("direction")]
+ public DirectionInfoContract? Direction { get; init; }
+
+ ///
+ /// Gets the DTID.
+ ///
+ [JsonPropertyName("dtid")]
+ public string? Dtid { get; init; }
+
+ ///
+ /// Gets the journey description.
+ ///
+ [JsonPropertyName("journeyDescription")]
+ public string JourneyDescription { get; init; } = string.Empty;
+
+ ///
+ /// Gets the journey number.
+ ///
+ [JsonPropertyName("journeyNumber")]
+ public int JourneyNumber { get; init; }
+
+ ///
+ /// Gets the label.
+ ///
+ [JsonPropertyName("label")]
+ public string? Label { get; init; }
+
+ ///
+ /// Gets the line.
+ ///
+ [JsonPropertyName("line")]
+ public LineInfoContract? Line { get; init; }
+
+ ///
+ /// Gets the operational journey number.
+ ///
+ [JsonPropertyName("operationalJourneyNumber")]
+ public string OperationalJourneyNumber { get; init; } = string.Empty;
+
+ ///
+ /// Gets the replacement transport.
+ ///
+ [JsonPropertyName("replacementTransport")]
+ public ReplacementTransportContract? ReplacementTransport { get; init; }
+
+ ///
+ /// Gets the type.
+ ///
+ [JsonPropertyName("type")]
+ public string Type { get; init; } = string.Empty;
+
+ ///
+ /// Gets the via stops.
+ ///
+ [JsonPropertyName("via")]
+ public List? Via { get; init; }
+}
diff --git a/source/DotBahn.Boards/Internal/Json/BoardsJsonContext.cs b/source/DotBahn.Boards/Internal/Json/BoardsJsonContext.cs
new file mode 100644
index 0000000..5118449
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Json/BoardsJsonContext.cs
@@ -0,0 +1,62 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+using DotBahn.Boards.Internal.Contracts;
+
+namespace DotBahn.Boards.Internal.Json;
+
+///
+/// Source-generated JSON serialization metadata for OpenBoards internal contracts.
+///
+[ExcludeFromCodeCoverage]
+[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
+[JsonSerializable(typeof(ArrivalBoardResponseContract))]
+[JsonSerializable(typeof(DepartureBoardResponseContract))]
+[JsonSerializable(typeof(AdministrationExtendedMultiLanguageContract))]
+[JsonSerializable(typeof(ArrivalContract))]
+[JsonSerializable(typeof(BoardMetaContract))]
+[JsonSerializable(typeof(CodeShareContract))]
+[JsonSerializable(typeof(DepartureContract))]
+[JsonSerializable(typeof(DirectionInfoContract))]
+[JsonSerializable(typeof(DisruptionCommunicationAttachmentContract))]
+[JsonSerializable(typeof(DisruptionCommunicationImageContract))]
+[JsonSerializable(typeof(DisruptionCommunicationLinkContract))]
+[JsonSerializable(typeof(ErrorDetailContract))]
+[JsonSerializable(typeof(ErrorResponseContract))]
+[JsonSerializable(typeof(JourneyInfoContract))]
+[JsonSerializable(typeof(LineChipVisualizationContract))]
+[JsonSerializable(typeof(LineColourContract))]
+[JsonSerializable(typeof(LineInfoContract))]
+[JsonSerializable(typeof(LineStrokeVisualizationContract))]
+[JsonSerializable(typeof(MessageAttributeDescriptionContract))]
+[JsonSerializable(typeof(MessageAttributeMultiLanguageContract))]
+[JsonSerializable(typeof(MessageDisruptionCommunicationDescriptionContract))]
+[JsonSerializable(typeof(MessageDisruptionCommunicationMultiLanguageContract))]
+[JsonSerializable(typeof(MessageNoteDescriptionContract))]
+[JsonSerializable(typeof(MessageNoteMultiLanguageContract))]
+[JsonSerializable(typeof(MessageRisCauseCodeDescriptionContract))]
+[JsonSerializable(typeof(MessageRisCauseCodeMultiLanguageContract))]
+[JsonSerializable(typeof(MessageRisQualityDeviationDescriptionContract))]
+[JsonSerializable(typeof(MessageRisQualityDeviationMultiLanguageContract))]
+[JsonSerializable(typeof(MessagesMultiLanguageContract))]
+[JsonSerializable(typeof(OpenArrivalBoardRequestContract))]
+[JsonSerializable(typeof(OpenDepartureBoardRequestContract))]
+[JsonSerializable(typeof(PlatformAccessibilityContract))]
+[JsonSerializable(typeof(PlatformContract))]
+[JsonSerializable(typeof(PlatformHistoryContract))]
+[JsonSerializable(typeof(ReplacementTransportContract))]
+[JsonSerializable(typeof(StationMultiLanguageContract))]
+[JsonSerializable(typeof(StationNameMultiLanguageContract))]
+[JsonSerializable(typeof(StopPlaceMultiLanguageContract))]
+[JsonSerializable(typeof(StopPlaceNameMultiLanguageContract))]
+[JsonSerializable(typeof(StopPlaceOrStationRequestContract))]
+[JsonSerializable(typeof(StopPlaceRefContract))]
+[JsonSerializable(typeof(StopPlaceRefViaContract))]
+[JsonSerializable(typeof(StopPlaceRefWithCancelContract))]
+[JsonSerializable(typeof(TimeWindowContract))]
+[JsonSerializable(typeof(TransportContract))]
+[JsonSerializable(typeof(TransportCompanyMultiLanguageContract))]
+[JsonSerializable(typeof(TransportDestinationPortionWorkingRefContract))]
+[JsonSerializable(typeof(TransportDestinationRefContract))]
+[JsonSerializable(typeof(TransportOriginRefContract))]
+[JsonSerializable(typeof(TransportWithDirectionAndViaContract))]
+internal sealed partial class BoardsJsonContext : JsonSerializerContext;
diff --git a/source/DotBahn.Boards/Internal/Transformers/ArrivalBoardTransformer.cs b/source/DotBahn.Boards/Internal/Transformers/ArrivalBoardTransformer.cs
new file mode 100644
index 0000000..b87859b
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Transformers/ArrivalBoardTransformer.cs
@@ -0,0 +1,40 @@
+using DotBahn.Boards.Internal.Contracts;
+using DotBahn.Boards.Models;
+using DotBahn.Boards.Models.Entries;
+using DotBahn.Common.Transformer;
+
+namespace DotBahn.Boards.Internal.Transformers;
+
+///
+/// Transforms an arrival-board contract into the public domain model.
+///
+internal sealed class ArrivalBoardTransformer : TransformerBase, ITransformer, ArrivalBoardResponseContract> {
+ ///
+ public Board Transform(ArrivalBoardResponseContract contract) {
+ ArgumentNullException.ThrowIfNull(contract);
+ return TransformBoard(contract.StopPlaces ?? [], contract.Stations ?? [], contract.Administrations ?? [], contract.Messages, contract.Meta, contract.DisruptionCommunications ?? [], contract.Arrivals ?? [], TransformArrival);
+ }
+
+ private static ArrivalEntry TransformArrival(ArrivalContract contract, TransformContext ctx) => new() {
+ Id = contract.ArrivalId,
+ StopPlace = ResolveStopPlace(contract.EvaNumber, ctx) ?? new StopPlace { EvaNumber = contract.EvaNumber, Name = contract.EvaNumber },
+ Journey = TransformJourneyInfo(contract.JourneyId, contract.JourneyInfo, ctx),
+ Time = BuildTimeChanged(contract.TimeSchedule, contract.Time, contract.TimeType),
+ Platform = BuildPlatformChanged(contract.PlatformSchedule, contract.Platform),
+ Transport = TransformTransport(contract.Transport, ctx),
+ Messages = ResolveMessages(contract.Messages, ctx.Messages).ToList(),
+ Cancelled = contract.Cancelled,
+ Additional = contract.Additional,
+ OnDemand = contract.OnDemand,
+ NoPassengerChange = contract.NoPassengerChange,
+ VehicleSequenceAvailable = contract.VehicleSequenceAvailable ?? false,
+ Codeshares = TransformCodeshares(contract.Codeshares),
+ ContinuationBy = (contract.ContinuationBy ?? []).Select(c => TransformTransportReference(c, ctx)).ToList(),
+ ReliefBy = (contract.ReliefBy ?? []).Select(c => TransformTransportReference(c, ctx)).ToList(),
+ ReliefFor = (contract.ReliefFor ?? []).Select(c => TransformTransportReference(c, ctx)).ToList(),
+ ReplacedBy = (contract.ReplacedBy ?? []).Select(c => TransformTransportReference(c, ctx)).ToList(),
+ ReplacementFor = (contract.ReplacementFor ?? []).Select(c => TransformTransportReference(c, ctx)).ToList(),
+ TravelsWith = (contract.TravelsWith ?? []).Select(c => TransformTransportReference(c, ctx)).ToList(),
+ PastDisruptions = contract.PastDisruptions ?? false
+ };
+}
diff --git a/source/DotBahn.Boards/Internal/Transformers/DepartureBoardTransformer.cs b/source/DotBahn.Boards/Internal/Transformers/DepartureBoardTransformer.cs
new file mode 100644
index 0000000..e0d705c
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Transformers/DepartureBoardTransformer.cs
@@ -0,0 +1,40 @@
+using DotBahn.Boards.Internal.Contracts;
+using DotBahn.Boards.Models;
+using DotBahn.Boards.Models.Entries;
+using DotBahn.Common.Transformer;
+
+namespace DotBahn.Boards.Internal.Transformers;
+
+///
+/// Transforms a departure-board contract into the public domain model.
+///
+internal sealed class DepartureBoardTransformer : TransformerBase, ITransformer, DepartureBoardResponseContract> {
+ ///
+ public Board Transform(DepartureBoardResponseContract contract) {
+ ArgumentNullException.ThrowIfNull(contract);
+ return TransformBoard(contract.StopPlaces ?? [], contract.Stations ?? [], contract.Administrations ?? [], contract.Messages, contract.Meta, contract.DisruptionCommunications ?? [], contract.Departures ?? [], TransformDeparture);
+ }
+
+ private static DepartureEntry TransformDeparture(DepartureContract contract, TransformContext ctx) => new() {
+ Id = contract.DepartureId,
+ StopPlace = ResolveStopPlace(contract.EvaNumber, ctx) ?? new StopPlace { EvaNumber = contract.EvaNumber, Name = contract.EvaNumber },
+ Journey = TransformJourneyInfo(contract.JourneyId, contract.JourneyInfo, ctx),
+ Time = BuildTimeChanged(contract.TimeSchedule, contract.Time, contract.TimeType),
+ Platform = BuildPlatformChanged(contract.PlatformSchedule, contract.Platform),
+ Transport = TransformTransport(contract.Transport, ctx),
+ Messages = ResolveMessages(contract.Messages, ctx.Messages).ToList(),
+ Cancelled = contract.Cancelled,
+ Additional = contract.Additional,
+ OnDemand = contract.OnDemand,
+ NoPassengerChange = contract.NoPassengerChange,
+ VehicleSequenceAvailable = contract.VehicleSequenceAvailable ?? false,
+ Codeshares = TransformCodeshares(contract.Codeshares),
+ ContinuationFor = (contract.ContinuationFor ?? []).Select(c => TransformTransportReference(c, ctx)).ToList(),
+ ReliefBy = (contract.ReliefBy ?? []).Select(c => TransformTransportReference(c, ctx)).ToList(),
+ ReliefFor = (contract.ReliefFor ?? []).Select(c => TransformTransportReference(c, ctx)).ToList(),
+ ReplacedBy = (contract.ReplacedBy ?? []).Select(c => TransformTransportReference(c, ctx)).ToList(),
+ ReplacementFor = (contract.ReplacementFor ?? []).Select(c => TransformTransportReference(c, ctx)).ToList(),
+ TravelsWith = (contract.TravelsWith ?? []).Select(c => TransformTransportReference(c, ctx)).ToList(),
+ FutureDisruptions = contract.FutureDisruptions ?? false
+ };
+}
diff --git a/source/DotBahn.Boards/Internal/Transformers/TransformerBase.cs b/source/DotBahn.Boards/Internal/Transformers/TransformerBase.cs
new file mode 100644
index 0000000..9e3086f
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Transformers/TransformerBase.cs
@@ -0,0 +1,384 @@
+using System.Globalization;
+using DotBahn.Boards.Internal.Contracts;
+using DotBahn.Boards.Models;
+using DotBahn.Boards.Models.Entries;
+using DotBahn.Boards.Models.Journeys;
+using DotBahn.Boards.Models.Messages;
+using DotBahn.Boards.Models.Operators;
+using DotBahn.Common.Models;
+
+namespace DotBahn.Boards.Internal.Transformers;
+
+///
+/// Shared transformation helpers for arrival and departure boards.
+///
+internal abstract class TransformerBase {
+ private const string GermanLanguageCode = "deu";
+ private const string EnglishLanguageCode = "eng";
+
+ ///
+ /// Lookup context shared by all board transformations.
+ ///
+ protected record TransformContext(IReadOnlyDictionary StopPlaces, IReadOnlyDictionary Administrations, IReadOnlyDictionary Messages);
+
+ ///
+ /// Transforms the shared board structure into the public domain model.
+ ///
+ protected static Board TransformBoard(IEnumerable stopPlaceContracts, IEnumerable stationContracts, IEnumerable administrationContracts, MessagesMultiLanguageContract? messagesContract, BoardMetaContract meta, IEnumerable disruptionCommunications, IEnumerable entries, Func transformEntry) where TEntry : BoardEntry {
+ var ctx = BuildContext(stopPlaceContracts, stationContracts, administrationContracts, messagesContract);
+
+ return new Board {
+ ConsideredStopPlaces = (meta.ConsideredStopPlaces ?? [])
+ .Select(eva => ctx.StopPlaces.GetValueOrDefault(eva))
+ .Where(s => s != null)
+ .Cast()
+ .ToList(),
+ TruncatedTransportTypes = meta.TruncatedTransportTypes ?? [],
+ Entries = entries.Select(e => transformEntry(e, ctx)).ToList(),
+ StationMessages = ResolveMessages(disruptionCommunications, ctx.Messages).ToList()
+ };
+ }
+
+
+ ///
+ /// Builds a from scheduled and best-known time strings.
+ ///
+ protected static ChangedValue BuildTimeChanged(string timeSchedule, string time, string timeType) {
+ var scheduled = ParseTime(timeSchedule);
+ var actual = ParseTime(time);
+ var hasUpdate = timeType is "PREVIEW" or "REAL" || actual != scheduled;
+
+ return new ChangedValue {
+ Original = scheduled,
+ Updated = hasUpdate ? actual : null
+ };
+ }
+
+ ///
+ /// Builds a from scheduled and current platform contracts.
+ ///
+ protected static ChangedRef BuildPlatformChanged(PlatformContract? platformSchedule, PlatformContract? platform) {
+ var scheduled = platformSchedule != null ? TransformPlatform(platformSchedule) : platform != null ? TransformPlatform(platform) : new Platform { Name = string.Empty };
+ var actual = platform != null && platform.Name != scheduled.Name ? TransformPlatform(platform) : null;
+
+ return new ChangedRef {
+ Original = scheduled,
+ Updated = actual
+ };
+ }
+
+ protected static Journey TransformJourneyInfo(string journeyId, JourneyInfoContract contract, TransformContext ctx) => new() {
+ Id = journeyId,
+ Origin = ResolveVisit(contract.Origin, ctx),
+ Destination = ResolveVisit(contract.Destination, ctx),
+ DifferingOrigin = ResolveStopPlace(contract.DifferingOrigin?.EvaNumber, ctx),
+ DifferingDestination = ResolveStopPlace(contract.DifferingDestination?.EvaNumber, ctx),
+ ScheduledStartTime = ParseTime(contract.ScheduledStartTime),
+ TransportAtStart = TransformTransport(contract.TransportAtStart, ctx),
+ IsCancelled = contract.JourneyCancelled,
+ Type = contract.Type,
+ HeaderAdministration = ctx.Administrations.GetValueOrDefault(contract.HeaderAdministrationId),
+ HeaderJourneyNumber = contract.HeaderJourneyNumber
+ };
+
+ protected static Transport TransformTransport(TransportWithDirectionAndViaContract contract, TransformContext ctx) =>
+ CreateTransport(
+ contract,
+ contract.Direction?.Texts ?? [],
+ contract.Direction != null ? (contract.Direction.StopPlaces ?? []).Select(r => ResolveStopPlace(r.EvaNumber, ctx)).Where(s => s != null).Cast().ToList() : [],
+ (contract.Via ?? []).Select(v => ResolveVisit(v, ctx)).ToList(),
+ contract.ReplacementTransport?.RealType,
+ ctx);
+
+ protected static IReadOnlyDictionary TransformCodeshares(IEnumerable? contracts) =>
+ (contracts ?? []).ToDictionary(c => c.AirlineCode, c => c.Flightnumber);
+
+ protected static TransportReference TransformTransportReference(TransportDestinationRefContract contract, TransformContext ctx) =>
+ CreateTransportReference(contract, ctx,
+ destination: ResolveVisit(contract.Destination, ctx),
+ differingDestination: ResolveStopPlace(contract.DifferingDestination?.EvaNumber, ctx));
+
+ protected static TransportReference TransformTransportReference(TransportOriginRefContract contract, TransformContext ctx) =>
+ CreateTransportReference(contract, ctx,
+ origin: ResolveVisit(contract.Origin, ctx),
+ differingOrigin: ResolveStopPlace(contract.DifferingOrigin?.EvaNumber, ctx));
+
+ protected static TransportReference TransformTransportReference(TransportDestinationPortionWorkingRefContract contract, TransformContext ctx) =>
+ CreateTransportReference(contract, ctx,
+ destination: ResolveVisit(contract.Destination, ctx),
+ differingDestination: ResolveStopPlace(contract.DifferingDestination?.EvaNumber, ctx),
+ separationAt: ResolveStopPlace(contract.SeparationAt?.EvaNumber, ctx));
+
+ ///
+ /// Resolves a list of message IDs to messages.
+ ///
+ protected static IReadOnlyList ResolveMessages(IEnumerable? messageIds, IReadOnlyDictionary lookup) =>
+ (messageIds ?? []).Select(lookup.GetValueOrDefault)
+ .Where(m => m != null)
+ .Cast()
+ .ToList();
+
+ protected static StopPlace? ResolveStopPlace(string? evaNumber, TransformContext ctx) =>
+ !string.IsNullOrEmpty(evaNumber) && ctx.StopPlaces.TryGetValue(evaNumber, out var stopPlace) ? stopPlace : null;
+
+
+ ///
+ /// Builds the shared lookup context for all board transformations.
+ ///
+ private static TransformContext BuildContext(IEnumerable stopPlaceContracts, IEnumerable stationContracts, IEnumerable administrationContracts, MessagesMultiLanguageContract? messagesContract) {
+ var stationNames = stationContracts.ToDictionary(s => s.Stada, c => SelectLocalized(c.LocalizedNames, n => n.Language, n => n.Name).Value);
+ var stopPlaces = stopPlaceContracts.ToDictionary(s => s.EvaNumber, c => TransformStopPlace(c, stationNames));
+
+ return new TransformContext(stopPlaces, administrationContracts.ToDictionary(a => a.AdministrationId, TransformAdministration), BuildMessageLookup(messagesContract));
+ }
+
+ ///
+ /// Builds a message lookup dictionary from all message collections.
+ ///
+ private static IReadOnlyDictionary BuildMessageLookup(MessagesMultiLanguageContract? messages) {
+ if (messages == null) {
+ return new Dictionary();
+ }
+
+ var lookup = new Dictionary();
+
+ foreach (var attribute in messages.Attributes ?? []) {
+ lookup[attribute.MessageId] = TransformMessageAttribute(attribute);
+ }
+
+ foreach (var disruption in messages.Disruptions ?? []) {
+ lookup[disruption.MessageId] = TransformMessageDisruption(disruption);
+ }
+
+ foreach (var note in messages.Notes ?? []) {
+ lookup[note.MessageId] = TransformMessageNote(note);
+ }
+
+ foreach (var cause in messages.RisCauseCodes ?? []) {
+ lookup[cause.MessageId] = TransformMessageRisCauseCode(cause);
+ }
+
+ foreach (var deviation in messages.RisQualityDeviations ?? []) {
+ lookup[deviation.MessageId] = TransformMessageRisQualityDeviation(deviation);
+ }
+
+ return lookup;
+ }
+
+ private static StopPlace ResolveStopPlaceOrDefault(string evaNumber, TransformContext ctx) =>
+ ResolveStopPlace(evaNumber, ctx) ?? new StopPlace { EvaNumber = evaNumber, Name = evaNumber };
+
+ private static Visit ResolveVisit(StopPlaceRefWithCancelContract reference, TransformContext ctx) => new() {
+ StopPlace = ResolveStopPlaceOrDefault(reference.EvaNumber, ctx),
+ Cancelled = reference.Cancelled
+ };
+
+ private static Visit ResolveVisit(StopPlaceRefViaContract reference, TransformContext ctx) => new() {
+ StopPlace = ResolveStopPlaceOrDefault(reference.EvaNumber, ctx),
+ Additional = reference.Additional,
+ Cancelled = reference.Cancelled,
+ DisplayPriority = reference.DisplayPriority
+ };
+
+ private static DateTime ParseTime(string value) => DateTime.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
+
+ private static StopPlace TransformStopPlace(StopPlaceMultiLanguageContract contract, IReadOnlyDictionary stationNames) {
+ var localized = SelectLocalized(contract.LocalizedNames, n => n.Language, n => (n.Name, n.Symbol, n.SymbolName));
+ return new StopPlace {
+ EvaNumber = contract.EvaNumber,
+ Name = localized.Value.Name,
+ Symbol = localized.Value.Symbol,
+ SymbolName = localized.Value.SymbolName,
+ Dhid = contract.Ifopt,
+ StadaId = contract.Stada,
+ StationName = !string.IsNullOrEmpty(contract.Stada) && stationNames.TryGetValue(contract.Stada, out var name) ? name : null
+ };
+ }
+
+ private static Administration TransformAdministration(AdministrationExtendedMultiLanguageContract contract) => new() {
+ Id = contract.AdministrationId,
+ OperatorCode = contract.OperatorCode,
+ OperatorName = contract.OperatorName,
+ TransportCompanies = (contract.TransportCompanies ?? []).Select(TransformTransportCompany).ToList()
+ };
+
+ private static TransportCompany TransformTransportCompany(TransportCompanyMultiLanguageContract contract) => new() {
+ Language = contract.Language,
+ Name = contract.Name,
+ ShortName = contract.ShortName,
+ Email = contract.Email,
+ PhoneNumber = contract.PhoneNumber,
+ Website = contract.Website,
+ WebsiteTicketing = contract.WebsiteTicketing,
+ WebsiteDigitalAssistant = contract.WebsiteDigitalAssistant
+ };
+
+ private static Platform TransformPlatform(PlatformContract contract) => new() {
+ Name = contract.Name,
+ Ifopt = contract.Ifopt,
+ StepFreeAccess = contract.Accessibility?.StepFreeAccess ?? false,
+ BoardingAid = contract.Accessibility?.BoardingAid ?? false,
+ TactileGuidingStrips = contract.Accessibility?.TactileGuidingStrips ?? false,
+ TactileHandrailLabel = contract.Accessibility?.TactileHandrailLabel ?? false,
+ TactilePlatformAccess = contract.Accessibility?.TactilePlatformAccess ?? false,
+ AudibleSignalsAvailable = contract.Accessibility?.AudibleSignalsAvailable ?? false,
+ AutomaticDoor = contract.Accessibility?.AutomaticDoor ?? false,
+ PassengerInformationDisplay = contract.Accessibility?.PassengerInformationDisplay ?? false,
+ PlatformSign = contract.Accessibility?.PlatformSign ?? false,
+ StairsMarking = contract.Accessibility?.StairsMarking ?? false,
+ StandardPlatformHeight = contract.Accessibility?.StandardPlatformHeight ?? false
+ };
+
+ private static Line TransformLine(LineInfoContract contract) => new() {
+ Name = contract.Name,
+ PrimaryColour = contract.Colour?.PrimaryColour,
+ PrimaryTextColour = contract.Colour?.PrimaryTextColour,
+ ChipDifferingBoundaryColour = contract.Colour?.ChipVisualization?.DifferingBoundaryColour,
+ ChipDifferingFillColour = contract.Colour?.ChipVisualization?.DifferingFillColour,
+ ChipDifferingTextColour = contract.Colour?.ChipVisualization?.DifferingTextColour,
+ ChipSecondaryFillColour = contract.Colour?.ChipVisualization?.SecondaryFillColour,
+ StrokeDifferingBoundaryColour = contract.Colour?.StrokeVisualization?.DifferingBoundaryColour,
+ StrokeSecondaryFillColour = contract.Colour?.StrokeVisualization?.SecondaryFillColour
+ };
+
+
+ private static Transport TransformTransport(TransportContract contract, TransformContext ctx) =>
+ CreateTransport(contract, [], [], [], null, ctx);
+
+ private static Transport CreateTransport(
+ string administrationId, string category, string categoryInternal, string type,
+ int journeyNumber, string operationalNumber, string description, string? label,
+ LineInfoContract? line, string? dfid, string? dtid,
+ IReadOnlyList direction, IReadOnlyList directionStopPlaces,
+ IReadOnlyList via, string? replacementTransport, TransformContext ctx) => new() {
+ Category = category,
+ InternalCategory = categoryInternal,
+ Type = type,
+ Number = journeyNumber.ToString(CultureInfo.InvariantCulture),
+ OperationalNumber = operationalNumber,
+ Description = description,
+ Label = label,
+ Line = line != null ? TransformLine(line) : null,
+ Dfid = dfid,
+ Dtid = dtid,
+ Direction = direction,
+ DirectionStopPlaces = directionStopPlaces,
+ Via = via,
+ ReplacementTransport = replacementTransport,
+ Administration = ctx.Administrations.GetValueOrDefault(administrationId) ?? new Administration {
+ Id = administrationId,
+ OperatorCode = string.Empty,
+ OperatorName = string.Empty
+ }
+ };
+
+ private static Transport CreateTransport(TransportWithDirectionAndViaContract c, IReadOnlyList direction, IReadOnlyList directionStopPlaces, IReadOnlyList via, string? replacementTransport, TransformContext ctx) =>
+ CreateTransport(c.AdministrationId, c.Category, c.CategoryInternal, c.Type, c.JourneyNumber, c.OperationalJourneyNumber, c.JourneyDescription, c.Label, c.Line, c.Dfid, c.Dtid, direction, directionStopPlaces, via, replacementTransport, ctx);
+
+ private static Transport CreateTransport(TransportContract c, IReadOnlyList direction, IReadOnlyList directionStopPlaces, IReadOnlyList via, string? replacementTransport, TransformContext ctx) =>
+ CreateTransport(c.AdministrationId, c.Category, c.CategoryInternal, c.Type, c.JourneyNumber, c.OperationalJourneyNumber, c.JourneyDescription, c.Label, c.Line, c.Dfid, c.Dtid, direction, directionStopPlaces, via, replacementTransport, ctx);
+
+ private static TransportReference CreateTransportReference(
+ string administrationId, string category, string categoryInternal, string type,
+ string journeyId, int journeyNumber, string operationalNumber, string description,
+ string? label, LineInfoContract? line, string? dfid, string? dtid, TransformContext ctx,
+ Visit? origin = null, Visit? destination = null,
+ StopPlace? differingOrigin = null, StopPlace? differingDestination = null, StopPlace? separationAt = null) => new() {
+ JourneyId = journeyId,
+ Category = category,
+ InternalCategory = categoryInternal,
+ Type = type,
+ Number = journeyNumber.ToString(CultureInfo.InvariantCulture),
+ OperationalNumber = operationalNumber,
+ Description = description,
+ Label = label,
+ Line = line != null ? TransformLine(line) : null,
+ Dfid = dfid,
+ Dtid = dtid,
+ Administration = ctx.Administrations.GetValueOrDefault(administrationId),
+ Origin = origin,
+ Destination = destination,
+ DifferingOrigin = differingOrigin,
+ DifferingDestination = differingDestination,
+ SeparationAt = separationAt
+ };
+
+ private static TransportReference CreateTransportReference(TransportDestinationRefContract c, TransformContext ctx, Visit? destination, StopPlace? differingDestination) =>
+ CreateTransportReference(c.AdministrationId, c.Category, c.CategoryInternal, c.Type, c.JourneyId, c.JourneyNumber, c.OperationalJourneyNumber, c.JourneyDescription, c.Label, c.Line, c.Dfid, c.Dtid, ctx, destination: destination, differingDestination: differingDestination);
+
+ private static TransportReference CreateTransportReference(TransportOriginRefContract c, TransformContext ctx, Visit? origin, StopPlace? differingOrigin) =>
+ CreateTransportReference(c.AdministrationId, c.Category, c.CategoryInternal, c.Type, c.JourneyId, c.JourneyNumber, c.OperationalJourneyNumber, c.JourneyDescription, c.Label, c.Line, c.Dfid, c.Dtid, ctx, origin: origin, differingOrigin: differingOrigin);
+
+ private static TransportReference CreateTransportReference(TransportDestinationPortionWorkingRefContract c, TransformContext ctx, Visit? destination, StopPlace? differingDestination, StopPlace? separationAt) =>
+ CreateTransportReference(c.AdministrationId, c.Category, c.CategoryInternal, c.Type, c.JourneyId, c.JourneyNumber, c.OperationalJourneyNumber, c.JourneyDescription, c.Label, c.Line, c.Dfid, c.Dtid, ctx, destination: destination, differingDestination: differingDestination, separationAt: separationAt);
+
+ private static Message TransformMessageAttribute(MessageAttributeMultiLanguageContract contract) => new() {
+ Type = MessageType.Attribute,
+ Text = SelectLocalized(contract.Descriptions, d => d.Language, d => d.Text).Value,
+ Code = contract.Code,
+ Priority = contract.DisplayPriority,
+ DetailedPriority = contract.DisplayPriorityDetail
+ };
+
+ private static Message TransformMessageDisruption(MessageDisruptionCommunicationMultiLanguageContract contract) {
+ var localized = SelectLocalized(contract.Descriptions, d => d.Language, d => d.Text);
+ return new Message {
+ Type = MessageType.Disruption,
+ Text = localized.Value,
+ ShortText = localized.Item?.TextShort,
+ Cause = contract.Cause,
+ Effect = contract.Effect,
+ Priority = contract.DisplayPriority,
+ DisruptionId = contract.DisruptionId,
+ DisruptionCommunicationId = contract.DisruptionCommunicationId,
+ HasAlternatives = contract.HasAlternatives ?? false,
+ Resources = BuildMessageResources(localized.Item?.Links, localized.Item?.Attachments, localized.Item?.Images)
+ };
+ }
+
+ private static Message TransformMessageNote(MessageNoteMultiLanguageContract contract) {
+ var localized = SelectLocalized(contract.Descriptions, d => d.Language, d => d.Text);
+ return new Message {
+ Type = MessageType.Note,
+ Text = localized.Value,
+ ShortText = localized.Item?.TextShort,
+ Category = contract.Category,
+ Code = contract.Code,
+ Priority = contract.DisplayPriority,
+ DisruptionId = contract.DisruptionId,
+ DisruptionCommunicationId = contract.DisruptionCommunicationId,
+ Resources = BuildMessageResources(localized.Item?.Links, localized.Item?.Attachments, localized.Item?.Images)
+ };
+ }
+
+ private static Message TransformMessageRisCauseCode(MessageRisCauseCodeMultiLanguageContract contract) => new() {
+ Type = MessageType.RisCauseCode,
+ Text = SelectLocalized(contract.Descriptions, d => d.Language, d => d.Text).Value,
+ Code = contract.Code
+ };
+
+ private static Message TransformMessageRisQualityDeviation(MessageRisQualityDeviationMultiLanguageContract contract) => new() {
+ Type = MessageType.RisQualityDeviation,
+ Text = SelectLocalized(contract.Descriptions, d => d.Language, d => d.Text).Value,
+ Code = contract.Code
+ };
+
+ private static IReadOnlyList BuildMessageResources(IEnumerable? links, IEnumerable? attachments, IEnumerable? images) =>
+ (links ?? []).Select(c => CreateMessageResource(c.Label, c.Url, MessageResourceType.Link))
+ .Concat((attachments ?? []).Select(c => CreateMessageResource(c.Label, c.Url, MessageResourceType.Attachment)))
+ .Concat((images ?? []).Select(c => CreateMessageResource(c.Label, c.Url, MessageResourceType.Image)))
+ .ToList();
+
+ private static MessageResource CreateMessageResource(string label, string url, MessageResourceType type) => new() {
+ Type = type,
+ Label = label,
+ Url = url
+ };
+
+ private static (T Item, TValue Value) SelectLocalized(IEnumerable? items, Func languageSelector, Func valueSelector) {
+ var list = items?.ToList() ?? [];
+ var selected = list.FirstOrDefault(x => languageSelector(x).Equals(GermanLanguageCode, StringComparison.OrdinalIgnoreCase)) ?? list.FirstOrDefault(x => languageSelector(x).Equals(EnglishLanguageCode, StringComparison.OrdinalIgnoreCase)) ?? list.FirstOrDefault();
+
+ return selected == null ? (default!, default!) : (selected, valueSelector(selected));
+ }
+}
diff --git a/source/DotBahn.Boards/Internal/Utilities/QueryUtil.cs b/source/DotBahn.Boards/Internal/Utilities/QueryUtil.cs
new file mode 100644
index 0000000..13d7a93
--- /dev/null
+++ b/source/DotBahn.Boards/Internal/Utilities/QueryUtil.cs
@@ -0,0 +1,78 @@
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using DotBahn.Boards.Internal.Contracts;
+
+namespace DotBahn.Boards.Internal.Utilities;
+
+///
+/// Maps public board queries to internal OpenBoards request contracts.
+///
+internal static class QueryUtil {
+ ///
+ /// Maps a to the internal arrival request contract.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal static OpenArrivalBoardRequestContract ToArrivalContract(BoardQuery query) => new() {
+ StopPlaceOrStation = MapStopPlaceOrStation(query),
+ TimeWindow = MapTimeWindow(query),
+ TransportTypes = query.TransportTypes.Count > 0 ? [.. query.TransportTypes] : null,
+ Languages = query.Languages.Count > 0 ? [.. query.Languages] : null,
+ MaxEntriesPerTransportType = query.MaxEntriesPerTransportType,
+ MaxViaStops = query.MaxViaStops ?? 3,
+ NoCancellations = query.NoCancellations,
+ OnlyReplacementTransports = query.OnlyReplacementTransports,
+ SortBy = query.SortBy,
+ IncludeLineColours = query.IncludeLineColours,
+ IncludePlatformAccessibility = query.IncludePlatformAccessibility
+ };
+
+ ///
+ /// Maps a to the internal departure request contract.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal static OpenDepartureBoardRequestContract ToDepartureContract(BoardQuery query) => new() {
+ StopPlaceOrStation = MapStopPlaceOrStation(query),
+ TimeWindow = MapTimeWindow(query),
+ TransportTypes = query.TransportTypes.Count > 0 ? [.. query.TransportTypes] : null,
+ Languages = query.Languages.Count > 0 ? [.. query.Languages] : null,
+ MaxEntriesPerTransportType = query.MaxEntriesPerTransportType,
+ MaxViaStops = query.MaxViaStops ?? 3,
+ NoCancellations = query.NoCancellations,
+ OnlyReplacementTransports = query.OnlyReplacementTransports,
+ SortBy = query.SortBy,
+ IncludeLineColours = query.IncludeLineColours,
+ IncludePlatformAccessibility = query.IncludePlatformAccessibility
+ };
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ private static StopPlaceOrStationRequestContract MapStopPlaceOrStation(BoardQuery query) => new() {
+ EvaNumbers = query.EvaNumbers is { Count: > 0 } ? [.. query.EvaNumbers] : null,
+ Stada = query.StadaId,
+ Dhids = query.Dhids is { Count: > 0 } ? [.. query.Dhids] : null,
+ Platforms = query.Platforms is { Count: > 0 } ? [.. query.Platforms] : null,
+ BoardConfigurations = query.BoardConfigurations is { Count: > 0 } ? [.. query.BoardConfigurations] : null
+ };
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ private static TimeWindowContract? MapTimeWindow(BoardQuery query) {
+ var start = query.Start;
+ var end = query.End;
+ var count = query.EntryCount;
+
+ if (!start.HasValue && !end.HasValue && !count.HasValue) {
+ return null;
+ }
+
+ return new TimeWindowContract {
+ TimeStart = start.HasValue ? FormatDateTime(start.Value) : null,
+ TimeEnd = end.HasValue ? FormatDateTime(end.Value) : null,
+ EntryCount = count
+ };
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ private static string FormatDateTime(DateTime value) {
+ var utc = value.Kind == DateTimeKind.Unspecified ? DateTime.SpecifyKind(value, DateTimeKind.Utc) : value.ToUniversalTime();
+ return utc.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture);
+ }
+}
diff --git a/source/DotBahn.Boards/Models/Board.cs b/source/DotBahn.Boards/Models/Board.cs
new file mode 100644
index 0000000..69681bd
--- /dev/null
+++ b/source/DotBahn.Boards/Models/Board.cs
@@ -0,0 +1,31 @@
+
+using DotBahn.Boards.Models.Entries;
+using DotBahn.Boards.Models.Messages;
+
+namespace DotBahn.Boards.Models;
+
+///
+/// A board of arrival or departure events for one or more stop places.
+///
+/// The type of board entry.
+public class Board where TEntry : BoardEntry {
+ ///
+ /// Stop places the board was created for.
+ ///
+ public IReadOnlyList ConsideredStopPlaces { get; init; } = [];
+
+ ///
+ /// Entries matching the query.
+ ///
+ public IReadOnlyList Entries { get; init; } = [];
+
+ ///
+ /// Station-level disruption messages.
+ ///
+ public IReadOnlyList StationMessages { get; init; } = [];
+
+ ///