Moving folder structure

This commit is contained in:
2025-07-10 10:12:50 +02:00
parent 450aa5f1c9
commit 29f6c4ae81
172 changed files with 109 additions and 162 deletions

View File

@@ -0,0 +1,36 @@
using System.Net.Http;
namespace AMWD.Net.Api.Cloudflare
{
/// <summary>
/// Implements the interface to authenticate using an API key and email address.
/// </summary>
public class ApiKeyAuthentication : IAuthentication
{
private readonly string _emailAddress;
private readonly string _apiKey;
/// <summary>
/// Initializes a new instance of the <see cref="ApiKeyAuthentication"/> class.
/// </summary>
/// <param name="emailAddress">The email address.</param>
/// <param name="apiKey">The global API key.</param>
public ApiKeyAuthentication(string emailAddress, string apiKey)
{
emailAddress.ValidateCloudflareEmailAddress();
if (string.IsNullOrWhiteSpace(apiKey))
throw new ArgumentNullException(nameof(apiKey));
_emailAddress = emailAddress;
_apiKey = apiKey;
}
/// <inheritdoc />
public void AddHeader(HttpClient httpClient)
{
httpClient.DefaultRequestHeaders.Add("X-Auth-Email", _emailAddress);
httpClient.DefaultRequestHeaders.Add("X-Auth-Key", _apiKey);
}
}
}

View File

@@ -0,0 +1,31 @@
using System.Net.Http;
using System.Net.Http.Headers;
namespace AMWD.Net.Api.Cloudflare
{
/// <summary>
/// Implements the interface to authenticate using an API token.
/// </summary>
public class ApiTokenAuthentication : IAuthentication
{
private readonly string _apiToken;
/// <summary>
/// Initializes a new instance of the <see cref="ApiTokenAuthentication"/> class.
/// </summary>
/// <param name="apiToken">The API token.</param>
public ApiTokenAuthentication(string apiToken)
{
if (string.IsNullOrWhiteSpace(apiToken))
throw new ArgumentNullException(nameof(apiToken));
_apiToken = apiToken;
}
/// <inheritdoc />
public void AddHeader(HttpClient httpClient)
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _apiToken);
}
}
}