OpenUrzednik.Transport.Http 1.1.0-preview.121.gdc045d8e7a

Prefix Reserved
This is a prerelease version of OpenUrzednik.Transport.Http.
dotnet add package OpenUrzednik.Transport.Http --version 1.1.0-preview.121.gdc045d8e7a
                    
NuGet\Install-Package OpenUrzednik.Transport.Http -Version 1.1.0-preview.121.gdc045d8e7a
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenUrzednik.Transport.Http" Version="1.1.0-preview.121.gdc045d8e7a" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenUrzednik.Transport.Http" Version="1.1.0-preview.121.gdc045d8e7a" />
                    
Directory.Packages.props
<PackageReference Include="OpenUrzednik.Transport.Http" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenUrzednik.Transport.Http --version 1.1.0-preview.121.gdc045d8e7a
                    
#r "nuget: OpenUrzednik.Transport.Http, 1.1.0-preview.121.gdc045d8e7a"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OpenUrzednik.Transport.Http@1.1.0-preview.121.gdc045d8e7a
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenUrzednik.Transport.Http&version=1.1.0-preview.121.gdc045d8e7a&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=OpenUrzednik.Transport.Http&version=1.1.0-preview.121.gdc045d8e7a&prerelease
                    
Install as a Cake Tool

OpenUrzednik.Transport.Http

🇵🇱 Wersja polska (skrócona)

⚠️ Unofficial: OpenUrzednik.NET is a community project. It is not affiliated with, authorized or endorsed by Narodowy Bank Polski (NBP) or any other Polish public institution.

The HTTP transport types of OpenUrzednik.NET: the errors a REST client returns when an HTTP response caused them, and their status code.

Part of OpenUrzednik.NET. See the main README for an overview of the project.

Installation

Every REST provider (e.g. OpenUrzednik.Nbp) depends on this package, so you get it with the provider. Install it on its own only if you build your own client in the same style:

dotnet add package OpenUrzednik.Transport.Http

Usage

OpenUrzednik.Core describes conditions (not found, rate limited, unavailable), whatever the transport. When an HTTP response caused the error, a client returns the condition's HTTP subclass from this package:

HTTP response Error It is a
400 HttpBadRequestError BadRequestError
401, 403 HttpUnauthorizedError UnauthorizedError
404 HttpNotFoundError NotFoundError
408 HttpRequestTimeoutError RequestTimeoutError
429 HttpRateLimitExceededError RateLimitExceededError
5xx HttpServiceUnavailableError ServiceUnavailableError
another status HttpUnknownError UnknownError

A provider may map a status to another condition (e.g. a quota answered with 400); the error is then that condition's HTTP subclass. Every subclass keeps its condition's Code and exception, so your is NotFoundError and Code checks handle an HttpNotFoundError like any other NotFoundError. A provider can derive its own type from an HTTP subclass to add details of its API, such as its error code; its README names those types, and they pass the same checks. Read the status through IOpenUrzednikHttpStatusCode:

using System.Net;

using OpenUrzednik.Transport.Http;

var result = await client.GetAsync(date);
if (result.IsFailure && result.Errors[0] is IOpenUrzednikHttpStatusCode http)
    Console.WriteLine($"HTTP {(int)http.StatusCode}");

// Or, without a type check: null when no HTTP response caused the error.
HttpStatusCode? status = result.Errors[0].GetHttpStatus();

An error with no HTTP response behind it is Core's plain type (or a provider's subclass of it): an empty answer (NotFoundError), a client-side timeout (RequestTimeoutError), a resilience handler's rejection (ServiceUnavailableError) or a network failure (ConnectionFailedError).

The status is a System.Net.HttpStatusCode. 429 Too Many Requests (RFC 6585) has no named member on netstandard2.0 and .NET Framework, so compare with (HttpStatusCode)429 there. TryGetHttpStatus(out var status) is the non-nullable form of GetHttpStatus().

Metadata holds the status as an int under "statusCode" (HttpStatusExtensions.StatusCodeMetadataKey), the type OpenTelemetry uses for http.response.status_code, so you can copy Metadata into a ProblemDetails response as it is.

Core's GetHttpStatusCode() and TryGetHttpStatusCode() (HttpErrorMetadata) are obsolete: they keep working until 2.0, but use GetHttpStatus() from this package.

Compatibility

IOpenUrzednikHttpStatusCode never gets a new member: a further HTTP detail comes as a separate interface. The HTTP error types stay unsealed, so providers can derive from them. Code that compares the exact type (error.GetType() == typeof(NotFoundError), or typeof(HttpNotFoundError), which a provider's subclass doesn't match) misses them; use is or Code.

Dependencies

OpenUrzednik.Core only. The .NET builds are trimming- and Native AOT-safe.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on OpenUrzednik.Transport.Http:

Package Downloads
OpenUrzednik.Nbp

Unofficial .NET client for the NBP (Narodowy Bank Polski) API: currency exchange rates, rate tables and gold prices. Not affiliated with NBP.

OpenUrzednik.MF.WhiteList

Unofficial .NET client for the Polish Ministry of Finance VAT White List API (Wykaz podatników VAT): search by NIP, REGON or account number, check an account against a NIP or REGON, and the WL2 VAT status, each answer with its requestId proof. Not affiliated with the Ministry of Finance.

GitHub repositories

This package is not used by any popular GitHub repositories.