Revert "Refactor BaseCrudApi to use generic type parameters"
This reverts commit 5197ad1481.
This commit is contained in:
@@ -8,7 +8,7 @@ namespace ReC.Client.Api
|
||||
/// <summary>
|
||||
/// Provides shared CRUD operations for API resources.
|
||||
/// </summary>
|
||||
public abstract class BaseCrudApi<TCreate, TUpdate, TDelete>
|
||||
public abstract class BaseCrudApi
|
||||
{
|
||||
/// <summary>
|
||||
/// The HTTP client used to send requests.
|
||||
@@ -21,7 +21,7 @@ namespace ReC.Client.Api
|
||||
protected readonly string ResourcePath;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseCrudApi{TCreate, TUpdate, TDelete}"/> class.
|
||||
/// Initializes a new instance of the <see cref="BaseCrudApi"/> class.
|
||||
/// </summary>
|
||||
/// <param name="http">The HTTP client used for requests.</param>
|
||||
/// <param name="resourcePath">The base resource path for the API endpoint.</param>
|
||||
@@ -34,29 +34,32 @@ namespace ReC.Client.Api
|
||||
/// <summary>
|
||||
/// Creates a resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The payload type.</typeparam>
|
||||
/// <param name="payload">The payload to send.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>The HTTP response message.</returns>
|
||||
public Task<HttpResponseMessage> CreateAsync(TCreate payload, CancellationToken cancel = default)
|
||||
public Task<HttpResponseMessage> CreateAsync<T>(T payload, CancellationToken cancel = default)
|
||||
=> Http.PostAsync(ResourcePath, ReCClientHelpers.ToJsonContent(payload), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Updates a resource by identifier.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The payload type.</typeparam>
|
||||
/// <param name="id">The resource identifier.</param>
|
||||
/// <param name="payload">The payload to send.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>The HTTP response message.</returns>
|
||||
public Task<HttpResponseMessage> UpdateAsync(long id, TUpdate payload, CancellationToken cancel = default)
|
||||
public Task<HttpResponseMessage> UpdateAsync<T>(long id, T payload, CancellationToken cancel = default)
|
||||
=> Http.PutAsync($"{ResourcePath}/{id}", ReCClientHelpers.ToJsonContent(payload), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes resources with identifiers supplied in the payload.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The payload type containing identifiers.</typeparam>
|
||||
/// <param name="payload">The payload to send.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>The HTTP response message.</returns>
|
||||
public Task<HttpResponseMessage> DeleteAsync(TDelete payload, CancellationToken cancel = default)
|
||||
public Task<HttpResponseMessage> DeleteAsync<T>(T payload, CancellationToken cancel = default)
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Delete, ResourcePath)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user