Compare commits

...

10 Commits

Author SHA1 Message Date
Developer 02
682fb772f7 feat(infrastructure): Unterstützung für generische IEConnectClient<>-Registrierung hinzugefügt 2025-08-12 20:10:18 +02:00
Developer 02
9d5bf509d5 feat(EConnectClient): created as an implementation of IEConnectClient 2025-08-12 20:08:36 +02:00
Developer 02
757ba77179 feat(IEConnectClient): create interface to handle abse http client operations 2025-08-12 19:38:22 +02:00
Developer 02
11ab4388d0 create response class to handle http result 2025-08-12 19:29:32 +02:00
Developer 02
d904fded39 refactor: rename HttpClient-related members to EConnectClient for clarity 2025-08-12 18:46:38 +02:00
Developer 02
e6a8c81a0b feat(infrastructure): add extension method to create EConnect HttpClient 2025-08-12 18:44:41 +02:00
Developer 02
4256a79122 feat(infrastructure): add extension methods for configuring and registering HttpClient
- Implemented ConfigureHttpClient extension for IServiceCollection with dynamic client name
- Added AddInfrastructureServices method to simplify HttpClient registration via configurable options
- Introduced sealed Config class for flexible client configuration
2025-08-12 18:41:07 +02:00
Developer 02
c3c6ffdf99 init Leanetec.EConnect.Infrastructure 2025-08-12 17:11:55 +02:00
Developer 02
8b248db4e2 feat(domain): neue Entität 'ProblemDetail' hinzugefügt 2025-08-12 17:02:03 +02:00
Developer 02
c5787c8736 feat(domain): neue Entität 'OrderDocument' hinzugefügt 2025-08-12 16:50:28 +02:00
9 changed files with 182 additions and 0 deletions

View File

@ -15,6 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{AC628874-E
docs\econnect-api_swagger.pdf = docs\econnect-api_swagger.pdf
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Leanetec.EConnect.Infrastructure", "src\Leanetec.EConnect.Infrastructure\Leanetec.EConnect.Infrastructure.csproj", "{88A1AA25-45F3-4082-8B5A-F95FC8A21057}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -29,6 +31,10 @@ Global
{9242EEA9-447B-44A6-A66D-D671DD16D0BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9242EEA9-447B-44A6-A66D-D671DD16D0BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9242EEA9-447B-44A6-A66D-D671DD16D0BB}.Release|Any CPU.Build.0 = Release|Any CPU
{88A1AA25-45F3-4082-8B5A-F95FC8A21057}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88A1AA25-45F3-4082-8B5A-F95FC8A21057}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88A1AA25-45F3-4082-8B5A-F95FC8A21057}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88A1AA25-45F3-4082-8B5A-F95FC8A21057}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -36,6 +42,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{34DC964A-1905-7DFC-0125-D551D3EEFCDD} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{9242EEA9-447B-44A6-A66D-D671DD16D0BB} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{88A1AA25-45F3-4082-8B5A-F95FC8A21057} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8C81AD6F-B903-4C78-873C-38EE216EFAD5}

View File

@ -0,0 +1,11 @@
using Leanetec.EConnect.Domain.Entities;
namespace Leanetec.EConnect.Client.Interface;
public interface IEConnectClient<TError> where TError : class
{
public Task<Response<TData, TError>> GetAsync<TData>(string? route = null, CancellationToken cancel = default) where TData : class;
public Task<Response<IAsyncEnumerable<TData?>, TError>> GetListAsAsyncEnumerable<TData>(string? route = null, CancellationToken cancel = default)
where TData : class;
}

View File

@ -0,0 +1,39 @@
namespace Leanetec.EConnect.Domain.Entities;
public class OrderDocument
{
/// <summary>
/// The unique internal id of the file
/// </summary>
public int Id { get; init; }
/// <summary>
/// The name of the file
/// </summary>
public string? FileName { get; init; }
/// <summary>
/// The size of the file in bytes
/// </summary>
public int FileSizeInBytes { get; init; }
/// <summary>
/// The internal unique id of the folder containing this file
/// </summary>
public int ParentFolderId { get; init; }
/// <summary>
/// The string representation of the timstamp when this file has been created (uploaded)
/// </summary>
public DateTime? CreatedOn { get; init; }
/// <summary>
/// The string representation of the timstamp when this file has been updated
/// </summary>
public DateTime? LastUpdateOn { get; init; }
/// <summary>
/// The MIME type of the file
/// </summary>
public string? FileMimeType { get; init; }
}

View File

@ -0,0 +1,10 @@
namespace Leanetec.EConnect.Domain.Entities;
public class ProblemDetail
{
public string? Type { get; init; }
public string? Title { get; init; }
public int? Status { get; init; }
public string? Detail { get; init; }
public string? Instance { get; init; }
}

View File

@ -0,0 +1,5 @@
namespace Leanetec.EConnect.Domain.Entities;
public record Response<TData, TError>(bool Ok, TData? Data = null, TError? Error = null)
where TData : class
where TError : class;

View File

@ -0,0 +1,6 @@
namespace Leanetec.EConnect.Infrastructure;
public static class ClientExtensions
{
public static HttpClient CreateEConnectClient(this IHttpClientFactory factory) => factory.CreateClient(DependencyInjection.EConnectClientName);
}

View File

@ -0,0 +1,36 @@
using Leanetec.EConnect.Client.Interface;
using Microsoft.Extensions.DependencyInjection;
namespace Leanetec.EConnect.Infrastructure;
public static class DependencyInjection
{
internal static readonly string EConnectClientName = Guid.NewGuid().ToString();
internal static IServiceCollection ConfigureEConnectClient(this IServiceCollection services, Action<HttpClient> configureClient)
{
services.AddHttpClient(EConnectClientName, configureClient);
return services;
}
public static IServiceCollection AddInfrastructureServices(this IServiceCollection services, Action<Config> options)
{
Config config = new(services);
options.Invoke(config);
services.ConfigureEConnectClient(config.EConnectClient);
services.AddScoped(typeof(IEConnectClient<>), typeof(EConnectClient<>));
return services;
}
public sealed class Config
{
private readonly IServiceCollection _services;
internal Config(IServiceCollection services)
{
_services = services;
}
public Action<HttpClient> EConnectClient { get; set; } = _ => { };
}
}

View File

@ -0,0 +1,49 @@
using Leanetec.EConnect.Client.Interface;
using Leanetec.EConnect.Domain.Entities;
using System.Net.Http.Json;
namespace Leanetec.EConnect.Infrastructure;
public class EConnectClient<TError> : IEConnectClient<TError> where TError : class
{
private readonly HttpClient _http;
public EConnectClient(IHttpClientFactory factory)
{
_http = factory.CreateEConnectClient();
}
public async Task<Response<TData, TError>> GetAsync<TData>(string? route = null, CancellationToken cancel = default)
where TData : class
{
var res = await _http.GetAsync(route, cancel);
if (res.IsSuccessStatusCode)
{
var data = await res.Content.ReadFromJsonAsync<TData>(cancel);
return new Response<TData, TError>(true, Data: data);
}
else
{
var error = await res.Content.ReadFromJsonAsync<TError>(cancel);
return new Response<TData, TError>(false, Error: error);
}
}
public async Task<Response<IAsyncEnumerable<TData?>, TError>> GetListAsAsyncEnumerable<TData>(string? route = null, CancellationToken cancel = default)
where TData : class
{
var res = await _http.GetAsync(route, cancel);
if (res.IsSuccessStatusCode)
{
var data = res.Content.ReadFromJsonAsAsyncEnumerable<TData>(cancel);
return new Response<IAsyncEnumerable<TData?>, TError>(true, Data: data);
}
else
{
var error = await res.Content.ReadFromJsonAsync<TError>(cancellationToken: cancel);
return new Response<IAsyncEnumerable<TData?>, TError>(false, Error: error);
}
}
}

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Leanetec.EConnect.Client\Leanetec.EConnect.Client.csproj" />
<ProjectReference Include="..\Leanetec.EConnect.Domain\Leanetec.EConnect.Domain.csproj" />
</ItemGroup>
</Project>