(
+ await Message.Content.ReadAsStreamAsync().ConfigureAwait(false),
+ ModelBase.SerializerOptions
+ ) ?? throw new ArcadeInvalidDataException("Response content cannot be null or deserialization failed");
+ }
+ catch (HttpRequestException ex)
+ {
+ throw new ArcadeIOException("I/O error occurred while reading response content", ex);
+ }
+ }
+
+ ///
+ /// Disposes the underlying HTTP response resources.
+ ///
+ public void Dispose()
+ {
+ Message.Dispose();
+ }
+}
diff --git a/src/ArcadeDotnet/Core/HttpRequest.cs b/src/ArcadeDotnet/Core/HttpRequest.cs
deleted file mode 100644
index 9d5422b..0000000
--- a/src/ArcadeDotnet/Core/HttpRequest.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.Net.Http;
-
-namespace ArcadeDotnet.Core;
-
-public sealed class HttpRequest
- where P : ParamsBase
-{
- public required HttpMethod Method { get; init; }
-
- public required P Params { get; init; }
-}
diff --git a/src/ArcadeDotnet/Core/HttpResponse.cs b/src/ArcadeDotnet/Core/HttpResponse.cs
deleted file mode 100644
index e30874b..0000000
--- a/src/ArcadeDotnet/Core/HttpResponse.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using System.Net.Http;
-using System.Text.Json;
-using System.Threading.Tasks;
-using ArcadeDotnet.Exceptions;
-
-namespace ArcadeDotnet.Core;
-
-public sealed class HttpResponse : IDisposable
-{
- public required HttpResponseMessage Message { get; init; }
-
- public async Task Deserialize()
- {
- try
- {
- return JsonSerializer.Deserialize(
- await Message.Content.ReadAsStreamAsync().ConfigureAwait(false),
- ModelBase.SerializerOptions
- ) ?? throw new ArcadeInvalidDataException("Response cannot be null");
- }
- catch (HttpRequestException e)
- {
- throw new ArcadeIOException("I/O Exception", e);
- }
- }
-
- public void Dispose()
- {
- this.Message.Dispose();
- }
-}
diff --git a/src/ArcadeDotnet/Core/IVariant.cs b/src/ArcadeDotnet/Core/IVariant.cs
index 23a224c..738a0f5 100644
--- a/src/ArcadeDotnet/Core/IVariant.cs
+++ b/src/ArcadeDotnet/Core/IVariant.cs
@@ -1,8 +1,27 @@
namespace ArcadeDotnet.Core;
-interface IVariant
+///
+/// Interface for creating variant types that wrap values.
+///
+/// The variant type implementing this interface.
+/// The type of value being wrapped by the variant.
+///
+/// This interface enables the creation of strongly-typed wrappers around values,
+/// useful for implementing the variant pattern in API models.
+///
+internal interface IVariant
where TVariant : IVariant
{
+ ///
+ /// Creates a variant instance from a value.
+ ///
+ /// The value to wrap in the variant.
+ /// A new variant instance containing the specified value.
static abstract TVariant From(TValue value);
+
+ ///
+ /// Gets the wrapped value.
+ ///
+ /// The value contained in this variant.
TValue Value { get; }
}
diff --git a/src/ArcadeDotnet/Exceptions/Arcade4xxException.cs b/src/ArcadeDotnet/Exceptions/Arcade4xxException.cs
index e1770f6..30e067c 100644
--- a/src/ArcadeDotnet/Exceptions/Arcade4xxException.cs
+++ b/src/ArcadeDotnet/Exceptions/Arcade4xxException.cs
@@ -2,8 +2,15 @@
namespace ArcadeDotnet.Exceptions;
+///
+/// Exception thrown when the API returns a 4xx client error status code.
+///
public class Arcade4xxException : ArcadeApiException
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The HTTP request exception that is the cause of the current exception, or null if no inner exception is specified.
public Arcade4xxException(HttpRequestException? innerException = null)
: base(innerException) { }
}
diff --git a/src/ArcadeDotnet/Exceptions/Arcade5xxException.cs b/src/ArcadeDotnet/Exceptions/Arcade5xxException.cs
index 4bba36a..cba6092 100644
--- a/src/ArcadeDotnet/Exceptions/Arcade5xxException.cs
+++ b/src/ArcadeDotnet/Exceptions/Arcade5xxException.cs
@@ -2,8 +2,15 @@
namespace ArcadeDotnet.Exceptions;
-public class Arcade5xxException : ArcadeApiException
+///
+/// Exception thrown when the API returns a 5xx server error status code.
+///
+public sealed class Arcade5xxException : ArcadeApiException
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The HTTP request exception that is the cause of the current exception, or null if no inner exception is specified.
public Arcade5xxException(HttpRequestException? innerException = null)
: base(innerException) { }
}
diff --git a/src/ArcadeDotnet/Exceptions/ArcadeApiException.cs b/src/ArcadeDotnet/Exceptions/ArcadeApiException.cs
index e0cc812..c8890a9 100644
--- a/src/ArcadeDotnet/Exceptions/ArcadeApiException.cs
+++ b/src/ArcadeDotnet/Exceptions/ArcadeApiException.cs
@@ -4,32 +4,63 @@
namespace ArcadeDotnet.Exceptions;
+///
+/// Exception thrown when the API returns an error status code.
+///
+[Serializable]
public class ArcadeApiException : ArcadeException
{
+ ///
+ /// Gets the HTTP request exception that caused this exception.
+ ///
+ ///
+ /// The that is the cause of the current exception.
+ ///
+ /// Thrown when the inner exception is null.
public new HttpRequestException InnerException
{
get
{
if (base.InnerException == null)
{
- throw new ArgumentNullException();
+ throw new InvalidOperationException("InnerException is null");
}
return (HttpRequestException)base.InnerException;
}
}
- public ArcadeApiException(string message, HttpRequestException? innerException = null)
- : base(message, innerException) { }
-
- protected ArcadeApiException(HttpRequestException? innerException)
- : base(innerException) { }
-
+ ///
+ /// Gets the HTTP status code returned by the API.
+ ///
+ ///
+ /// The returned by the API.
+ ///
public required HttpStatusCode StatusCode { get; init; }
+ ///
+ /// Gets the response body returned by the API.
+ ///
+ ///
+ /// The response body as a string, which may contain error details from the API.
+ ///
public required string ResponseBody { get; init; }
- public override string Message
- {
- get { return string.Format("Status Code: {0}\n{1}", StatusCode, ResponseBody); }
- }
+ ///
+ /// Gets a message that describes the current exception.
+ ///
+ ///
+ /// A string containing the HTTP status code and response body.
+ ///
+ public override string Message => $"Status Code: {StatusCode}\n{ResponseBody}";
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The HTTP request exception that is the cause of the current exception, or null if no inner exception is specified.
+ public ArcadeApiException(string message, HttpRequestException? innerException = null)
+ : base(message, innerException) { }
+
+ internal ArcadeApiException(HttpRequestException? innerException)
+ : base(innerException) { }
}
diff --git a/src/ArcadeDotnet/Exceptions/ArcadeBadRequestException.cs b/src/ArcadeDotnet/Exceptions/ArcadeBadRequestException.cs
index 119cbca..b7de3c9 100644
--- a/src/ArcadeDotnet/Exceptions/ArcadeBadRequestException.cs
+++ b/src/ArcadeDotnet/Exceptions/ArcadeBadRequestException.cs
@@ -2,8 +2,15 @@
namespace ArcadeDotnet.Exceptions;
-public class ArcadeBadRequestException : Arcade4xxException
+///
+/// Exception thrown when the API returns a 400 Bad Request status code.
+///
+public sealed class ArcadeBadRequestException : Arcade4xxException
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The HTTP request exception that is the cause of the current exception, or null if no inner exception is specified.
public ArcadeBadRequestException(HttpRequestException? innerException = null)
: base(innerException) { }
}
diff --git a/src/ArcadeDotnet/Exceptions/ArcadeException.cs b/src/ArcadeDotnet/Exceptions/ArcadeException.cs
index f96f585..05e4ab1 100644
--- a/src/ArcadeDotnet/Exceptions/ArcadeException.cs
+++ b/src/ArcadeDotnet/Exceptions/ArcadeException.cs
@@ -3,11 +3,24 @@
namespace ArcadeDotnet.Exceptions;
+///
+/// Base exception for all Arcade API exceptions.
+///
+[Serializable]
public class ArcadeException : Exception
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or null if no inner exception is specified.
public ArcadeException(string message, Exception? innerException = null)
: base(message, innerException) { }
+ ///
+ /// Initializes a new instance of the class with an HTTP request exception.
+ ///
+ /// The HTTP request exception that is the cause of the current exception.
protected ArcadeException(HttpRequestException? innerException)
: base(null, innerException) { }
}
diff --git a/src/ArcadeDotnet/Exceptions/ArcadeExceptionFactory.cs b/src/ArcadeDotnet/Exceptions/ArcadeExceptionFactory.cs
index f7df7f7..8fa4ee6 100644
--- a/src/ArcadeDotnet/Exceptions/ArcadeExceptionFactory.cs
+++ b/src/ArcadeDotnet/Exceptions/ArcadeExceptionFactory.cs
@@ -2,8 +2,17 @@
namespace ArcadeDotnet.Exceptions;
-public class ArcadeExceptionFactory
+///
+/// Factory for creating exception instances based on HTTP status codes.
+///
+public static class ArcadeExceptionFactory
{
+ ///
+ /// Creates an appropriate exception for the given HTTP status code.
+ ///
+ /// The HTTP status code.
+ /// The response body containing error details.
+ /// An or derived type.
public static ArcadeApiException CreateApiException(
HttpStatusCode statusCode,
string responseBody
diff --git a/src/ArcadeDotnet/Exceptions/ArcadeForbiddenException.cs b/src/ArcadeDotnet/Exceptions/ArcadeForbiddenException.cs
index b2689af..1140f43 100644
--- a/src/ArcadeDotnet/Exceptions/ArcadeForbiddenException.cs
+++ b/src/ArcadeDotnet/Exceptions/ArcadeForbiddenException.cs
@@ -2,8 +2,15 @@
namespace ArcadeDotnet.Exceptions;
-public class ArcadeForbiddenException : Arcade4xxException
+///
+/// Exception thrown when the API returns a 403 Forbidden status code.
+///
+public sealed class ArcadeForbiddenException : Arcade4xxException
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The HTTP request exception that is the cause of the current exception, or null if no inner exception is specified.
public ArcadeForbiddenException(HttpRequestException? innerException = null)
: base(innerException) { }
}
diff --git a/src/ArcadeDotnet/Exceptions/ArcadeIOException.cs b/src/ArcadeDotnet/Exceptions/ArcadeIOException.cs
index 84f1c26..73aaf86 100644
--- a/src/ArcadeDotnet/Exceptions/ArcadeIOException.cs
+++ b/src/ArcadeDotnet/Exceptions/ArcadeIOException.cs
@@ -3,20 +3,36 @@
namespace ArcadeDotnet.Exceptions;
-public class ArcadeIOException : ArcadeException
+///
+/// Exception thrown when an I/O error occurs during an API request.
+///
+[Serializable]
+public sealed class ArcadeIOException : ArcadeException
{
+ ///
+ /// Gets the HTTP request exception that caused this exception.
+ ///
+ ///
+ /// The that is the cause of the current exception.
+ ///
+ /// Thrown when the inner exception is null.
public new HttpRequestException InnerException
{
get
{
if (base.InnerException == null)
{
- throw new ArgumentNullException();
+ throw new InvalidOperationException("InnerException is null");
}
return (HttpRequestException)base.InnerException;
}
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The HTTP request exception that is the cause of the current exception, or null if no inner exception is specified.
public ArcadeIOException(string message, HttpRequestException? innerException = null)
: base(message, innerException) { }
}
diff --git a/src/ArcadeDotnet/Exceptions/ArcadeInvalidDataException.cs b/src/ArcadeDotnet/Exceptions/ArcadeInvalidDataException.cs
index 9cb9724..cc94b56 100644
--- a/src/ArcadeDotnet/Exceptions/ArcadeInvalidDataException.cs
+++ b/src/ArcadeDotnet/Exceptions/ArcadeInvalidDataException.cs
@@ -2,8 +2,17 @@
namespace ArcadeDotnet.Exceptions;
-public class ArcadeInvalidDataException : ArcadeException
+///
+/// Exception thrown when invalid data is encountered.
+///
+[Serializable]
+public sealed class ArcadeInvalidDataException : ArcadeException
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or null if no inner exception is specified.
public ArcadeInvalidDataException(string message, Exception? innerException = null)
: base(message, innerException) { }
}
diff --git a/src/ArcadeDotnet/Exceptions/ArcadeNotFoundException.cs b/src/ArcadeDotnet/Exceptions/ArcadeNotFoundException.cs
index 059c618..aa8e613 100644
--- a/src/ArcadeDotnet/Exceptions/ArcadeNotFoundException.cs
+++ b/src/ArcadeDotnet/Exceptions/ArcadeNotFoundException.cs
@@ -2,8 +2,15 @@
namespace ArcadeDotnet.Exceptions;
-public class ArcadeNotFoundException : Arcade4xxException
+///
+/// Exception thrown when the API returns a 404 Not Found status code.
+///
+public sealed class ArcadeNotFoundException : Arcade4xxException
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The HTTP request exception that is the cause of the current exception, or null if no inner exception is specified.
public ArcadeNotFoundException(HttpRequestException? innerException = null)
: base(innerException) { }
}
diff --git a/src/ArcadeDotnet/Exceptions/ArcadeRateLimitException.cs b/src/ArcadeDotnet/Exceptions/ArcadeRateLimitException.cs
index 6eb7c34..9b84d5e 100644
--- a/src/ArcadeDotnet/Exceptions/ArcadeRateLimitException.cs
+++ b/src/ArcadeDotnet/Exceptions/ArcadeRateLimitException.cs
@@ -2,8 +2,15 @@
namespace ArcadeDotnet.Exceptions;
-public class ArcadeRateLimitException : Arcade4xxException
+///
+/// Exception thrown when the API returns a 429 Too Many Requests status code.
+///
+public sealed class ArcadeRateLimitException : Arcade4xxException
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The HTTP request exception that is the cause of the current exception, or null if no inner exception is specified.
public ArcadeRateLimitException(HttpRequestException? innerException = null)
: base(innerException) { }
}
diff --git a/src/ArcadeDotnet/Exceptions/ArcadeUnauthorizedException.cs b/src/ArcadeDotnet/Exceptions/ArcadeUnauthorizedException.cs
index e386192..bfde690 100644
--- a/src/ArcadeDotnet/Exceptions/ArcadeUnauthorizedException.cs
+++ b/src/ArcadeDotnet/Exceptions/ArcadeUnauthorizedException.cs
@@ -2,8 +2,15 @@
namespace ArcadeDotnet.Exceptions;
-public class ArcadeUnauthorizedException : Arcade4xxException
+///
+/// Exception thrown when the API returns a 401 Unauthorized status code.
+///
+public sealed class ArcadeUnauthorizedException : Arcade4xxException
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The HTTP request exception that is the cause of the current exception, or null if no inner exception is specified.
public ArcadeUnauthorizedException(HttpRequestException? innerException = null)
: base(innerException) { }
}
diff --git a/src/ArcadeDotnet/Exceptions/ArcadeUnexpectedStatusCodeException.cs b/src/ArcadeDotnet/Exceptions/ArcadeUnexpectedStatusCodeException.cs
index fc0b6c7..69f408f 100644
--- a/src/ArcadeDotnet/Exceptions/ArcadeUnexpectedStatusCodeException.cs
+++ b/src/ArcadeDotnet/Exceptions/ArcadeUnexpectedStatusCodeException.cs
@@ -2,8 +2,15 @@
namespace ArcadeDotnet.Exceptions;
-public class ArcadeUnexpectedStatusCodeException : ArcadeApiException
+///
+/// Exception thrown when the API returns an unexpected HTTP status code.
+///
+public sealed class ArcadeUnexpectedStatusCodeException : ArcadeApiException
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The HTTP request exception that is the cause of the current exception, or null if no inner exception is specified.
public ArcadeUnexpectedStatusCodeException(HttpRequestException? innerException = null)
: base(innerException) { }
}
diff --git a/src/ArcadeDotnet/Exceptions/ArcadeUnprocessableEntityException.cs b/src/ArcadeDotnet/Exceptions/ArcadeUnprocessableEntityException.cs
index 1b2e954..ea26122 100644
--- a/src/ArcadeDotnet/Exceptions/ArcadeUnprocessableEntityException.cs
+++ b/src/ArcadeDotnet/Exceptions/ArcadeUnprocessableEntityException.cs
@@ -2,8 +2,15 @@
namespace ArcadeDotnet.Exceptions;
-public class ArcadeUnprocessableEntityException : Arcade4xxException
+///
+/// Exception thrown when the API returns a 422 Unprocessable Entity status code.
+///
+public sealed class ArcadeUnprocessableEntityException : Arcade4xxException
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The HTTP request exception that is the cause of the current exception, or null if no inner exception is specified.
public ArcadeUnprocessableEntityException(HttpRequestException? innerException = null)
: base(innerException) { }
}
diff --git a/src/ArcadeDotnet/Extensions/ServiceCollectionExtensions.cs b/src/ArcadeDotnet/Extensions/ServiceCollectionExtensions.cs
new file mode 100644
index 0000000..ed42486
--- /dev/null
+++ b/src/ArcadeDotnet/Extensions/ServiceCollectionExtensions.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Net.Http;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace ArcadeDotnet.Extensions;
+
+///
+/// Extension methods for configuring ArcadeClient in dependency injection containers.
+///
+public static class ServiceCollectionExtensions
+{
+ ///
+ /// Adds ArcadeClient services to the dependency injection container.
+ ///
+ public static IServiceCollection AddArcadeClient(
+ this IServiceCollection services,
+ string apiKey,
+ Uri? baseUrl = null)
+ {
+ ArgumentNullException.ThrowIfNull(services);
+ ArgumentNullException.ThrowIfNull(apiKey);
+
+ services.AddHttpClient("ArcadeClient", client =>
+ {
+ client.BaseAddress = baseUrl ?? new Uri(ArcadeClientOptions.DefaultBaseUrl);
+ client.DefaultRequestHeaders.UserAgent.ParseAdd("arcade-dotnet/0.2.0");
+ });
+
+ services.AddSingleton(sp =>
+ {
+ var httpClientFactory = sp.GetRequiredService();
+ return new ArcadeClient(new ArcadeClientOptions
+ {
+ ApiKey = apiKey,
+ BaseUrl = baseUrl,
+ HttpClientFactory = httpClientFactory
+ });
+ });
+
+ return services;
+ }
+
+ ///
+ /// Adds ArcadeClient services using environment variables.
+ ///
+ public static IServiceCollection AddArcadeClient(this IServiceCollection services)
+ {
+ ArgumentNullException.ThrowIfNull(services);
+
+ var baseUrl = ArcadeClientOptions.TryParseBaseUrl(
+ Environment.GetEnvironmentVariable(ArcadeClientOptions.BaseUrlEnvironmentVariable));
+
+ services.AddHttpClient("ArcadeClient", client =>
+ {
+ client.BaseAddress = baseUrl ?? new Uri(ArcadeClientOptions.DefaultBaseUrl);
+ client.DefaultRequestHeaders.UserAgent.ParseAdd("arcade-dotnet/0.2.0");
+ });
+
+ services.AddSingleton(sp =>
+ {
+ var httpClientFactory = sp.GetRequiredService();
+ return new ArcadeClient(new ArcadeClientOptions
+ {
+ ApiKey = Environment.GetEnvironmentVariable(ArcadeClientOptions.ApiKeyEnvironmentVariable),
+ BaseUrl = baseUrl,
+ HttpClientFactory = httpClientFactory
+ });
+ });
+
+ return services;
+ }
+}
diff --git a/src/ArcadeDotnet/IArcadeClient.cs b/src/ArcadeDotnet/IArcadeClient.cs
index 3fed6be..4f34f53 100644
--- a/src/ArcadeDotnet/IArcadeClient.cs
+++ b/src/ArcadeDotnet/IArcadeClient.cs
@@ -11,16 +11,20 @@
namespace ArcadeDotnet;
+///
+/// Interface for the Arcade API client.
+///
public interface IArcadeClient
{
- HttpClient HttpClient { get; init; }
-
- Uri BaseUrl { get; init; }
+ ///
+ /// Gets the base URL for the API.
+ ///
+ Uri BaseUrl { get; }
///
- /// API key used for authorization in header
+ /// Gets the API key used for authorization.
///
- string APIKey { get; init; }
+ string APIKey { get; }
IAdminService Admin { get; }
@@ -34,6 +38,14 @@ public interface IArcadeClient
IWorkerService Workers { get; }
- Task Execute(HttpRequest request)
- where T : ParamsBase;
+ ///
+ /// Executes an API request and returns the response.
+ ///
+ /// The type of parameters.
+ /// The request to execute.
+ /// The API response.
+ /// Thrown when an I/O error occurs.
+ /// Thrown when the API returns an error.
+ Task Execute(ArcadeRequest request)
+ where TParams : ParamsBase;
}
diff --git a/src/ArcadeDotnet/Models/Admin/AuthProviders/AuthProviderCreateParamsProperties/Oauth2Properties/AuthorizeRequestProperties/RequestContentType.cs b/src/ArcadeDotnet/Models/Admin/AuthProviders/AuthProviderCreateParamsProperties/Oauth2Properties/AuthorizeRequestProperties/RequestContentType.cs
index b1618e6..2c1943c 100644
--- a/src/ArcadeDotnet/Models/Admin/AuthProviders/AuthProviderCreateParamsProperties/Oauth2Properties/AuthorizeRequestProperties/RequestContentType.cs
+++ b/src/ArcadeDotnet/Models/Admin/AuthProviders/AuthProviderCreateParamsProperties/Oauth2Properties/AuthorizeRequestProperties/RequestContentType.cs
@@ -12,7 +12,7 @@ public enum RequestContentType
ApplicationJson,
}
-sealed class RequestContentTypeConverter : JsonConverter
+internal sealed class RequestContentTypeConverter : JsonConverter
{
public override RequestContentType Read(
ref Utf8JsonReader reader,
@@ -42,7 +42,7 @@ JsonSerializerOptions options
"application/x-www-form-urlencoded",
RequestContentType.ApplicationJson => "application/json",
_ => throw new ArcadeInvalidDataException(
- string.Format("Invalid value '{0}' in {1}", value, nameof(value))
+ $"Invalid value '{value}' in {nameof(value)}"
),
},
options
diff --git a/src/ArcadeDotnet/Models/Admin/AuthProviders/AuthProviderCreateParamsProperties/Oauth2Properties/AuthorizeRequestProperties/ResponseContentType.cs b/src/ArcadeDotnet/Models/Admin/AuthProviders/AuthProviderCreateParamsProperties/Oauth2Properties/AuthorizeRequestProperties/ResponseContentType.cs
index 4a97579..35d784f 100644
--- a/src/ArcadeDotnet/Models/Admin/AuthProviders/AuthProviderCreateParamsProperties/Oauth2Properties/AuthorizeRequestProperties/ResponseContentType.cs
+++ b/src/ArcadeDotnet/Models/Admin/AuthProviders/AuthProviderCreateParamsProperties/Oauth2Properties/AuthorizeRequestProperties/ResponseContentType.cs
@@ -12,7 +12,7 @@ public enum ResponseContentType
ApplicationJson,
}
-sealed class ResponseContentTypeConverter : JsonConverter
+internal sealed class ResponseContentTypeConverter : JsonConverter
{
public override ResponseContentType Read(
ref Utf8JsonReader reader,
@@ -43,7 +43,7 @@ JsonSerializerOptions options
"application/x-www-form-urlencoded",
ResponseContentType.ApplicationJson => "application/json",
_ => throw new ArcadeInvalidDataException(
- string.Format("Invalid value '{0}' in {1}", value, nameof(value))
+ $"Invalid value '{value}' in {nameof(value)}"
),
},
options
diff --git a/src/ArcadeDotnet/Properties/AssemblyInfo.cs b/src/ArcadeDotnet/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..53cf08a
--- /dev/null
+++ b/src/ArcadeDotnet/Properties/AssemblyInfo.cs
@@ -0,0 +1,5 @@
+using System.Runtime.CompilerServices;
+
+// Allow test project to access internal types and members
+[assembly: InternalsVisibleTo("ArcadeDotnet.Tests")]
+
diff --git a/src/ArcadeDotnet/Services/Admin/AdminService.cs b/src/ArcadeDotnet/Services/Admin/AdminService.cs
index ebcab64..001964a 100644
--- a/src/ArcadeDotnet/Services/Admin/AdminService.cs
+++ b/src/ArcadeDotnet/Services/Admin/AdminService.cs
@@ -7,28 +7,31 @@ namespace ArcadeDotnet.Services.Admin;
public sealed class AdminService : IAdminService
{
- public AdminService(IArcadeClient client)
- {
- _userConnections = new(() => new UserConnectionService(client));
- _authProviders = new(() => new AuthProviderService(client));
- _secrets = new(() => new SecretService(client));
- }
+ ///
+ /// Gets the user connections service.
+ ///
+ public IUserConnectionService UserConnections { get; }
- readonly Lazy _userConnections;
- public IUserConnectionService UserConnections
- {
- get { return _userConnections.Value; }
- }
+ ///
+ /// Gets the auth providers service.
+ ///
+ public IAuthProviderService AuthProviders { get; }
- readonly Lazy _authProviders;
- public IAuthProviderService AuthProviders
- {
- get { return _authProviders.Value; }
- }
+ ///
+ /// Gets the secrets service.
+ ///
+ public ISecretService Secrets { get; }
- readonly Lazy _secrets;
- public ISecretService Secrets
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Arcade client instance.
+ /// Thrown when is null.
+ public AdminService(IArcadeClient client)
{
- get { return _secrets.Value; }
+ ArgumentNullException.ThrowIfNull(client);
+ UserConnections = new UserConnectionService(client);
+ AuthProviders = new AuthProviderService(client);
+ Secrets = new SecretService(client);
}
}
diff --git a/src/ArcadeDotnet/Services/Admin/AuthProviders/AuthProviderService.cs b/src/ArcadeDotnet/Services/Admin/AuthProviders/AuthProviderService.cs
index a288fcd..1edf130 100644
--- a/src/ArcadeDotnet/Services/Admin/AuthProviders/AuthProviderService.cs
+++ b/src/ArcadeDotnet/Services/Admin/AuthProviders/AuthProviderService.cs
@@ -1,3 +1,4 @@
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using ArcadeDotnet.Core;
@@ -7,67 +8,52 @@ namespace ArcadeDotnet.Services.Admin.AuthProviders;
public sealed class AuthProviderService : IAuthProviderService
{
- readonly IArcadeClient _client;
+ private readonly IArcadeClient _client;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Arcade client instance.
+ /// Thrown when is null.
public AuthProviderService(IArcadeClient client)
{
+ ArgumentNullException.ThrowIfNull(client);
_client = client;
}
public async Task Create(AuthProviderCreateParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Post,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Post, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task List(AuthProviderListParams? parameters = null)
{
parameters ??= new();
-
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Delete(AuthProviderDeleteParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Delete,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Delete, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Get(AuthProviderGetParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Patch(AuthProviderPatchParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Patch,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Patch, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
}
diff --git a/src/ArcadeDotnet/Services/Admin/Secrets/SecretService.cs b/src/ArcadeDotnet/Services/Admin/Secrets/SecretService.cs
index 0a37baf..4b98674 100644
--- a/src/ArcadeDotnet/Services/Admin/Secrets/SecretService.cs
+++ b/src/ArcadeDotnet/Services/Admin/Secrets/SecretService.cs
@@ -1,3 +1,4 @@
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using ArcadeDotnet.Core;
@@ -7,34 +8,30 @@ namespace ArcadeDotnet.Services.Admin.Secrets;
public sealed class SecretService : ISecretService
{
- readonly IArcadeClient _client;
+ private readonly IArcadeClient _client;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Arcade client instance.
+ /// Thrown when is null.
public SecretService(IArcadeClient client)
{
+ ArgumentNullException.ThrowIfNull(client);
_client = client;
}
public async Task List(SecretListParams? parameters = null)
{
parameters ??= new();
-
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Delete(SecretDeleteParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Delete,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
- return;
+ var request = new ArcadeRequest(HttpMethod.Delete, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
}
}
diff --git a/src/ArcadeDotnet/Services/Admin/UserConnections/UserConnectionService.cs b/src/ArcadeDotnet/Services/Admin/UserConnections/UserConnectionService.cs
index d3e4e22..67becc1 100644
--- a/src/ArcadeDotnet/Services/Admin/UserConnections/UserConnectionService.cs
+++ b/src/ArcadeDotnet/Services/Admin/UserConnections/UserConnectionService.cs
@@ -1,3 +1,4 @@
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using ArcadeDotnet.Core;
@@ -7,10 +8,16 @@ namespace ArcadeDotnet.Services.Admin.UserConnections;
public sealed class UserConnectionService : IUserConnectionService
{
- readonly IArcadeClient _client;
+ private readonly IArcadeClient _client;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Arcade client instance.
+ /// Thrown when is null.
public UserConnectionService(IArcadeClient client)
{
+ ArgumentNullException.ThrowIfNull(client);
_client = client;
}
@@ -19,24 +26,14 @@ public async Task List(
)
{
parameters ??= new();
-
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Delete(UserConnectionDeleteParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Delete,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
- return;
+ var request = new ArcadeRequest(HttpMethod.Delete, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
}
}
diff --git a/src/ArcadeDotnet/Services/Auth/AuthService.cs b/src/ArcadeDotnet/Services/Auth/AuthService.cs
index 34a8d1d..9d745b3 100644
--- a/src/ArcadeDotnet/Services/Auth/AuthService.cs
+++ b/src/ArcadeDotnet/Services/Auth/AuthService.cs
@@ -1,3 +1,4 @@
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using ArcadeDotnet.Core;
@@ -6,45 +7,57 @@
namespace ArcadeDotnet.Services.Auth;
+///
+/// Service for handling authentication and authorization operations.
+///
public sealed class AuthService : IAuthService
{
- readonly IArcadeClient _client;
+ private readonly IArcadeClient _client;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Arcade client instance.
+ /// Thrown when is null.
public AuthService(IArcadeClient client)
{
+ ArgumentNullException.ThrowIfNull(client);
_client = client;
}
+ ///
+ /// Starts the authorization process.
+ ///
+ /// The authorization parameters.
+ /// The authorization response.
public async Task Authorize(AuthAuthorizeParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Post,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Post, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
+ ///
+ /// Confirms a user's details during authorization.
+ ///
+ /// The confirmation parameters.
+ /// The confirmation response.
public async Task ConfirmUser(AuthConfirmUserParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Post,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Post, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
+ ///
+ /// Checks the authorization status.
+ ///
+ /// The status parameters.
+ /// The authorization status.
public async Task Status(AuthStatusParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
}
diff --git a/src/ArcadeDotnet/Services/Chat/ChatService.cs b/src/ArcadeDotnet/Services/Chat/ChatService.cs
index 89b0186..04ea954 100644
--- a/src/ArcadeDotnet/Services/Chat/ChatService.cs
+++ b/src/ArcadeDotnet/Services/Chat/ChatService.cs
@@ -5,14 +5,19 @@ namespace ArcadeDotnet.Services.Chat;
public sealed class ChatService : IChatService
{
- public ChatService(IArcadeClient client)
- {
- _completions = new(() => new CompletionService(client));
- }
+ ///
+ /// Gets the completions service.
+ ///
+ public ICompletionService Completions { get; }
- readonly Lazy _completions;
- public ICompletionService Completions
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Arcade client instance.
+ /// Thrown when is null.
+ public ChatService(IArcadeClient client)
{
- get { return _completions.Value; }
+ ArgumentNullException.ThrowIfNull(client);
+ Completions = new CompletionService(client);
}
}
diff --git a/src/ArcadeDotnet/Services/Chat/Completions/CompletionService.cs b/src/ArcadeDotnet/Services/Chat/Completions/CompletionService.cs
index fef80dd..a280ac0 100644
--- a/src/ArcadeDotnet/Services/Chat/Completions/CompletionService.cs
+++ b/src/ArcadeDotnet/Services/Chat/Completions/CompletionService.cs
@@ -1,3 +1,4 @@
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using ArcadeDotnet.Core;
@@ -8,23 +9,24 @@ namespace ArcadeDotnet.Services.Chat.Completions;
public sealed class CompletionService : ICompletionService
{
- readonly IArcadeClient _client;
+ private readonly IArcadeClient _client;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Arcade client instance.
+ /// Thrown when is null.
public CompletionService(IArcadeClient client)
{
+ ArgumentNullException.ThrowIfNull(client);
_client = client;
}
public async Task Create(CompletionCreateParams? parameters = null)
{
parameters ??= new();
-
- HttpRequest request = new()
- {
- Method = HttpMethod.Post,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Post, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
}
diff --git a/src/ArcadeDotnet/Services/Health/HealthService.cs b/src/ArcadeDotnet/Services/Health/HealthService.cs
index 99d4ef3..f1db64d 100644
--- a/src/ArcadeDotnet/Services/Health/HealthService.cs
+++ b/src/ArcadeDotnet/Services/Health/HealthService.cs
@@ -1,3 +1,4 @@
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using ArcadeDotnet.Core;
@@ -7,23 +8,24 @@ namespace ArcadeDotnet.Services.Health;
public sealed class HealthService : IHealthService
{
- readonly IArcadeClient _client;
+ private readonly IArcadeClient _client;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Arcade client instance.
+ /// Thrown when is null.
public HealthService(IArcadeClient client)
{
+ ArgumentNullException.ThrowIfNull(client);
_client = client;
}
public async Task Check(HealthCheckParams? parameters = null)
{
parameters ??= new();
-
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
}
diff --git a/src/ArcadeDotnet/Services/Tools/Formatted/FormattedService.cs b/src/ArcadeDotnet/Services/Tools/Formatted/FormattedService.cs
index 5f80e74..41ad831 100644
--- a/src/ArcadeDotnet/Services/Tools/Formatted/FormattedService.cs
+++ b/src/ArcadeDotnet/Services/Tools/Formatted/FormattedService.cs
@@ -1,3 +1,4 @@
+using System;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
@@ -8,34 +9,31 @@ namespace ArcadeDotnet.Services.Tools.Formatted;
public sealed class FormattedService : IFormattedService
{
- readonly IArcadeClient _client;
+ private readonly IArcadeClient _client;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Arcade client instance.
+ /// Thrown when is null.
public FormattedService(IArcadeClient client)
{
+ ArgumentNullException.ThrowIfNull(client);
_client = client;
}
public async Task List(FormattedListParams? parameters = null)
{
parameters ??= new();
-
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Get(FormattedGetParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
}
diff --git a/src/ArcadeDotnet/Services/Tools/Scheduled/ScheduledService.cs b/src/ArcadeDotnet/Services/Tools/Scheduled/ScheduledService.cs
index 3f333a0..8e517ba 100644
--- a/src/ArcadeDotnet/Services/Tools/Scheduled/ScheduledService.cs
+++ b/src/ArcadeDotnet/Services/Tools/Scheduled/ScheduledService.cs
@@ -1,3 +1,4 @@
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using ArcadeDotnet.Core;
@@ -7,34 +8,31 @@ namespace ArcadeDotnet.Services.Tools.Scheduled;
public sealed class ScheduledService : IScheduledService
{
- readonly IArcadeClient _client;
+ private readonly IArcadeClient _client;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Arcade client instance.
+ /// Thrown when is null.
public ScheduledService(IArcadeClient client)
{
+ ArgumentNullException.ThrowIfNull(client);
_client = client;
}
public async Task List(ScheduledListParams? parameters = null)
{
parameters ??= new();
-
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Get(ScheduledGetParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
}
diff --git a/src/ArcadeDotnet/Services/Tools/ToolService.cs b/src/ArcadeDotnet/Services/Tools/ToolService.cs
index e72c699..2b5c027 100644
--- a/src/ArcadeDotnet/Services/Tools/ToolService.cs
+++ b/src/ArcadeDotnet/Services/Tools/ToolService.cs
@@ -11,66 +11,57 @@ namespace ArcadeDotnet.Services.Tools;
public sealed class ToolService : IToolService
{
- readonly IArcadeClient _client;
+ private readonly IArcadeClient _client;
- public ToolService(IArcadeClient client)
- {
- _client = client;
- _scheduled = new(() => new ScheduledService(client));
- _formatted = new(() => new FormattedService(client));
- }
+ ///
+ /// Gets the scheduled tools service.
+ ///
+ public IScheduledService Scheduled { get; }
- readonly Lazy _scheduled;
- public IScheduledService Scheduled
- {
- get { return _scheduled.Value; }
- }
+ ///
+ /// Gets the formatted tools service.
+ ///
+ public IFormattedService Formatted { get; }
- readonly Lazy _formatted;
- public IFormattedService Formatted
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Arcade client instance.
+ /// Thrown when is null.
+ public ToolService(IArcadeClient client)
{
- get { return _formatted.Value; }
+ ArgumentNullException.ThrowIfNull(client);
+ _client = client;
+ Scheduled = new ScheduledService(client);
+ Formatted = new FormattedService(client);
}
public async Task List(ToolListParams? parameters = null)
{
parameters ??= new();
-
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Authorize(ToolAuthorizeParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Post,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Post, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Execute(ToolExecuteParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Post,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Post, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Get(ToolGetParams parameters)
{
- HttpRequest request = new() { Method = HttpMethod.Get, Params = parameters };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
}
diff --git a/src/ArcadeDotnet/Services/Workers/WorkerService.cs b/src/ArcadeDotnet/Services/Workers/WorkerService.cs
index 6a90c28..bd98c31 100644
--- a/src/ArcadeDotnet/Services/Workers/WorkerService.cs
+++ b/src/ArcadeDotnet/Services/Workers/WorkerService.cs
@@ -1,3 +1,4 @@
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using ArcadeDotnet.Core;
@@ -7,89 +8,65 @@ namespace ArcadeDotnet.Services.Workers;
public sealed class WorkerService : IWorkerService
{
- readonly IArcadeClient _client;
+ private readonly IArcadeClient _client;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Arcade client instance.
+ /// Thrown when is null.
public WorkerService(IArcadeClient client)
{
+ ArgumentNullException.ThrowIfNull(client);
_client = client;
}
public async Task Create(WorkerCreateParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Post,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Post, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Update(WorkerUpdateParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Patch,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Patch, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task List(WorkerListParams? parameters = null)
{
parameters ??= new();
-
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Delete(WorkerDeleteParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Delete,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
- return;
+ var request = new ArcadeRequest(HttpMethod.Delete, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
}
public async Task Get(WorkerGetParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Health(WorkerHealthParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
public async Task Tools(WorkerToolsParams parameters)
{
- HttpRequest request = new()
- {
- Method = HttpMethod.Get,
- Params = parameters,
- };
- using var response = await this._client.Execute(request).ConfigureAwait(false);
+ var request = new ArcadeRequest(HttpMethod.Get, parameters);
+ using var response = await _client.Execute(request).ConfigureAwait(false);
return await response.Deserialize().ConfigureAwait(false);
}
}