80 lines
3.1 KiB
C#
80 lines
3.1 KiB
C#
using Castle.Core.Logging;
|
|
|
|
namespace Pilz.Net.Api;
|
|
|
|
public interface IApiClient
|
|
{
|
|
string ApiUrl { get; }
|
|
|
|
string? AuthKey { get; set; }
|
|
|
|
IApiMessageSerializer Serializer { get; }
|
|
|
|
ILogger Log { get; set; }
|
|
|
|
T GetClient<T>() where T : IApiSubClient;
|
|
Task<ApiResponse> SendRequest(string route, HttpMethod method, ApiMessage? message, ApiParameterCollection? @params, IApiMessageSerializer? serializer);
|
|
|
|
Task<ApiResponse<TResponse>> SendRequest<TResponse>(string route, HttpMethod method, ApiMessage? message, ApiParameterCollection? @params, IApiMessageSerializer? serializer) where TResponse : ApiMessage;
|
|
|
|
public virtual Task<ApiResponse> SendRequest(string route)
|
|
{
|
|
return SendRequest(route, HttpMethod.Post, null, null, null);
|
|
}
|
|
|
|
public virtual Task<ApiResponse> SendRequest(string route, HttpMethod method)
|
|
{
|
|
return SendRequest(route, method, null, null, null);
|
|
}
|
|
|
|
public virtual Task<ApiResponse> SendRequest(string route, HttpMethod method, ApiParameterCollection? @params)
|
|
{
|
|
return SendRequest(route, method, null, @params, null);
|
|
}
|
|
|
|
public virtual Task<ApiResponse> SendRequest(string route, ApiMessage? message)
|
|
{
|
|
return SendRequest(route, HttpMethod.Post, message, null, null);
|
|
}
|
|
|
|
public virtual Task<ApiResponse> SendRequest(string route, HttpMethod method, ApiMessage? message)
|
|
{
|
|
return SendRequest(route, method, message, null, null);
|
|
}
|
|
|
|
public virtual Task<ApiResponse> SendRequest(string route, HttpMethod method, ApiMessage? message, ApiParameterCollection? @params)
|
|
{
|
|
return SendRequest(route, method, message, @params, null);
|
|
}
|
|
|
|
public virtual Task<ApiResponse<TResponse>> SendRequest<TResponse>(string route) where TResponse : ApiMessage
|
|
{
|
|
return SendRequest<TResponse>(route, HttpMethod.Post, null, null, null);
|
|
}
|
|
|
|
public virtual Task<ApiResponse<TResponse>> SendRequest<TResponse>(string route, HttpMethod method) where TResponse : ApiMessage
|
|
{
|
|
return SendRequest<TResponse>(route, method, null, null, null);
|
|
}
|
|
|
|
public virtual Task<ApiResponse<TResponse>> SendRequest<TResponse>(string route, HttpMethod method, ApiParameterCollection? @params) where TResponse : ApiMessage
|
|
{
|
|
return SendRequest<TResponse>(route, method, null, @params, null);
|
|
}
|
|
|
|
public virtual Task<ApiResponse<TResponse>> SendRequest<TResponse>(string route, ApiMessage? message) where TResponse : ApiMessage
|
|
{
|
|
return SendRequest<TResponse>(route, HttpMethod.Post, message, null, null);
|
|
}
|
|
|
|
public virtual Task<ApiResponse<TResponse>> SendRequest<TResponse>(string route, HttpMethod method, ApiMessage? message) where TResponse : ApiMessage
|
|
{
|
|
return SendRequest<TResponse>(route, method, message, null, null);
|
|
}
|
|
|
|
public virtual Task<ApiResponse<TResponse>> SendRequest<TResponse>(string route, HttpMethod method, ApiMessage? message, ApiParameterCollection? @params) where TResponse : ApiMessage
|
|
{
|
|
return SendRequest<TResponse>(route, method, message, @params, null);
|
|
}
|
|
}
|