Table of Contents

Class ClientBase

Namespace
DotVgn.Client.Base
Assembly
DotVgn.Client.dll

Base class for API clients.

public class ClientBase
Inheritance
ClientBase
Derived
Inherited Members

Constructors

ClientBase(ClientOptions?)

Initializes a new instance of the ClientBase class.

protected ClientBase(ClientOptions? options = null)

Parameters

options ClientOptions

The options to use.

ClientBase(HttpClient)

Initializes a new instance of the ClientBase class.

protected ClientBase(HttpClient http)

Parameters

http HttpClient

The http client to use.

Methods

SendRequestAsync<T>(JsonTypeInfo<T>, string, CancellationToken)

Sends an asynchronous request to the specified path and deserializes the response body to the specified type.

protected Task<T> SendRequestAsync<T>(JsonTypeInfo<T> typeInfo, string path, CancellationToken cancellation)

Parameters

typeInfo JsonTypeInfo<T>

The source-generated JSON type information for T.

path string

The relative path to append to the base address for the HTTP request.

cancellation CancellationToken

A cancellation token that can be used to cancel the asynchronous operation.

Returns

Task<T>

The task result contains the deserialized response body of type T.

Type Parameters

T

The type to which the response body will be deserialized.

Exceptions

DotVgnApiException

Thrown if the HTTP response indicates a failure status code, or if the response body is empty or cannot be deserialized to the specified type.

SendRequestsAsync<TItem, TValue>(JsonTypeInfo<TValue>, IEnumerable<TItem>, CancellationToken)

Sends a batch of asynchronous requests to the specified paths and deserializes the response bodies to the specified type.

protected Task<IReadOnlyList<(TItem Key, TValue Value)>> SendRequestsAsync<TItem, TValue>(JsonTypeInfo<TValue> typeInfo, IEnumerable<TItem> queries, CancellationToken cancellation) where TItem : IQuery

Parameters

typeInfo JsonTypeInfo<TValue>

The source-generated JSON type information for TValue.

queries IEnumerable<TItem>

The items to process.

cancellation CancellationToken

A cancellation token that can be used to cancel the request.

Returns

Task<IReadOnlyList<(TItem Key, TValue Value)>>

The task result contains the deserialized read-only list of (Key, Value) pairs.

Type Parameters

TItem

The item type to process.

TValue

The result type produced by the worker.

Exceptions

DotVgnApiException

Thrown if the HTTP response indicates a failure status code, or if the response body is empty or cannot be deserialized to the specified type.