diff --git a/PocketBaseSharp/PocketBase.cs b/PocketBaseSharp/PocketBase.cs index ec748bf..0ad4a33 100644 --- a/PocketBaseSharp/PocketBase.cs +++ b/PocketBaseSharp/PocketBase.cs @@ -12,6 +12,10 @@ namespace PocketBaseSharp { + /// + /// Main client class for interacting with PocketBase backend services. + /// Provides access to all PocketBase APIs including authentication, collections, real-time subscriptions, and more. + /// public class PocketBase { #region Private Fields @@ -20,31 +24,93 @@ public class PocketBase #endregion #region Events + /// + /// Event handler delegate for intercepting HTTP requests before they are sent. + /// + /// The PocketBase instance + /// Request event arguments containing the request details + /// The potentially modified HTTP request message public delegate HttpRequestMessage BeforeSendEventHandler(object sender, RequestEventArgs e); + + /// + /// Event fired before each HTTP request is sent, allowing for request modification. + /// public event BeforeSendEventHandler? BeforeSend; + /// + /// Event handler delegate for processing HTTP responses after they are received. + /// + /// The PocketBase instance + /// Response event arguments containing the response details public delegate void AfterSendEventHandler(object sender, ResponseEventArgs e); + + /// + /// Event fired after each HTTP response is received, allowing for response processing. + /// public event AfterSendEventHandler? AfterSend; #endregion - + /// + /// Gets the authentication store for managing user authentication state. + /// public AuthStore AuthStore { private set; get; } + + /// + /// Gets the admin service for managing administrative operations. + /// public AdminService Admin { private set; get; } + + /// + /// Gets the user service for managing user operations. + /// public UserService User { private set; get; } + + /// + /// Gets the log service for accessing request logs and statistics. + /// public LogService Log { private set; get; } + + /// + /// Gets the settings service for managing application settings. + /// public SettingsService Settings { private set; get; } + + /// + /// Gets the collection service for managing database collections. + /// public CollectionService Collections { private set; get; } - //public RecordService Records { private set; get; } + + /// + /// Gets the real-time service for managing WebSocket connections and subscriptions. + /// public RealTimeService RealTime { private set; get; } + + /// + /// Gets the health service for checking server health status. + /// public HealthService Health { private set; get; } + + /// + /// Gets the backup service for managing database backups. + /// public BackupService Backup { private set; get; } + /// + /// Gets the batch service for performing multiple operations in a single request. + /// public BatchService Batch { private set; get; } private readonly string _baseUrl; private readonly string _language; private readonly HttpClient _httpClient; + /// + /// Initializes a new instance of the PocketBase client. + /// + /// The base URL of the PocketBase server (e.g., "http://localhost:8090") + /// Optional authentication store for managing auth state. If null, a new AuthStore will be created + /// The preferred language for API responses (default: "en-US") + /// Optional HttpClient instance. If null, a new HttpClient will be created public PocketBase(string baseUrl, AuthStore? authStore = null, string language = "en-US", HttpClient? httpClient = null) { this._baseUrl = baseUrl; @@ -64,12 +130,24 @@ public PocketBase(string baseUrl, AuthStore? authStore = null, string language = Batch = new BatchService(this); } + /// + /// Creates an authentication service for a specific collection that stores auth records. + /// + /// The type of the auth model, must implement IBaseAuthModel + /// The name of the collection containing auth records + /// A CollectionAuthService instance for the specified collection public CollectionAuthService AuthCollection(string collectionName) where T : IBaseAuthModel { return new CollectionAuthService(this, collectionName); } + /// + /// Gets or creates a record service for the specified collection. + /// Services are cached and reused for the same collection name. + /// + /// The name of the collection + /// A RecordService instance for the specified collection public RecordService Collection(string collectionName) { if (recordServices.ContainsKey(collectionName)) @@ -90,7 +168,18 @@ public BatchBuilder CreateBatch() return Batch.CreateBatch(); } - + + /// + /// Sends an asynchronous HTTP request to the PocketBase API. + /// + /// The API endpoint path (without base URL) + /// The HTTP method to use for the request + /// Optional HTTP headers to include with the request + /// Optional query parameters to append to the URL + /// Optional request body data + /// Optional files to upload with the request + /// Cancellation token to cancel the operation + /// A Result indicating success or failure of the operation public async Task SendAsync(string path, HttpMethod method, IDictionary? headers = null, IDictionary? query = null, IDictionary? body = null, IEnumerable? files = null, CancellationToken cancellationToken = default) { headers ??= new Dictionary(); @@ -140,6 +229,17 @@ public async Task SendAsync(string path, HttpMethod method, IDictionary< } } + /// + /// Sends a synchronous HTTP request to the PocketBase API. + /// + /// The API endpoint path (without base URL) + /// The HTTP method to use for the request + /// Optional HTTP headers to include with the request + /// Optional query parameters to append to the URL + /// Optional request body data + /// Optional files to upload with the request + /// Cancellation token to cancel the operation + /// A Result indicating success or failure of the operation public Result Send(string path, HttpMethod method, IDictionary? headers = null, IDictionary? query = null, IDictionary? body = null, IEnumerable? files = null, CancellationToken cancellationToken = default) { //RETURN RESULT @@ -187,6 +287,18 @@ public Result Send(string path, HttpMethod method, IDictionary? } } + /// + /// Sends an asynchronous HTTP request to the PocketBase API and deserializes the response to the specified type. + /// + /// The type to deserialize the response to + /// The API endpoint path (without base URL) + /// The HTTP method to use for the request + /// Optional HTTP headers to include with the request + /// Optional query parameters to append to the URL + /// Optional request body data + /// Optional files to upload with the request + /// Cancellation token to cancel the operation + /// A Result containing the deserialized response of type T or an error public async Task> SendAsync(string path, HttpMethod method, IDictionary? headers = null, IDictionary? query = null, IDictionary? body = null, IEnumerable? files = null, CancellationToken cancellationToken = default) { headers ??= new Dictionary(); @@ -238,6 +350,18 @@ public async Task> SendAsync(string path, HttpMethod method, IDicti } } + /// + /// Sends a synchronous HTTP request to the PocketBase API and deserializes the response to the specified type. + /// + /// The type to deserialize the response to + /// The API endpoint path (without base URL) + /// The HTTP method to use for the request + /// Optional HTTP headers to include with the request + /// Optional query parameters to append to the URL + /// Optional request body data + /// Optional files to upload with the request + /// Cancellation token to cancel the operation + /// A Result containing the deserialized response of type T or an error public Result Send(string path, HttpMethod method, IDictionary? headers = null, IDictionary? query = null, IDictionary? body = null, IEnumerable? files = null, CancellationToken cancellationToken = default) { headers ??= new Dictionary(); @@ -334,6 +458,12 @@ private HttpRequestMessage CreateRequest(Uri url, HttpMethod method, IDictionary return request; } + /// + /// Builds a complete URL for the specified API path with optional query parameters. + /// + /// The API endpoint path to append to the base URL + /// Optional query parameters to append to the URL + /// A complete URI for the API request public Uri BuildUrl(string path, IDictionary? queryParameters = null) { var url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/"); diff --git a/PocketBaseSharp/Services/AdminService.cs b/PocketBaseSharp/Services/AdminService.cs index 209eafa..8a28fb4 100644 --- a/PocketBaseSharp/Services/AdminService.cs +++ b/PocketBaseSharp/Services/AdminService.cs @@ -3,11 +3,19 @@ namespace PocketBaseSharp.Services { + /// + /// Service for managing administrative operations and authentication. + /// Provides functionality for admin user management in PocketBase. + /// public class AdminService : BaseAuthService { protected override string BasePath(string? url = null) => "/api/admins"; + /// + /// Initializes a new instance of the AdminService class. + /// + /// The PocketBase client instance public AdminService(PocketBase client) : base(client) { } diff --git a/PocketBaseSharp/Services/BackupService.cs b/PocketBaseSharp/Services/BackupService.cs index cc145d1..94054b2 100644 --- a/PocketBaseSharp/Services/BackupService.cs +++ b/PocketBaseSharp/Services/BackupService.cs @@ -9,9 +9,18 @@ namespace PocketBaseSharp.Services { + /// + /// Service for managing database backups and backup operations. + /// Provides functionality to retrieve and manage PocketBase backup files. + /// public class BackupService : BaseService { readonly PocketBase _pocketBase; + + /// + /// Initializes a new instance of the BackupService class. + /// + /// The PocketBase client instance public BackupService(PocketBase pocketBase) { this._pocketBase = pocketBase; @@ -22,6 +31,10 @@ protected override string BasePath(string? path = null) return path ?? string.Empty; } + /// + /// Retrieves the complete list of available backups from the server. + /// + /// A Result containing an enumerable of BackupModel objects representing all available backups public async Task>> GetFullListAsync() { var b = await _pocketBase.SendAsync>("/api/backups", HttpMethod.Get); diff --git a/PocketBaseSharp/Services/Base/BaseCrudService.cs b/PocketBaseSharp/Services/Base/BaseCrudService.cs index 9909aff..3e5b376 100644 --- a/PocketBaseSharp/Services/Base/BaseCrudService.cs +++ b/PocketBaseSharp/Services/Base/BaseCrudService.cs @@ -3,15 +3,33 @@ namespace PocketBaseSharp.Services.Base { + /// + /// Abstract base class for services that provide CRUD (Create, Read, Update, Delete) operations. + /// Provides standard implementation for common database operations on typed models. + /// + /// The type of model this service manages public abstract class BaseCrudService : BaseService { private readonly PocketBase _client; + /// + /// Initializes a new instance of the BaseCrudService class. + /// + /// The PocketBase client instance protected BaseCrudService(PocketBase client) { this._client = client; } + /// + /// Synchronously retrieves a paginated list of records. + /// + /// The page number to retrieve (default: 1) + /// The number of records per page (default: 30) + /// Optional filter expression to apply + /// Optional sort expression to apply + /// Cancellation token to cancel the operation + /// A Result containing the paginated collection or an error public virtual Result> List(int page = 1, int perPage = 30, string? filter = null, string? sort = null, CancellationToken cancellationToken = default) { var path = BasePath(); @@ -26,6 +44,15 @@ public virtual Result> List(int page = 1, int perPage = return _client.Send>(path, HttpMethod.Get, query: query, cancellationToken: cancellationToken); } + /// + /// Asynchronously retrieves a paginated list of records. + /// + /// The page number to retrieve (default: 1) + /// The number of records per page (default: 30) + /// Optional filter expression to apply + /// Optional sort expression to apply + /// Cancellation token to cancel the operation + /// A Result containing the paginated collection or an error public virtual Task>> ListAsync(int page = 1, int perPage = 30, string? filter = null, string? sort = null, CancellationToken cancellationToken = default) { var path = BasePath(); diff --git a/PocketBaseSharp/Services/Base/BaseService.cs b/PocketBaseSharp/Services/Base/BaseService.cs index 80810af..154f96b 100644 --- a/PocketBaseSharp/Services/Base/BaseService.cs +++ b/PocketBaseSharp/Services/Base/BaseService.cs @@ -3,17 +3,34 @@ namespace PocketBaseSharp.Services.Base { + /// + /// Abstract base class for all PocketBase service classes. + /// Provides common functionality for URL encoding, body construction, and property management. + /// public abstract class BaseService { private readonly string[] _itemProperties; + /// + /// Initializes a new instance of the BaseService class. + /// protected BaseService() { this._itemProperties = this.GetPropertyNames().ToArray(); } + /// + /// Gets the base API path for this service. Must be implemented by derived classes. + /// + /// Optional additional path segment + /// The base API path for this service protected abstract string BasePath(string? path = null); + /// + /// Constructs a request body dictionary from an object, excluding base model properties. + /// + /// The object to convert to a request body + /// A dictionary containing the object's properties as key-value pairs protected Dictionary ConstructBody(object item) { var body = new Dictionary(); @@ -39,6 +56,11 @@ private IEnumerable GetPropertyNames() select prop.Name; } + /// + /// URL-encodes a parameter value for safe inclusion in URLs. + /// + /// The parameter value to encode + /// The URL-encoded parameter value, or an empty string if the parameter is null protected string UrlEncode(string? param) { return HttpUtility.UrlEncode(param) ?? ""; diff --git a/PocketBaseSharp/Services/CollectionAuthService.cs b/PocketBaseSharp/Services/CollectionAuthService.cs index 5cd38f4..97aa10c 100644 --- a/PocketBaseSharp/Services/CollectionAuthService.cs +++ b/PocketBaseSharp/Services/CollectionAuthService.cs @@ -7,12 +7,28 @@ namespace PocketBaseSharp.Services { + /// + /// Service for managing authentication operations on collections that store auth records. + /// Provides a simplified interface for the most common auth record type. + /// + /// The type of the auth model, must implement IBaseAuthModel public class CollectionAuthService : CollectionAuthService, T> where T : IBaseAuthModel { + /// + /// Initializes a new instance of the CollectionAuthService class. + /// + /// The PocketBase client instance + /// The name of the authentication collection public CollectionAuthService(PocketBase client, string collectionName) : base(client, collectionName) { } } + /// + /// Service for managing authentication operations on collections that store auth records. + /// Provides full authentication functionality including login, registration, and user management. + /// + /// The record type that contains the auth model + /// The type of the auth model, must implement IBaseAuthModel public class CollectionAuthService : BaseAuthService where R : RecordAuthModel where T : IBaseAuthModel @@ -22,6 +38,11 @@ public class CollectionAuthService : BaseAuthService private readonly PocketBase _client; private readonly string _collectionName; + /// + /// Initializes a new instance of the CollectionAuthService class. + /// + /// The PocketBase client instance + /// The name of the authentication collection public CollectionAuthService(PocketBase client, string collectionName) : base(client) { this._client = client; diff --git a/PocketBaseSharp/Services/CollectionService.cs b/PocketBaseSharp/Services/CollectionService.cs index 5fb3b64..3c42c12 100644 --- a/PocketBaseSharp/Services/CollectionService.cs +++ b/PocketBaseSharp/Services/CollectionService.cs @@ -4,17 +4,35 @@ namespace PocketBaseSharp.Services { + /// + /// Service for managing database collections and their schemas. + /// Provides CRUD operations for collection definitions and import/export functionality. + /// public class CollectionService : BaseCrudService { private readonly PocketBase _client; protected override string BasePath(string? url = null) => "/api/collections"; + /// + /// Initializes a new instance of the CollectionService class. + /// + /// The PocketBase client instance public CollectionService(PocketBase client) : base(client) { this._client = client; } + /// + /// Asynchronously imports collections from a collection array, optionally deleting missing collections. + /// + /// The collections to import + /// Whether to delete collections not included in the import + /// Optional additional request body data + /// Optional query parameters + /// Optional HTTP headers + /// Cancellation token to cancel the operation + /// A Result indicating success or failure of the import operation public Task ImportAsync(IEnumerable collections, bool deleteMissing = false, IDictionary? body = null, IDictionary? query = null, IDictionary? headers = null, CancellationToken cancellationToken = default) { body ??= new Dictionary(); @@ -25,6 +43,16 @@ public Task ImportAsync(IEnumerable collections, bool d return _client.SendAsync(url, HttpMethod.Put, headers: headers, query: query, body: body, cancellationToken: cancellationToken); } + /// + /// Synchronously imports collections from a collection array, optionally deleting missing collections. + /// + /// The collections to import + /// Whether to delete collections not included in the import + /// Optional additional request body data + /// Optional query parameters + /// Optional HTTP headers + /// Cancellation token to cancel the operation + /// A Result indicating success or failure of the import operation public Result Import(IEnumerable collections, bool deleteMissing = false, IDictionary? body = null, IDictionary? query = null, IDictionary? headers = null, CancellationToken cancellationToken = default) { body ??= new Dictionary(); @@ -35,24 +63,48 @@ public Result Import(IEnumerable collections, bool deleteMissin return _client.Send(url, HttpMethod.Put, headers: headers, query: query, body: body, cancellationToken: cancellationToken); } + /// + /// Asynchronously retrieves a collection by its name. + /// + /// The name of the collection to retrieve + /// Cancellation token to cancel the operation + /// A Result containing the collection model or an error public Task> GetByNameAsync(string name, CancellationToken cancellationToken = default) { var url = $"{BasePath()}/{UrlEncode(name)}"; return _client.SendAsync(url, HttpMethod.Get, cancellationToken: cancellationToken); } + /// + /// Synchronously retrieves a collection by its name. + /// + /// The name of the collection to retrieve + /// Cancellation token to cancel the operation + /// A Result containing the collection model or an error public Result GetByName(string name, CancellationToken cancellationToken = default) { var url = $"{BasePath()}/{UrlEncode(name)}"; return _client.Send(url, HttpMethod.Get, cancellationToken: cancellationToken); } + /// + /// Asynchronously deletes a collection by its name. + /// + /// The name of the collection to delete + /// Cancellation token to cancel the operation + /// A Result indicating success or failure of the deletion public Task DeleteAsync(string name, CancellationToken cancellationToken = default) { var url = $"{BasePath()}/{UrlEncode(name)}"; return _client.SendAsync(url, HttpMethod.Delete, cancellationToken: cancellationToken); } + /// + /// Synchronously deletes a collection by its name. + /// + /// The name of the collection to delete + /// Cancellation token to cancel the operation + /// A Result indicating success or failure of the deletion public Result Delete(string name, CancellationToken cancellationToken = default) { var url = $"{BasePath()}/{UrlEncode(name)}"; diff --git a/PocketBaseSharp/Services/LogService.cs b/PocketBaseSharp/Services/LogService.cs index 7e24f47..f84c1eb 100644 --- a/PocketBaseSharp/Services/LogService.cs +++ b/PocketBaseSharp/Services/LogService.cs @@ -5,6 +5,10 @@ namespace PocketBaseSharp.Services { + /// + /// Service for accessing request logs and statistics from the PocketBase server. + /// Provides functionality to retrieve individual log entries and aggregate statistics. + /// public class LogService : BaseService { @@ -12,6 +16,10 @@ public class LogService : BaseService private readonly PocketBase _client; + /// + /// Initializes a new instance of the LogService class. + /// + /// The PocketBase client instance public LogService(PocketBase client) { this._client = client; diff --git a/PocketBaseSharp/Services/RealTimeService.cs b/PocketBaseSharp/Services/RealTimeService.cs index eb82820..5fdc18f 100644 --- a/PocketBaseSharp/Services/RealTimeService.cs +++ b/PocketBaseSharp/Services/RealTimeService.cs @@ -4,6 +4,10 @@ namespace PocketBaseSharp.Services { + /// + /// Service for managing real-time connections and subscriptions using Server-Sent Events (SSE). + /// Provides functionality to subscribe to collection changes and receive real-time updates. + /// public class RealTimeService : BaseService { protected override string BasePath(string? path = null) => "/api/realtime"; @@ -15,6 +19,10 @@ public class RealTimeService : BaseService private readonly Dictionary>> _subscriptions = new(); + /// + /// Initializes a new instance of the RealTimeService class. + /// + /// The PocketBase client instance public RealTimeService(PocketBase client) { this._client = client; @@ -28,6 +36,12 @@ private async Task RealTimeCallBackAsync(SseMessage message) await callBack(message); } + /// + /// Subscribes to real-time events for a specific subscription topic. + /// + /// The subscription topic (e.g., collection name) + /// The callback function to execute when messages are received + /// A task representing the asynchronous subscription operation public async Task SubscribeAsync(string subscription, Func callback) { if (!_subscriptions.ContainsKey(subscription)) @@ -44,6 +58,11 @@ public async Task SubscribeAsync(string subscription, Func cal } } + /// + /// Unsubscribes from real-time events for a specific topic or all topics. + /// + /// The topic to unsubscribe from. If null or empty, unsubscribes from all topics + /// A task representing the asynchronous unsubscription operation public Task UnsubscribeAsync(string? topic = null) { if (string.IsNullOrEmpty(topic)) @@ -55,6 +74,11 @@ public Task UnsubscribeAsync(string? topic = null) return SubmitSubscriptionsAsync(); } + /// + /// Unsubscribes from all real-time events for topics that start with the specified prefix. + /// + /// The prefix to match against topic names + /// A task representing the asynchronous unsubscription operation public async Task UnsubscribeByPrefixAsync(string prefix) { var subscriptionsToRemove = _subscriptions.Keys.Where(k => k.StartsWith(prefix)).ToList(); @@ -67,6 +91,13 @@ public async Task UnsubscribeByPrefixAsync(string prefix) } } + /// + /// Unsubscribes a specific listener from a specific topic. + /// If no listeners remain for the topic, the topic subscription is completely removed. + /// + /// The topic to unsubscribe from + /// The specific listener callback to remove + /// A task representing the asynchronous unsubscription operation public async Task UnsubscribeByTopicAndListenerAsync(string topic, Func listener) { if (!_subscriptions.ContainsKey(topic)) diff --git a/PocketBaseSharp/Services/RecordService.cs b/PocketBaseSharp/Services/RecordService.cs index 1e07c17..2c2a1ae 100644 --- a/PocketBaseSharp/Services/RecordService.cs +++ b/PocketBaseSharp/Services/RecordService.cs @@ -4,6 +4,10 @@ namespace PocketBaseSharp.Services { + /// + /// Service for managing records within a specific collection. + /// Provides CRUD operations and file management for collection records. + /// public class RecordService : BaseSubCrudService { @@ -16,6 +20,11 @@ protected override string BasePath(string? path = null) private readonly PocketBase _client; readonly string _collectionName; + /// + /// Initializes a new instance of the RecordService class for a specific collection. + /// + /// The PocketBase client instance + /// The name of the collection this service manages public RecordService(PocketBase client, string collectionName) : base(client, collectionName) { this._collectionName = collectionName; @@ -28,6 +37,14 @@ private Uri GetFileUrl(string recordId, string fileName, IDictionary + /// Asynchronously downloads a file associated with a specific record. + /// + /// The ID of the record containing the file + /// The name of the file to download + /// Optional thumbnail format specification + /// Cancellation token to cancel the operation + /// A Result containing the file stream or an error public Task> DownloadFileAsync(string recordId, string fileName, ThumbFormat? thumbFormat = null, CancellationToken cancellationToken = default) { var url = $"api/files/{UrlEncode(_collectionName)}/{UrlEncode(recordId)}/{fileName}"; diff --git a/PocketBaseSharp/Services/SettingsService.cs b/PocketBaseSharp/Services/SettingsService.cs index 64f3e8b..f51bcb6 100644 --- a/PocketBaseSharp/Services/SettingsService.cs +++ b/PocketBaseSharp/Services/SettingsService.cs @@ -3,6 +3,10 @@ namespace PocketBaseSharp.Services { + /// + /// Service for managing application settings and configuration. + /// Provides functionality to retrieve and update PocketBase application settings. + /// public class SettingsService : BaseService { @@ -10,43 +14,103 @@ public class SettingsService : BaseService private readonly PocketBase _client; + /// + /// Initializes a new instance of the SettingsService class. + /// + /// The PocketBase client instance public SettingsService(PocketBase client) { this._client = client; } + /// + /// Asynchronously retrieves all application settings. + /// + /// Optional query parameters + /// Optional HTTP headers + /// Cancellation token to cancel the operation + /// A Result containing a dictionary of all settings public Task>> GetAllAsync(IDictionary? query = null, IDictionary? headers = null, CancellationToken cancellationToken = default) { return _client.SendAsync>(BasePath(), HttpMethod.Get, headers: headers, query: query, cancellationToken: cancellationToken); } + /// + /// Synchronously retrieves all application settings. + /// + /// Optional query parameters + /// Optional HTTP headers + /// Cancellation token to cancel the operation + /// A Result containing a dictionary of all settings public Result> GetAll(IDictionary? query = null, IDictionary? headers = null, CancellationToken cancellationToken = default) { return _client.Send>(BasePath(), HttpMethod.Get, headers: headers, query: query, cancellationToken: cancellationToken); } + /// + /// Asynchronously updates application settings with the provided values. + /// + /// The settings to update + /// Optional query parameters + /// Optional HTTP headers + /// Cancellation token to cancel the operation + /// A Result containing the updated settings public Task>> UpdateAsync(IDictionary? body = null, IDictionary? query = null, IDictionary? headers = null, CancellationToken cancellationToken = default) { return _client.SendAsync>(BasePath(), HttpMethod.Patch, headers: headers, query: query, body: body, cancellationToken: cancellationToken); } + /// + /// Synchronously updates application settings with the provided values. + /// + /// The settings to update + /// Optional query parameters + /// Optional HTTP headers + /// Cancellation token to cancel the operation + /// A Result containing the updated settings public Result> Update(IDictionary? body = null, IDictionary? query = null, IDictionary? headers = null, CancellationToken cancellationToken = default) { return _client.Send>(BasePath(), HttpMethod.Patch, headers: headers, query: query, body: body, cancellationToken: cancellationToken); } + /// + /// Asynchronously tests the S3 configuration settings. + /// + /// Optional test data + /// Optional query parameters + /// Optional HTTP headers + /// Cancellation token to cancel the operation + /// A Result indicating whether the S3 test was successful public Task TestS3Async(IDictionary? body = null, IDictionary? query = null, IDictionary? headers = null, CancellationToken cancellationToken = default) { var url = $"{BasePath()}/test/s3"; return _client.SendAsync(url, HttpMethod.Post, headers: headers, body: body, query: query, cancellationToken: cancellationToken); } + /// + /// Synchronously tests the S3 configuration settings. + /// + /// Optional test data + /// Optional query parameters + /// Optional HTTP headers + /// Cancellation token to cancel the operation + /// A Result indicating whether the S3 test was successful public Result TestS3(IDictionary? body = null, IDictionary? query = null, IDictionary? headers = null, CancellationToken cancellationToken = default) { var url = $"{BasePath()}/test/s3"; return _client.Send(url, HttpMethod.Post, headers: headers, body: body, query: query, cancellationToken: cancellationToken); } + /// + /// Asynchronously tests the email configuration by sending a test email. + /// + /// The email address to send the test email to + /// The email template to use for the test + /// Optional test data + /// Optional query parameters + /// Optional HTTP headers + /// Cancellation token to cancel the operation + /// A Result indicating whether the email test was successful public Task TestEmailAsync(string toEmail, string template, IDictionary? body = null, IDictionary? query = null, IDictionary? headers = null, CancellationToken cancellationToken = default) { query ??= new Dictionary(); @@ -57,6 +121,16 @@ public Task TestEmailAsync(string toEmail, string template, IDictionary< return _client.SendAsync(url, HttpMethod.Post, headers: headers, body: body, query: query, cancellationToken: cancellationToken); } + /// + /// Synchronously tests the email configuration by sending a test email. + /// + /// The email address to send the test email to + /// The email template to use for the test + /// Optional test data + /// Optional query parameters + /// Optional HTTP headers + /// Cancellation token to cancel the operation + /// A Result indicating whether the email test was successful public Result TestEmail(string toEmail, string template, IDictionary? body = null, IDictionary? query = null, IDictionary? headers = null, CancellationToken cancellationToken = default) { query ??= new Dictionary(); diff --git a/PocketBaseSharp/Services/UserService.cs b/PocketBaseSharp/Services/UserService.cs index 1c60806..5b8ce6b 100644 --- a/PocketBaseSharp/Services/UserService.cs +++ b/PocketBaseSharp/Services/UserService.cs @@ -7,6 +7,10 @@ namespace PocketBaseSharp.Services { + /// + /// Service for managing user accounts and authentication in the users collection. + /// Provides CRUD operations and authentication functionality for user records. + /// public class UserService : BaseCrudService { protected override string BasePath(string? url = null) => "/api/collections/users/records"; @@ -14,6 +18,10 @@ public class UserService : BaseCrudService private readonly PocketBase _client; private readonly CollectionAuthService _authService; + /// + /// Initializes a new instance of the UserService class. + /// + /// The PocketBase client instance public UserService(PocketBase client) : base(client) { this._client = client;