New change request abstractions.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
@@ -8,25 +7,9 @@ using Wino.Core.Domain.Interfaces;
|
||||
|
||||
namespace Wino.Core.Requests.Bundles
|
||||
{
|
||||
/// <summary>
|
||||
/// Bundle that encapsulates batch request and native request without a response.
|
||||
/// </summary>
|
||||
/// <typeparam name="TRequest">Http type for each integrator. eg. ClientServiceRequest for Gmail and RequestInformation for Microsoft Graph.</typeparam>
|
||||
/// <param name="NativeRequest">Native type to send via http.</param>
|
||||
/// <param name="BatchRequest">Batch request that is generated by base synchronizer.</param>
|
||||
public record HttpRequestBundle<TRequest>(TRequest NativeRequest, IRequestBase Request) : IRequestBundle<TRequest>
|
||||
public record HttpRequestBundle<TRequest>(TRequest NativeRequest, IUIChangeRequest UIChangeRequest, IRequestBase Request = null) : IRequestBundle<TRequest>
|
||||
{
|
||||
public string BundleId { get; set; } = string.Empty;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (Request is IRequest singleRequest)
|
||||
return $"Single {singleRequest.Operation}. No response.";
|
||||
else if (Request is IBatchChangeRequest batchChangeRequest)
|
||||
return $"Batch {batchChangeRequest.Operation} for {batchChangeRequest.Items.Count()} items. No response.";
|
||||
else
|
||||
return "Unknown http request bundle.";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -43,15 +26,5 @@ namespace Wino.Core.Requests.Bundles
|
||||
|
||||
return JsonSerializer.Deserialize<TResponse>(content) ?? throw new InvalidOperationException("Invalid Http Response Deserialization");
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (Request is IRequest singleRequest)
|
||||
return $"Single {singleRequest.Operation}. Expecting '{typeof(TResponse).FullName}' type.";
|
||||
else if (Request is IBatchChangeRequest batchChangeRequest)
|
||||
return $"Batch {batchChangeRequest.Operation} for {batchChangeRequest.Items.Count()} items. Expecting '{typeof(TResponse).FullName}' type.";
|
||||
else
|
||||
return "Unknown http request bundle.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user