Added timing information to CloudflareResponse

This commit is contained in:
2024-11-08 17:11:32 +01:00
parent 935632df27
commit 42455e596b
9 changed files with 77 additions and 58 deletions

View File

@@ -248,7 +248,6 @@ namespace AMWD.Net.Api.Cloudflare
return new CloudflareResponse<TRes>
{
Success = true,
ResultInfo = new PaginationInfo(),
Result = (TRes)cObj,
};
}

View File

@@ -5,20 +5,9 @@ namespace AMWD.Net.Api.Cloudflare
/// <summary>
/// The base Cloudflare response.
/// </summary>
public class CloudflareResponse
/// <typeparam name="T">The result type.</typeparam>
public class CloudflareResponse<T>
{
/// <summary>
/// Information about the result of the request.
/// </summary>
[JsonProperty("result_info")]
public PaginationInfo? ResultInfo { get; set; }
/// <summary>
/// Whether the API call was successful.
/// </summary>
[JsonProperty("success")]
public bool Success { get; set; }
/// <summary>
/// Errors returned by the API call.
/// </summary>
@@ -30,18 +19,29 @@ namespace AMWD.Net.Api.Cloudflare
/// </summary>
[JsonProperty("messages")]
public IReadOnlyList<ResponseInfo> Messages { get; set; } = [];
}
/// <summary>
/// The base Cloudflare response with a result.
/// </summary>
/// <typeparam name="T">The result type.</typeparam>
public class CloudflareResponse<T> : CloudflareResponse
{
/// <summary>
/// Whether the API call was successful.
/// </summary>
[JsonProperty("success")]
public bool Success { get; set; }
/// <summary>
/// The result of the API call.
/// </summary>
[JsonProperty("result")]
public T? Result { get; set; }
/// <summary>
/// Information about the result of the request.
/// </summary>
[JsonProperty("result_info")]
public PaginationInfo? ResultInfo { get; set; }
/// <summary>
/// Information about the processing time of a request.
/// </summary>
[JsonProperty("timing")]
public RecordProcessTiming? Timing { get; set; }
}
}

View File

@@ -28,5 +28,11 @@
/// </summary>
[JsonProperty("total_count")]
public int TotalCount { get; set; }
/// <summary>
/// Total number of pages of results.
/// </summary>
[JsonProperty("total_pages")]
public int TotalPages { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using System;
namespace AMWD.Net.Api.Cloudflare
{
/// <summary>
/// Information about the processing time of a file.
/// </summary>
public class RecordProcessTiming
{
/// <summary>
/// When the file parsing ended.
/// </summary>
[JsonProperty("end_time")]
public DateTime? EndTime { get; set; }
/// <summary>
/// Processing time of the file in seconds.
/// </summary>
[JsonProperty("process_time")]
public int? ProcessTime { get; set; }
/// <summary>
/// When the file parsing started.
/// </summary>
[JsonProperty("start_time")]
public DateTime? StartTime { get; set; }
}
}