Refactor Api-Client
Add Exceptionhandler, AlertService JSON-Converter AppSettings via DI Reformat Code
This commit is contained in:
23
Jugenddienst Stunden/Infrastructure/NullApiClient.cs
Normal file
23
Jugenddienst Stunden/Infrastructure/NullApiClient.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Jugenddienst_Stunden.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jugenddienst_Stunden.Infrastructure;
|
||||
|
||||
internal sealed class NullApiClient : IApiClient {
|
||||
private readonly string _message;
|
||||
public NullApiClient(string message) => _message = message ?? "API nicht konfiguriert.";
|
||||
|
||||
public Task<T> GetAsync<T>(string path, IDictionary<string, string?>? query = null, CancellationToken ct = default)
|
||||
=> Task.FromException<T>(new InvalidOperationException(_message));
|
||||
|
||||
public Task<T> SendAsync<T>(HttpMethod method, string path, object? body = null,
|
||||
IDictionary<string, string?>? query = null, CancellationToken ct = default)
|
||||
=> Task.FromException<T>(new InvalidOperationException(_message));
|
||||
|
||||
public Task DeleteAsync(string path, IDictionary<string, string?>? query = null, CancellationToken ct = default)
|
||||
=> Task.FromException(new InvalidOperationException(_message));
|
||||
}
|
||||
Reference in New Issue
Block a user