using System.Collections.Generic; using System.Threading.Tasks; using System.Threading; namespace DataConnection.REST.Interfaces { /// /// Interface for a generic REST service client. /// public interface IRestServiceClient { /// /// Authenticates the client using the provided credentials. /// Implementation varies by service type. /// /// Cancellation token. /// True if authentication was successful, false otherwise. Task AuthenticateAsync(CancellationToken cancellationToken = default); /// /// Sends a GET request to the specified URI. /// /// The type of the object to deserialize the response content to. /// The URI the request is sent to. /// Cancellation token. /// The deserialized response content. Task GetAsync(string requestUri, CancellationToken cancellationToken = default); /// /// Sends a POST request to the specified URI. /// /// The type of the request object. /// The type of the object to deserialize the response content to. /// The URI the request is sent to. /// The HTTP request content sent to the server. /// Cancellation token. /// The deserialized response content. Task PostAsync(string requestUri, TRequest payload, CancellationToken cancellationToken = default); /// /// Creates a new entity by sending a POST request with the provided data. /// /// The name of the entity to create. /// The data for the new entity as key-value pairs. /// Cancellation token. /// The created entity data or null if creation failed. Task?> CreateEntityAsync(string entityName, Dictionary entityData, CancellationToken cancellationToken = default); /// /// Creates a new entity or updates an existing one (upsert operation). /// /// The name of the entity to upsert. /// The data for the entity as key-value pairs. /// Cancellation token. /// The upserted entity data or null if operation failed. Task?> UpsertEntityAsync(string entityName, Dictionary entityData, CancellationToken cancellationToken = default); /// /// Searches for entities matching the specified key fields. /// /// The name of the entity to search. /// The key fields and their values to search for. /// Cancellation token. /// A list of matching entities. Task>> FindEntitiesByKeysAsync(string entityName, Dictionary keyFields, CancellationToken cancellationToken = default); /// /// Deletes an entity by its ID or unique identifier. /// /// The name of the entity to delete. /// The ID or unique identifier of the entity to delete. /// Cancellation token. /// True if deletion was successful, false otherwise. Task DeleteEntityAsync(string entityName, string entityId, CancellationToken cancellationToken = default); /// /// Updates an existing entity by its ID with the provided data. /// /// The name of the entity to update. /// The ID or unique identifier of the entity to update. /// The data to update as key-value pairs. /// Cancellation token. /// The updated entity data or null if update failed. Task?> UpdateEntityAsync(string entityName, string entityId, Dictionary entityData, CancellationToken cancellationToken = default); /// /// Searches for entities matching the specified required fields to detect duplicates. /// /// The name of the entity to search. /// The required fields and their values to search for. /// Cancellation token. /// A list of matching entities. Task>> FindEntitiesByRequiredFieldsAsync(string entityName, Dictionary requiredFields, CancellationToken cancellationToken = default); // Add other methods as needed (PUT, DELETE, PATCH, etc.) // Consider adding methods for handling raw HttpResponseMessage or string responses } }