Skip to content

Implement Termii client configuration and HTTP pipeline#17

Merged
teesofttech merged 1 commit into
mainfrom
feature/2-http-pipeline
Jun 13, 2026
Merged

Implement Termii client configuration and HTTP pipeline#17
teesofttech merged 1 commit into
mainfrom
feature/2-http-pipeline

Conversation

@teesofttech

@teesofttech teesofttech commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the shared client configuration, authentication, and HTTP request pipeline that future endpoint clients will use.

What changed

  • Added HttpClient-based TermiiClient construction.
  • Added an internal JSON HTTP pipeline.
  • Added API key injection for query-string and JSON-body authentication flows.
  • Added configurable request timeout.
  • Added AddTermii(...) dependency injection registration for ASP.NET Core style usage.
  • Added unit coverage for query authentication, body authentication, and DI registration.
  • Updated README usage and the API coverage matrix.

Validation

  • dotnet restore Termii.SDK.sln
  • dotnet build Termii.SDK.sln --configuration Release --no-restore
  • dotnet test Termii.SDK.sln --configuration Release --no-build

Closes #2

Summary by CodeRabbit

  • New Features

    • Added dependency injection support via AddTermii extension for ASP.NET Core integration
    • Introduced configurable timeout setting for HTTP operations
    • Refactored SDK client with improved resource management
  • Documentation

    • Added ASP.NET Core usage example in README showing dependency injection setup
  • Tests

    • Added test coverage for API key authentication and service registration

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 69206db9-b4f4-4841-9394-3ec6b2d06109

📥 Commits

Reviewing files that changed from the base of the PR and between 278436b and cd5ac55.

📒 Files selected for processing (11)
  • README.md
  • docs/API_COVERAGE.md
  • src/Termii/Properties/AssemblyInfo.cs
  • src/Termii/Termii.csproj
  • src/Termii/TermiiAuthenticationLocation.cs
  • src/Termii/TermiiClient.cs
  • src/Termii/TermiiJsonHttpPipeline.cs
  • src/Termii/TermiiOptions.cs
  • src/Termii/TermiiServiceCollectionExtensions.cs
  • tests/Termii.Tests/Termii.Tests.csproj
  • tests/Termii.Tests/TermiiClientTests.cs

📝 Walkthrough

Walkthrough

This PR implements the complete Termii SDK client foundation. It adds configuration validation, an HTTP request pipeline with api_key authentication handling (query string or JSON body), a disposable TermiiClient managing HttpClient lifecycle, ASP.NET Core dependency injection support, comprehensive test coverage, and documentation examples.

Changes

SDK Foundation Implementation

Layer / File(s) Summary
Configuration & Options Foundation
src/Termii/TermiiOptions.cs, src/Termii/TermiiAuthenticationLocation.cs, src/Termii/Properties/AssemblyInfo.cs
TermiiOptions gains a Timeout property (100 seconds default) and enhanced validation ensuring non-null absolute BaseUrl and positive Timeout. TermiiAuthenticationLocation enum specifies where API key is placed (None, Query, Body). Assembly info enables test access to internal members via InternalsVisibleTo.
HTTP Request Pipeline & Authentication
src/Termii/TermiiJsonHttpPipeline.cs
TermiiJsonHttpPipeline builds and executes HTTP requests with JSON serialization (ignoring null values). Conditionally appends api_key to query string or embeds into JSON body per TermiiAuthenticationLocation. Merges API key with request body while preventing duplicate keys (case-insensitive).
Client Lifecycle & Request Delegation
src/Termii/TermiiClient.cs
TermiiClient refactored to sealed class implementing IDisposable. Manages HttpClient with explicit ownership tracking (ownsHttpClient flag). Supports construction from TermiiOptions (creates HttpClient) or pre-configured HttpClient. Public Dispose() conditionally disposes owned client. Internal SendAsync delegates to TermiiJsonHttpPipeline.
Dependency Injection Integration
src/Termii/TermiiServiceCollectionExtensions.cs, src/Termii/Termii.csproj
AddTermii extension method registers validated TermiiOptions as singleton and configures HttpClient (base address, timeout) via AddHttpClient<TermiiClient>. Project file adds Microsoft.Extensions.Http and System.Text.Json dependencies.
Test Coverage & Validation
tests/Termii.Tests/TermiiClientTests.cs, tests/Termii.Tests/Termii.Tests.csproj
Tests verify SendAsync appends api_key to query string (GET) and JSON body (POST). Test validates AddTermii DI registration with configured ApiKey, normalized BaseUrl, and Timeout. RecordingHttpMessageHandler captures outgoing requests for assertion. Test project adds Microsoft.Extensions.DependencyInjection dependency.
Documentation & API Status
README.md, docs/API_COVERAGE.md
README includes ASP.NET Core DI registration example: builder.Services.AddTermii(options => options.ApiKey = ...). API coverage matrix updates client configuration and authentication row from Planned to In progress.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 A client foundation rises, secure and bright,
With pipelines flowing, authentication done right!
From options to tests, the SDK takes flight—
Termii's REST calls now shine in the light! 🌟

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/2-http-pipeline

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@teesofttech
teesofttech changed the base branch from feature/1-bootstrap-sdk to main June 13, 2026 10:56
@teesofttech
teesofttech marked this pull request as ready for review June 13, 2026 11:03
Copilot AI review requested due to automatic review settings June 13, 2026 11:03
@teesofttech
teesofttech merged commit f5a006a into main Jun 13, 2026
2 of 3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Termii client configuration, authentication, and HTTP pipeline

2 participants