Make References and BatchId required for RecAction invoke
Updated InvokeRecActionViewCommand and InvokeReferencesDto to require non-null References and BatchId. Updated RecActionApi.InvokeAsync to require InvokeReferences and added an overload accepting batchId for convenience. This enforces stricter input validation and aligns client and backend requirements.
This commit is contained in:
@@ -18,12 +18,12 @@ namespace ReC.Application.RecActions.Commands;
|
||||
public record InvokeRecActionViewCommand : IRequest
|
||||
{
|
||||
public RecActionViewDto Action { get; set; } = null!;
|
||||
public InvokeReferencesDto? References { get; set; }
|
||||
public required InvokeReferencesDto References { get; set; }
|
||||
}
|
||||
|
||||
public record InvokeReferencesDto
|
||||
{
|
||||
public string? BatchId { get; init; }
|
||||
public required string BatchId { get; init; }
|
||||
public string? Reference1 { get; init; }
|
||||
public string? Reference2 { get; init; }
|
||||
public string? Reference3 { get; init; }
|
||||
|
||||
@@ -24,13 +24,25 @@ namespace ReC.Client.Api
|
||||
/// <param name="references">Optional reference values to pass through to all result records.</param>
|
||||
/// <param name="cancellationToken">A token to cancel the operation.</param>
|
||||
/// <returns><see langword="true"/> if the request succeeds; otherwise, <see langword="false"/>.</returns>
|
||||
public async Task<bool> InvokeAsync(int profileId, InvokeReferences references = null, CancellationToken cancellationToken = default)
|
||||
public async Task<bool> InvokeAsync(int profileId, InvokeReferences references, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var content = references != null ? ReCClientHelpers.ToJsonContent(references) : null;
|
||||
var resp = await Http.PostAsync($"{ResourcePath}/invoke/{profileId}", content, cancellationToken);
|
||||
return resp.IsSuccessStatusCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes a ReC action for the specified profile.
|
||||
/// </summary>
|
||||
/// <param name="profileId">The profile identifier.</param>
|
||||
/// <param name="batchId">Batch identifier.</param>
|
||||
/// <param name="cancellationToken">A token to cancel the operation.</param>
|
||||
/// <returns><see langword="true"/> if the request succeeds; otherwise, <see langword="false"/>.</returns>
|
||||
public Task<bool> InvokeAsync(int profileId, string batchId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return InvokeAsync(profileId, new InvokeReferences() { BatchId = batchId }, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves Rec actions.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user