using New.Application.Ports; using New.Infrastructure.CaseFramework.Dtos; namespace New.Infrastructure.CaseFramework; /// Seam D: implements against the case-framework's own contract. public sealed class CaseFrameworkGateway : ICaseFrameworkGateway { private readonly CaseFrameworkClient _client; // Internal constructor parameter type (CaseFrameworkClient is internal - // its API is shaped by case-framework DTOs). Registered via an explicit // factory in ServiceCollectionExtensions; see that file's remarks. internal CaseFrameworkGateway(CaseFrameworkClient client) => _client = client; public async Task CreateCaseAsync(string caseTypeCode, string externalReference, IReadOnlyList participants, CancellationToken ct) { var response = await _client.CreateCaseAsync( new CreateCaseRequest(caseTypeCode, externalReference, participants.ToList()), ct); return new CaseCreated(response.Id, response.ProcessStatus); } public async Task GetProcessStatusAsync(Guid caseId, CancellationToken ct) { var response = await _client.GetCaseAsync(caseId, ct); return response?.ProcessStatus; } public async Task CreateTaskAsync(Guid caseId, string code, string description, CancellationToken ct) { var response = await _client.CreateTaskAsync(caseId, new CreateTaskRequest(code, description), ct); return new TaskCreated(response.TaskId, response.Open); } public Task CompleteTaskAsync(Guid caseId, Guid taskId, CancellationToken ct) => _client.CompleteTaskAsync(caseId, taskId, ct); public Task RequestClosureAsync(Guid caseId, CancellationToken ct) => _client.RequestClosureAsync(caseId, ct); }