using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using VigilCare.ClinicalContracts.Sync;
[ApiController]
[Produces("application/json")]
public class ClinicalSyncController : ControllerBase
{
private readonly IClinicalSyncService _sync;
public ClinicalSyncController(IClinicalSyncService sync) => _sync = sync;
/// Upload a buffered sync batch from a ward gateway.
[HttpPost("api/v1/sync/batches")]
[Authorize(AuthenticationSchemes = GatewayApiKeyAuthenticationHandler.SchemeName)]
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status201Created)]
public async Task UploadBatch(
[FromBody] ClinicalSyncBatchRequest request, CancellationToken ct)
{
var result = await _sync.UploadBatchAsync(request, ct);
return StatusCode(201, ApiResponse.Created(result));
}
/// Poll batch processing status and conflicts.
[HttpGet("api/v1/sync/batches/{batchId:guid}")]
[Authorize(AuthenticationSchemes =
$"{JwtBearerDefaults.AuthenticationScheme},{GatewayApiKeyAuthenticationHandler.SchemeName}")]
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiResponse