Somum.Requests
10.1.6
dotnet add package Somum.Requests --version 10.1.6
NuGet\Install-Package Somum.Requests -Version 10.1.6
<PackageReference Include="Somum.Requests" Version="10.1.6" />
<PackageVersion Include="Somum.Requests" Version="10.1.6" />
<PackageReference Include="Somum.Requests" />
paket add Somum.Requests --version 10.1.6
#r "nuget: Somum.Requests, 10.1.6"
#:package Somum.Requests@10.1.6
#addin nuget:?package=Somum.Requests&version=10.1.6
#tool nuget:?package=Somum.Requests&version=10.1.6
Somum.Requests
Somum.Requests provides base request types and URI construction helpers for Somum API contracts. Derive a request from QueryBase<TResponse> for read operations or CommandBase<TResponse> for state-changing operations.
QueryBase<TResponse>is the abstract base class used for GET queries.
Build a request URI
Override Endpoint with the resource path and, when necessary, Version with the API version. Mark public properties with FromQuery to include their non-null values in the query string. Supply Name to FromQuery when the API parameter name differs from the property name.
using Microsoft.AspNetCore.Mvc;
using Somum.Requests;
public sealed class GetJobsRequest : QueryBase<IReadOnlyList<Job>>
{
protected override string Endpoint => "jobs";
protected override int Version => 2;
[FromQuery(Name = "page")]
public int? Page { get; init; }
[FromQuery(Name = "pageSize")]
public int? PageSize { get; init; }
}
var request = new GetJobsRequest { Page = 1, PageSize = 25 };
var queryString = request.ToQueryString();
// page=1&pageSize=25
var relativeUri = request.GetUri("messaging");
// messaging/api/v2/jobs?page=1&pageSize=25
var url = request.GetUrl("https://api.example.com", "messaging");
// https://api.example.com/messaging/api/v2/jobs?page=1&pageSize=25
API behavior
| Method | Purpose |
|---|---|
ToQueryString() |
Builds a query string from non-null public instance properties marked with FromQuery. The returned value has no leading ?. |
GetUri(prefix) |
Builds a relative URI in the form [prefix/]api/v{Version}/{Endpoint}[?query]. |
GetUrl(host, prefix) |
Builds an absolute HTTP or HTTPS URL by combining host and GetUri(prefix). The host can include a base path. |
GetUrl requires an absolute HTTP or HTTPS host and rejects hosts containing a query string or fragment. Leading and trailing path separators are normalized when the URL is combined.
Query-string values
Query values are converted by QueryStringBuilder. Values are not URL-encoded, so encode values before assigning them to a FromQuery property when the API requires encoded text.
Navigating Queries
NavigatingQuery<T> provides the following query parameters for paginated, filtered, and ordered results:
| Property | Description |
|---|---|
Page |
The 1-based page number to retrieve. Defaults to 1. |
PageSize |
The maximum number of items to retrieve per page. Defaults to 10. |
Filter |
An optional Gridify filter expression. Filtered properties must belong to the DTO associated with the request response. Set to null or an empty string to apply no filtering. |
OrderBy |
An optional Gridify ordering expression. Ordered properties must belong to the DTO associated with the request response. Set to null or an empty string to apply no ordering. |
For filtering and ordering expression syntax, refer to the Gridify documentation.
Commands with HTTP Request Payloads
Use CommandBase<TResponse, TPayload> for POST and PUT requests that include a JSON body payload. The Payload property is automatically marked with [FromBody], allowing ASP.NET Core to bind the HTTP request body to the command.
Example `PUT` endpoint:
````````markdown
Example HTTP request:
````````markdown
The JSON request body is bound to `command.Payload`, while route, query string, and form values can be defined as additional properties on the command.
Paged Results
Paged<T> is the standard response model for paginated API endpoints. It contains the page data, total item count, paging details, and optional navigation links.
| Property | Description |
|---|---|
Data |
Items returned for the current page. |
Count |
Total number of items available across all pages. |
Page |
One-based number of the current page. Defaults to 1. |
PageSize |
Requested number of items per page. Defaults to 10. |
TotalPages |
Total number of pages calculated from Count and PageSize. |
HasNextPage |
Indicates whether another page follows the current page. |
HasPreviousPage |
Indicates whether a page precedes the current page. |
SelfLink |
URI for the current page. |
FirstLink |
URI for the first page. |
PreviousLink |
URI for the previous page, or null when the current page is the first page. |
NextLink |
URI for the next page, or null when the current page is the last page. |
LastLink |
URI for the last page. |
Response
| Product | Versions 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 was computed. 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 was computed. 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. |
-
.NETStandard 2.0
- MediatR.Contracts (>= 2.0.1)
- Microsoft.AspNetCore.Mvc (>= 2.3.13)
- Somum.Results (>= 10.1.6)
- System.Text.Json (>= 10.0.12)
- System.Text.RegularExpressions (>= 4.3.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Somum.Requests:
| Package | Downloads |
|---|---|
|
Somum.Broadcast.Requests
For handling broadcast jobs and wizards, like launching notifications or messages to multiple recipients. |
|
|
Somum.AccessControl.Requests
For handling access control requests (queries and commands) in the Somum API, like groups, access control lists, and permissions. |
GitHub repositories
This package is not used by any popular GitHub repositories.