56 lines
2.0 KiB
C#
56 lines
2.0 KiB
C#
using GestionaDenuncias.Shared.Models;
|
|
|
|
namespace GestionaDenunciasAN.Services;
|
|
|
|
public sealed class ApiInboxTrackingService : IInboxTrackingService
|
|
{
|
|
private readonly ApiDenunciasClient _api;
|
|
|
|
public ApiInboxTrackingService(ApiDenunciasClient api)
|
|
{
|
|
_api = api;
|
|
}
|
|
|
|
public Task<InboxUserState> GetUserStateAsync(string username, CancellationToken cancellationToken = default)
|
|
=> _api.GetAsync<InboxUserState>("api/tracking/user-state", cancellationToken);
|
|
|
|
public Task<IReadOnlyList<ReportDto>> RegisterSnapshotAsync(
|
|
string username,
|
|
IEnumerable<ReportDto> reports,
|
|
CancellationToken cancellationToken = default)
|
|
=> _api.PostAsync<IReadOnlyList<ReportDto>>(
|
|
"api/tracking/snapshot",
|
|
new TrackingSnapshotRequest(username, reports.ToArray()),
|
|
cancellationToken);
|
|
|
|
public Task MarkReportImportedAsync(
|
|
string username,
|
|
ReportDto report,
|
|
int? complaintId,
|
|
CancellationToken cancellationToken = default)
|
|
=> _api.PostAsync(
|
|
"api/tracking/imported",
|
|
new MarkReportImportedRequest(username, report, complaintId),
|
|
cancellationToken);
|
|
|
|
public Task MarkReportHandledInGestionaAsync(
|
|
string username,
|
|
int denunciaId,
|
|
DateTime uploadedAtUtc,
|
|
CancellationToken cancellationToken = default)
|
|
=> _api.PostAsync(
|
|
"api/tracking/handled-in-gestiona",
|
|
new MarkReportHandledInGestionaRequest(username, denunciaId, uploadedAtUtc),
|
|
cancellationToken);
|
|
|
|
public Task EnsureReportCanBeImportedByUserAsync(
|
|
string username,
|
|
ReportDto report,
|
|
bool confirmDifferentOwner = false,
|
|
CancellationToken cancellationToken = default)
|
|
=> _api.PostAsync(
|
|
"api/tracking/import-permission",
|
|
new TrackingImportPermissionRequest(username, report, confirmDifferentOwner),
|
|
cancellationToken);
|
|
}
|