Files
Denso/srcs/RobotNet10/Commons/RobotNet10.Script/IO/IHttpConnection.cs
2026-07-03 16:31:37 +07:00

65 lines
2.5 KiB
C#

namespace RobotNet10.Script.IO;
/// <summary>
/// Interface for HTTP connection operations.
/// </summary>
public interface IHttpConnection : IDisposable
{
/// <summary>
/// Gets the base URL of the HTTP connection.
/// </summary>
string BaseUrl { get; }
/// <summary>
/// Gets whether the connection is currently connected.
/// </summary>
bool IsConnected { get; }
/// <summary>
/// Connects to the HTTP endpoint.
/// </summary>
Task ConnectAsync();
/// <summary>
/// Disconnects from the HTTP endpoint.
/// </summary>
Task DisconnectAsync();
/// <summary>
/// Sends a GET request to the specified path.
/// </summary>
/// <param name="path">The path relative to BaseUrl.</param>
/// <param name="headers">Optional headers to include in the request.</param>
/// <returns>The response content as string.</returns>
Task<string> GetAsync(string path, Dictionary<string, string>? headers = null);
/// <summary>
/// Sends a POST request to the specified path.
/// </summary>
/// <param name="path">The path relative to BaseUrl.</param>
/// <param name="content">The content to send.</param>
/// <param name="contentType">The content type (default: application/json).</param>
/// <param name="headers">Optional headers to include in the request.</param>
/// <returns>The response content as string.</returns>
Task<string> PostAsync(string path, string content, string contentType = "application/json", Dictionary<string, string>? headers = null);
/// <summary>
/// Sends a PUT request to the specified path.
/// </summary>
/// <param name="path">The path relative to BaseUrl.</param>
/// <param name="content">The content to send.</param>
/// <param name="contentType">The content type (default: application/json).</param>
/// <param name="headers">Optional headers to include in the request.</param>
/// <returns>The response content as string.</returns>
Task<string> PutAsync(string path, string content, string contentType = "application/json", Dictionary<string, string>? headers = null);
/// <summary>
/// Sends a DELETE request to the specified path.
/// </summary>
/// <param name="path">The path relative to BaseUrl.</param>
/// <param name="headers">Optional headers to include in the request.</param>
/// <returns>The response content as string.</returns>
Task<string> DeleteAsync(string path, Dictionary<string, string>? headers = null);
}