Class ClientBase
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
optionsClientOptionsThe options to use.
ClientBase(HttpClient)
Initializes a new instance of the ClientBase class.
protected ClientBase(HttpClient http)
Parameters
httpHttpClientThe 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
typeInfoJsonTypeInfo<T>The source-generated JSON type information for
T.pathstringThe relative path to append to the base address for the HTTP request.
cancellationCancellationTokenA 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
TThe 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
typeInfoJsonTypeInfo<TValue>The source-generated JSON type information for
TValue.queriesIEnumerable<TItem>The items to process.
cancellationCancellationTokenA 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
TItemThe item type to process.
TValueThe 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.