Skip to content

Commit

Permalink
Add XML documentation for API interfaces
Browse files Browse the repository at this point in the history
This commit introduces comprehensive XML comments to improve codebase clarity and maintainability. Detailed descriptions were added for all methods and properties across `ISubDBClient`, `IResponse`, `IRequest`, and `ISubDBApi` interfaces, outlining their purpose, parameters, and return values. These changes enhance API usability and developer understanding.
  • Loading branch information
ivandrofly committed Jan 3, 2025
1 parent cbe183c commit 840fc45
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Http/IRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,33 @@

namespace SubDBSharp.Models
{
/// <summary>
/// Represents an HTTP request with a specified endpoint, method, and optional body content.
/// </summary>
public interface IRequest
{
/// <summary>
/// Gets or sets the HTTP content to be sent as the body of an HTTP request.
/// </summary>
/// <remarks>
/// Typically used to include serialized data or other payloads in HTTP requests such as POST or PUT.
/// </remarks>
HttpContent Body { get; }

/// <summary>
/// Gets or sets the URI that represents the target endpoint of the HTTP request.
/// </summary>
/// <remarks>
/// Used to specify the destination URL for the HTTP operation being executed.
/// </remarks>
Uri EndPoint { get; }

/// <summary>
/// Gets or sets the HTTP method to be used for the request.
/// </summary>
/// <remarks>
/// Specifies the action to be performed by the request, such as GET, POST, PUT, or DELETE.
/// </remarks>
HttpMethod Method { get; }
}
}
28 changes: 28 additions & 0 deletions src/Http/IResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,38 @@

namespace SubDBSharp.Http
{
/// <summary>
/// Represents a response received from an HTTP request.
/// </summary>
public interface IResponse
{
/// <summary>
/// Gets the content of the response body.
/// </summary>
/// <remarks>
/// The body contains the data returned by the HTTP request, which may be in various formats such as plain text,
/// JSON object, or binary data, depending on the nature of the response.
/// This property is represented as an object and may require casting to the expected type.
/// </remarks>
object Body { get; }

/// <summary>
/// Gets the collection of HTTP headers included in the response as key-value pairs.
/// </summary>
/// <remarks>
/// The headers provide metadata about the response, such as content type, server, and other relevant information.
/// This property is represented as a read-only dictionary where the keys are the header names
/// and the values are the corresponding header values.
/// </remarks>
IReadOnlyDictionary<string, string> Headers { get; }

/// <summary>
/// Gets the HTTP status code associated with the response.
/// </summary>
/// <remarks>
/// The status code indicates the outcome of the HTTP request, such as success, client error, or server error.
/// It conforms to the standardized status codes as defined in the <see cref="System.Net.HttpStatusCode"/> enumeration.
/// </remarks>
HttpStatusCode StatusCode { get; }
}
}
28 changes: 28 additions & 0 deletions src/Http/ISubDBApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,39 @@

namespace SubDBSharp
{
/// <summary>
/// Interface for interacting with the SubDB API to perform operations related to subtitle management.
/// </summary>
public interface ISubDBApi
{
/// <summary>
/// Downloads a subtitle file based on the provided video hash and language preferences.
/// </summary>
/// <param name="hash">A unique hash representing the video file, generated using a specific hash function.</param>
/// <param name="languages">A list of language codes indicating the preferred languages for the subtitle. The first matching language is returned.</param>
/// <returns>A Task representing the asynchronous operation, containing the server's response to the subtitle download request.</returns>
Task<Response> DownloadSubtitle(string hash, params string[] languages);

/// <summary>
/// Retrieves a list of available languages supported by the SubDB API for subtitles.
/// </summary>
/// <returns>A Task representing the asynchronous operation, containing the server's response with the list of available languages.</returns>
Task<Response> GetAvailableLanguagesAsync();

/// <summary>
/// Searches for subtitles based on the hash of a video file, optionally returning the number of subtitle versions available per language.
/// </summary>
/// <param name="hash">The hash of the video file, uniquely identifying it in the subtitle database.</param>
/// <param name="getVersions">Optional parameter to indicate whether to include the number of versions available for each subtitle language.</param>
/// <returns>A Task representing the asynchronous operation, containing the server's response to the subtitle search request.</returns>
Task<Response> SearchSubtitle(string hash, bool getVersions = false);

/// <summary>
/// Uploads a subtitle file for a specific movie to the server.
/// </summary>
/// <param name="subtitle">The content of the subtitle file being uploaded.</param>
/// <param name="movie">The movie identifier or hash that the subtitle is associated with.</param>
/// <returns>A Task representing the asynchronous operation, containing the server's response to the upload request.</returns>
Task<Response> UploadSubtitle(string subtitle, string movie);
}
}
35 changes: 35 additions & 0 deletions src/ISubDBClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,46 @@

namespace SubDBSharp
{
/// <summary>
/// Defines methods for interacting with the SubDB API,
/// including operations for downloading, uploading, searching subtitles,
/// and retrieving available subtitle languages.
/// </summary>
public interface ISubDBClient
{
/// <summary>
/// Downloads the subtitle for a given video file based on its hash and specified language preferences.
/// </summary>
/// <param name="hash">The hash of the video file, used to uniquely identify the video.</param>
/// <param name="languages">An array of language codes specifying the preferred subtitle language(s).
/// If multiple language codes are provided, the first available subtitle will be returned in the specified order.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the server response,
/// including the subtitle content and its associated metadata.</returns>
Task<Response> DownloadSubtitleAsync(string hash, params string[] languages);

/// <summary>
/// Retrieves the list of all available subtitle languages currently supported in the SubDB database.
/// </summary>
/// <returns>A task that represents the asynchronous operation. The task result contains the server response,
/// including the list of available language codes.</returns>
Task<Response> GetAvailableLanguagesAsync();

/// <summary>
/// Searches for subtitles for a given video file based on its hash.
/// Optionally, retrieves additional information about the subtitle versions available.
/// </summary>
/// <param name="hash">The hash of the video file used to uniquely identify the video.</param>
/// <param name="getVersions">A boolean indicating whether to return information about the number of subtitle versions per language available in the database.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the server response, including available subtitles and their metadata if found.</returns>
Task<Response> SearchSubtitleAsync(string hash, bool getVersions);

/// <summary>
/// Uploads a subtitle file for a specific movie to the SubDB server.
/// </summary>
/// <param name="subtitle">The subtitle content to be uploaded.</param>
/// <param name="movie">The movie name or identifier associated with the subtitle.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the server response,
/// including status and any additional metadata related to the upload operation.</returns>
Task<Response> UploadSubtitleAsync(string subtitle, string movie);
}
}

0 comments on commit 840fc45

Please sign in to comment.