using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace ReC.Client.Api
{
///
/// Provides access to RecAction endpoints.
///
public class RecActionApi : BaseCrudApi
{
///
/// Initializes a new instance of the class.
///
/// The HTTP client used for requests.
public RecActionApi(HttpClient http) : base(http, "api/RecAction")
{
}
///
/// Invokes a ReC action for the specified profile.
///
/// The profile identifier.
/// A token to cancel the operation.
/// if the request succeeds; otherwise, .
public async Task InvokeAsync(int profileId, CancellationToken cancellationToken = default)
{
var resp = await Http.PostAsync($"{ResourcePath}/invoke/{profileId}", content: null, cancellationToken);
return resp.IsSuccessStatusCode;
}
///
/// Retrieves Rec actions.
///
/// Optional profile filter.
/// Optional invoked filter.
/// A token to cancel the operation.
/// The HTTP response message.
public Task GetAsync(long? profileId = null, bool? invoked = null, CancellationToken cancel = default)
{
var query = ReCClientHelpers.BuildQuery(("ProfileId", profileId), ("Invoked", invoked));
return Http.GetAsync($"{ResourcePath}{query}", cancel);
}
}
}