HTTP API Toolkit HTTP API Toolkit
HTTP API Toolkit HTTP API Toolkit
DocFX + Singulink = ♥

Search Results for

    Class ApiClientBase

    Base class for API clients.

    Inheritance
    object
    ApiClientBase
    SignalRApiClientBase
    Namespace: Singulink.Net.Http.Api.Client
    Assembly: Singulink.Net.Http.Api.Client.dll
    Syntax
    public abstract class ApiClientBase

    Constructors

    Name Description
    ApiClientBase()

    Initializes a new instance of the ApiClientBase class using reflection-based JSON serialization with default Web options.

    ApiClientBase(ApiClientBase)

    Initializes a new instance of the ApiClientBase class that shares the session state and JSON serializer options with the specified parent client.

    ApiClientBase(string?, Action<string?>?)

    Initializes a new instance of the ApiClientBase class using reflection-based JSON serialization with default Web options, the specified session token and session token changed callback.

    ApiClientBase(JsonSerializerOptions, string?, Action<string?>?)

    Initializes a new instance of the ApiClientBase class using the specified JSON serializer options, with an optional session token and session token changed callback.

    ApiClientBase(IJsonTypeInfoResolver, Action<JsonSerializerOptions>?)

    Initializes a new instance of the ApiClientBase class using JSON serialization backed by the specified source-generated type information resolver (e.g. a JsonSerializerContext). This constructor is compatible with trimming.

    ApiClientBase(IJsonTypeInfoResolver, string?, Action<string?>?, Action<JsonSerializerOptions>?)

    Initializes a new instance of the ApiClientBase class using JSON serialization backed by the specified source-generated type information resolver (e.g. a JsonSerializerContext), with the specified session token and session token changed callback. This constructor is compatible with trimming.

    Fields

    Name Description
    DefaultSessionCookieName

    The default name of the cookie that holds the encrypted session token. Value is "session-token".

    DefaultUserIdPreconditionQueryName

    The default query parameter name for the user ID precondition that is used to ensure the cookie session user ID matches the expected user ID making the API request. Value is "if-userId".

    Properties

    Name Description
    IsPersistentSession

    Gets or sets a value indicating whether the session token should be persisted via the session token changed callback.

    SerializerOptions

    Gets the JSON serializer options used for serializing and deserializing API request and response content. Defaults to options provided by Web.

    SessionCookieName

    Gets the name of the cookie that holds the encrypted session token. Defaults to DefaultSessionCookieName.

    SessionToken

    Gets the current session token.

    UserAgent

    Gets the user agent string sent with requests. On non-browser platforms, this is automatically applied to HTTP requests. If a parent client exists, returns the parent's value by default.

    Methods

    Name Description
    CreateRequest(HttpMethod, string, params ReadOnlySpan<(string Name, object? Value)>)

    Creates an API request with the specified HTTP method, path, and optional query string parameters.

    GetApiUrl(string, ReadOnlySpan<(string Name, object? Value)>)

    Builds a full API URL from the base address, path, and query string parameters. Default query parameters from GetDefaultQueryParams(string) are automatically merged with per-call parameters (per-call parameters with the same key take precedence).

    GetBaseAddress()

    Gets the default base address for the API client that is used if HTTP client does not have a base address set.

    GetDefaultQueryParams(string)

    Gets the default query string parameters to include in API requests and hub connections. Per-call parameters with the same key override default parameters. If a parent client exists, returns the parent's defaults. Override this method to inject common parameters such as the user ID precondition.

    SendAsync(HttpRequestMessage, object?, CancellationToken)

    Sends an API request with the specified content.

    SendAsync(HttpRequestMessage, CancellationToken)

    Sends an API request.

    SendAsync<TResponse>(HttpRequestMessage, object?, CancellationToken)

    Sends an API request with the specified content and returns the response.

    SendAsync<TResponse>(HttpRequestMessage, CancellationToken)

    Sends an API request and returns the response.

    SendStreamingAsync<TItem>(HttpRequestMessage, object?, CancellationToken)

    Sends an API request with the specified content and returns a streaming response (see StreamingResponse). Exceptions reported in the response stream are thrown from the enumeration as the corresponding ApiException. Null items are yielded as null, so a nullable item type should be used if the endpoint can produce them.

    SendStreamingAsync<TItem>(HttpRequestMessage, CancellationToken)

    Sends an API request and returns a streaming response (see StreamingResponse).

    © Singulink. All rights reserved.