Remove Extensions class and update namespace references from Helpers to Helper for consistency

This commit is contained in:
Andre Beging
2025-12-11 19:06:41 +01:00
parent 46229a6dc7
commit 05b92e8f54
9 changed files with 11 additions and 52 deletions

View File

@@ -1,5 +1,5 @@
using System.Text;
using FsToolbox.Cli.Helpers;
using FsToolbox.Cli.Helper;
using FsToolbox.Cli.Tasks;
namespace FsToolbox.Cli

View File

@@ -1,4 +1,4 @@
using FsToolbox.Cli.Helpers;
using FsToolbox.Cli.Helper;
namespace FsToolbox.Cli
{

View File

@@ -2,7 +2,7 @@ using System.Text.Json;
using System.Text.Json.Nodes;
using FsToolbox.Cli.Tasks;
namespace FsToolbox.Cli.Helpers
namespace FsToolbox.Cli.Helper
{
/// <summary>
/// Provides helper methods to manage authentication and cached CSRF tokens.

View File

@@ -1,41 +0,0 @@
using System.Text;
using System.Text.Json.Nodes;
namespace FsToolbox.Cli.Helpers
{
public static class Extensions
{
#region Public Method FsPostAsync
/// <summary>
/// Sends a POST request to the specified URI with the provided JSON content.
/// </summary>
/// <param name="httpClient">The instance of <see cref="HttpClient" /> used to send the request.</param>
/// <param name="requestUri">The URI to which the request is sent.</param>
/// <param name="jsonObject">The JSON object to include in the request body.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the HTTP response.</returns>
public static async Task<HttpResponseMessage> FsPostAsync(this HttpClient httpClient, string requestUri, JsonObject jsonObject)
{
var content = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json");
content.Headers.ContentType = new("application/json");
return await httpClient.PostAsync(requestUri, content);
}
#endregion
#region Public Method ToList
/// <summary>
/// Converts the specified JSON node into a list of non-null <see cref="JsonNode" /> elements.
/// </summary>
/// <param name="node">The <see cref="JsonNode" /> to be converted. If null, an empty list is returned.</param>
/// <returns>A list of <see cref="JsonNode" /> instances containing non-null elements.</returns>
public static List<JsonNode> ToList(this JsonNode? node)
{
var array = node?.AsArray() ?? [];
return array.Where(x => x != null).Select(x => x!).ToList();
}
#endregion
}
}

View File

@@ -1,6 +1,6 @@
using Microsoft.Extensions.Configuration;
namespace FsToolbox.Cli.Helpers
namespace FsToolbox.Cli.Helper
{
/// <summary>
/// Represents the root configuration settings for the application, including API and credentials.

View File

@@ -1,6 +1,6 @@
namespace FsToolbox.Cli.Tasks
{
public partial class RegionTasks
public static partial class RegionTasks
{
#region Record Store

View File

@@ -1,10 +1,10 @@
using System.Text.Json;
using System.Text.Json.Nodes;
using FsToolbox.Cli.Helpers;
using FsToolbox.Cli.Helper;
namespace FsToolbox.Cli.Tasks
{
public partial class RegionTasks
public static partial class RegionTasks
{
#region Public Method GetStoresInRegionAsync

View File

@@ -1,7 +1,7 @@
using System.Net.Http.Json;
using System.Text.Json;
using System.Text.Json.Nodes;
using FsToolbox.Cli.Helpers;
using FsToolbox.Cli.Helper;
namespace FsToolbox.Cli.Tasks
{

View File

@@ -1,7 +1,7 @@
using System;
using System.Linq;
using System.Net.Http.Json;
using FsToolbox.Cli.Helpers;
using FsToolbox.Cli.Helper;
namespace FsToolbox.Cli.Tasks
{
@@ -76,7 +76,7 @@ namespace FsToolbox.Cli.Tasks
var expiryEntry = cookies.FirstOrDefault(c => c.Trim().StartsWith("expires="));
var expireString = expiryEntry?.Split('=')[1];
if (DateTime.TryParse(expireString, out var expiration))
await FsToolbox.Cli.Helpers.AuthHelper.StoreCsrfTokenAsync(csrfToken, expiration);
await AuthHelper.StoreCsrfTokenAsync(csrfToken, expiration);
}
return csrfToken;
@@ -89,7 +89,7 @@ namespace FsToolbox.Cli.Tasks
/// <returns>A task that represents the asynchronous operation.</returns>
public static async Task GetCurrentUserAsync(HttpClient httpClient)
{
await FsToolbox.Cli.Helpers.AuthHelper.EnsureAuthenticationAsync(httpClient);
await AuthHelper.EnsureAuthenticationAsync(httpClient);
var response = await httpClient.GetAsync(Endpoints.UserCurrent);