-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathIQueryClient.cs
30 lines (29 loc) · 1.7 KB
/
IQueryClient.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
namespace CommandQuery.Client
{
/// <summary>
/// Client for sending queries to CommandQuery APIs over <c>HTTP</c>.
/// </summary>
public interface IQueryClient
{
/// <summary>
/// Sends an <see cref="IQuery{TResult}"/> to the API with <c>GET</c>.
/// </summary>
/// <typeparam name="TResult">The type of result.</typeparam>
/// <param name="query">The query.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>A result.</returns>
/// <exception cref="ArgumentNullException"><paramref name="query"/> is <see langword="null"/>.</exception>
/// <exception cref="CommandQueryException">The <see cref="IQuery{TResult}"/> failed.</exception>
Task<TResult?> GetAsync<TResult>(IQuery<TResult> query, CancellationToken cancellationToken = default);
/// <summary>
/// Sends an <see cref="IQuery{TResult}"/> to the API with <c>POST</c>.
/// </summary>
/// <typeparam name="TResult">The type of result.</typeparam>
/// <param name="query">The query.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>A result.</returns>
/// <exception cref="ArgumentNullException"><paramref name="query"/> is <see langword="null"/>.</exception>
/// <exception cref="CommandQueryException">The <see cref="IQuery{TResult}"/> failed.</exception>
Task<TResult?> PostAsync<TResult>(IQuery<TResult> query, CancellationToken cancellationToken = default);
}
}