Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
754 changes: 754 additions & 0 deletions src/libs/DeepL/Generated/DeepL.CorrectTextClient.CorrectText.g.cs

Large diffs are not rendered by default.

286 changes: 286 additions & 0 deletions src/libs/DeepL/Generated/DeepL.CorrectTextClient.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@

#nullable enable

namespace DeepL
{
/// <summary>
/// The `correct` endpoint fixes spelling and grammar errors without broader rephrasing. Use it when you want<br/>
/// a minimal-change correction pass rather than the broader rewriting performed by `rephrase`.<br/>
/// If no httpClient is provided, a new one will be created.<br/>
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
/// </summary>
public sealed partial class CorrectTextClient : global::DeepL.ICorrectTextClient, global::System.IDisposable
{
/// <summary>
/// DeepL API Pro
/// </summary>
public const string DefaultBaseUrl = "https://api.deepl.com/";

private bool _disposeHttpClient = true;

/// <inheritdoc/>
public global::System.Net.Http.HttpClient HttpClient { get; }

/// <inheritdoc/>
public System.Uri? BaseUri => ResolveDisplayedBaseUri();

/// <inheritdoc/>
public global::System.Collections.Generic.List<global::DeepL.EndPointAuthorization> Authorizations { get; }

/// <inheritdoc/>
public bool ReadResponseAsString { get; set; }
#if DEBUG
= true;
#endif

/// <inheritdoc/>
public global::DeepL.AutoSDKClientOptions Options { get; }


internal global::DeepL.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::DeepL.AutoSDKServerConfiguration();
/// <summary>
///
/// </summary>
public global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } = global::DeepL.SourceGenerationContext.Default;



private static readonly global::DeepL.AutoSDKServer[] s_availableServers = new global::DeepL.AutoSDKServer[]
{ new global::DeepL.AutoSDKServer(
id: "https-api-deepl-com",
name: "DeepL API Pro",
url: "https://api.deepl.com/",
description: "DeepL API Pro"),
new global::DeepL.AutoSDKServer(
id: "https-api-free-deepl-com",
name: "DeepL API Free",
url: "https://api-free.deepl.com/",
description: "DeepL API Free"),
};

/// <summary>
/// The server options available for this client.
/// </summary>
public global::System.Collections.Generic.IReadOnlyList<global::DeepL.AutoSDKServer> AvailableServers => s_availableServers;

/// <summary>
/// The currently selected server for this client, if any.
/// </summary>
public global::DeepL.AutoSDKServer? SelectedServer
{
get => ResolveSelectedServer();
set => SelectServer(value);
}

/// <summary>
/// Creates a new instance of the CorrectTextClient.
/// If no httpClient is provided, a new one will be created.
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
/// </summary>
/// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
/// <param name="baseUri">The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used.</param>
/// <param name="authorizations">The authorizations to use for the requests.</param>
/// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
public CorrectTextClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List<global::DeepL.EndPointAuthorization>? authorizations = null,
bool disposeHttpClient = true) : this(
httpClient,
baseUri,
authorizations,
options: null,
disposeHttpClient: disposeHttpClient)
{
}

/// <summary>
/// Creates a new instance of the CorrectTextClient with explicit options but no base URL override.
/// Skips passing <c>baseUri</c> so the default base URL from the OpenAPI spec applies.
/// </summary>
/// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
/// <param name="authorizations">The authorizations to use for the requests.</param>
/// <param name="options">Client-wide request defaults such as headers, query parameters, retries, and timeout.</param>
/// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
public CorrectTextClient(
global::System.Net.Http.HttpClient? httpClient,
global::System.Collections.Generic.List<global::DeepL.EndPointAuthorization>? authorizations,
global::DeepL.AutoSDKClientOptions? options,
bool disposeHttpClient = true) : this(
httpClient,
baseUri: null,
authorizations,
options,
disposeHttpClient: disposeHttpClient)
{
}

/// <summary>
/// Creates a new instance of the CorrectTextClient.
/// If no httpClient is provided, a new one will be created.
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
/// </summary>
/// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
/// <param name="baseUri">The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used.</param>
/// <param name="authorizations">The authorizations to use for the requests.</param>
/// <param name="options">Client-wide request defaults such as headers, query parameters, retries, and timeout.</param>
/// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
public CorrectTextClient(
global::System.Net.Http.HttpClient? httpClient,
global::System.Uri? baseUri,
global::System.Collections.Generic.List<global::DeepL.EndPointAuthorization>? authorizations,
global::DeepL.AutoSDKClientOptions? options,
bool disposeHttpClient = true)
{

HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
if (baseUri is not null)
{
HttpClient.BaseAddress ??= baseUri;
}
Authorizations = authorizations ?? new global::System.Collections.Generic.List<global::DeepL.EndPointAuthorization>();
Options = options ?? new global::DeepL.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;

AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress;

Initialized(HttpClient);
}

/// <inheritdoc/>
public void Dispose()
{
if (_disposeHttpClient)
{
HttpClient.Dispose();
}
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
global::System.Net.Http.HttpClient client,
global::System.Net.Http.HttpRequestMessage request);
partial void ProcessResponse(
global::System.Net.Http.HttpClient client,
global::System.Net.Http.HttpResponseMessage response);
partial void ProcessResponseContent(
global::System.Net.Http.HttpClient client,
global::System.Net.Http.HttpResponseMessage response,
ref string content);


/// <summary>
/// Selects one of the generated server options by id.
/// </summary>
public bool TrySelectServer(string serverId)
{
if (string.IsNullOrWhiteSpace(serverId))
{
return false;
}

foreach (var server in s_availableServers)
{
if (string.Equals(server.Id, serverId, global::System.StringComparison.OrdinalIgnoreCase))
{
AutoSDKServerConfiguration.SelectedServer = server;
AutoSDKServerConfiguration.ExplicitBaseUri = null;
return true;
}
}

return false;
}

/// <summary>
/// Clears the currently selected server.
/// </summary>
public void ClearSelectedServer()
{
AutoSDKServerConfiguration.SelectedServer = null;
}

private global::DeepL.AutoSDKServer? ResolveSelectedServer()
{
var selectedServer = AutoSDKServerConfiguration.SelectedServer;
if (selectedServer is null)
{
return null;
}

foreach (var server in s_availableServers)
{
if (string.Equals(server.Id, selectedServer.Id, global::System.StringComparison.Ordinal))
{
return server;
}
}

return null;
}

private void SelectServer(global::DeepL.AutoSDKServer? server)
{
if (server is null)
{
AutoSDKServerConfiguration.SelectedServer = null;
return;
}

foreach (var candidate in s_availableServers)
{
if (string.Equals(candidate.Id, server.Id, global::System.StringComparison.Ordinal))
{
AutoSDKServerConfiguration.SelectedServer = candidate;
AutoSDKServerConfiguration.ExplicitBaseUri = null;
return;
}
}

throw new global::System.ArgumentException("The provided server is not available for this client.", nameof(server));
}

private global::System.Uri? ResolveDisplayedBaseUri()
{
if (AutoSDKServerConfiguration.ExplicitBaseUri is global::System.Uri explicitBaseUri)
{
return explicitBaseUri;
}

return ResolveSelectedServer()?.Uri ?? (s_availableServers.Length > 0 ? s_availableServers[0].Uri : HttpClient.BaseAddress);
}

private global::System.Uri? ResolveBaseUri(
global::DeepL.AutoSDKServer[] servers,
string defaultBaseUrl)
{
if (AutoSDKServerConfiguration.ExplicitBaseUri is global::System.Uri explicitBaseUri)
{
return explicitBaseUri;
}

if (AutoSDKServerConfiguration.SelectedServer is global::DeepL.AutoSDKServer selectedServer)
{
foreach (var server in servers)
{
if (string.Equals(server.Id, selectedServer.Id, global::System.StringComparison.Ordinal))
{
return server.Uri;
}
}
}

if (servers.Length > 0)
{
return servers[0].Uri;
}

return string.IsNullOrWhiteSpace(defaultBaseUrl)
? HttpClient.BaseAddress
: new global::System.Uri(defaultBaseUrl, global::System.UriKind.RelativeOrAbsolute);
}
}
}
11 changes: 11 additions & 0 deletions src/libs/DeepL/Generated/DeepL.DeepLClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ public sealed partial class DeepLClient : global::DeepL.IDeepLClient, global::Sy
AutoSDKServerConfiguration = AutoSDKServerConfiguration,
};

/// <summary>
/// The `correct` endpoint fixes spelling and grammar errors without broader rephrasing. Use it when you want<br/>
/// a minimal-change correction pass rather than the broader rewriting performed by `rephrase`.
/// </summary>
public CorrectTextClient CorrectText => new CorrectTextClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
AutoSDKServerConfiguration = AutoSDKServerConfiguration,
};

/// <summary>
/// Please note that this is the spec for the (old) v2 glossary endpoint.<br/>
/// We recommend users switch to the newer v3 glossary endpoints, which support editability and multilinguality.<br/>
Expand Down
56 changes: 56 additions & 0 deletions src/libs/DeepL/Generated/DeepL.ICorrectTextClient.CorrectText.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#nullable enable

namespace DeepL
{
public partial interface ICorrectTextClient
{
/// <summary>
/// Correct text<br/>
/// Fix spelling and grammar errors in one or more texts. Unlike `/v2/write/rephrase`, this endpoint applies<br/>
/// a minimal-change correction pass and does not rewrite the text for style or tone.
/// </summary>
/// <param name="request"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::DeepL.ApiException"></exception>
global::System.Threading.Tasks.Task<global::DeepL.CorrectTextResponse> CorrectTextAsync(

global::DeepL.CorrectTextRequest request,
global::DeepL.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Correct text<br/>
/// Fix spelling and grammar errors in one or more texts. Unlike `/v2/write/rephrase`, this endpoint applies<br/>
/// a minimal-change correction pass and does not rewrite the text for style or tone.
/// </summary>
/// <param name="request"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::DeepL.ApiException"></exception>
global::System.Threading.Tasks.Task<global::DeepL.AutoSDKHttpResponse<global::DeepL.CorrectTextResponse>> CorrectTextAsResponseAsync(

global::DeepL.CorrectTextRequest request,
global::DeepL.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Correct text<br/>
/// Fix spelling and grammar errors in one or more texts. Unlike `/v2/write/rephrase`, this endpoint applies<br/>
/// a minimal-change correction pass and does not rewrite the text for style or tone.
/// </summary>
/// <param name="text">
/// Text to be corrected. Only UTF-8-encoded plain text is supported. Corrections are returned in the same order as they are requested.
/// </param>
/// <param name="targetLang">
/// The language for the text improvement.<br/>
/// Example: de
/// </param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::DeepL.CorrectTextResponse> CorrectTextAsync(
global::System.Collections.Generic.IList<string> text,
global::DeepL.TargetLanguageWrite? targetLang = default,
global::DeepL.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
Loading