Skip to content

Commit

Permalink
Add code generator
Browse files Browse the repository at this point in the history
Remove Newtonsoft.Json
Remove IEquatable
Remove model interfaces
Remove AttachedFile class
Code cleanup
  • Loading branch information
Eptagone committed Jan 29, 2024
1 parent 24fa497 commit 3026c54
Show file tree
Hide file tree
Showing 449 changed files with 27,928 additions and 31,657 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Ignore vscode editor files
.vscode/*
# Ignore all folders named publish
**/publish/*
# Nuget packages
nuget.config
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ It contains all the methods and types available in the Bot API 7.0 released on D
- Contains pre-defined methods for all Bot API 7.0 methods.
- Contains classes for each object type used in the Bot API 7.0.
- Sync and async methods.
- Support [System.Text.Json](https://www.nuget.org/packages/System.Text.Json/) and [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json/).
- Uses [System.Text.Json](https://www.nuget.org/packages/System.Text.Json/) by default.

---

Expand Down
2 changes: 1 addition & 1 deletion src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ dotnet_style_collection_initializer = true:suggestion
dotnet_style_qualification_for_field = true:suggestion
dotnet_style_qualification_for_property = true:suggestion
dotnet_style_qualification_for_method = true:suggestion
dotnet_style_qualification_for_event = true:silent
dotnet_style_qualification_for_event = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
Expand Down
20 changes: 0 additions & 20 deletions src/library/Telegram.BotAPI/Abstractions/ICaption.cs

This file was deleted.

25 changes: 0 additions & 25 deletions src/library/Telegram.BotAPI/Abstractions/IContact.cs

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions src/library/Telegram.BotAPI/Abstractions/IExternalThumbnail.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/library/Telegram.BotAPI/Abstractions/IFormattableMessage.cs

This file was deleted.

26 changes: 0 additions & 26 deletions src/library/Telegram.BotAPI/Abstractions/ILocation.cs

This file was deleted.

82 changes: 82 additions & 0 deletions src/library/Telegram.BotAPI/Abstractions/ITelegramBotClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright (c) 2024 Quetzal Rivera.
// Licensed under the MIT License, See LICENCE in the project root for license information.

using System.Net.Http;
using System.Text.Json;

namespace Telegram.BotAPI;

/// <summary>
/// Defines methods to make requests to the Telegram Bot API.
/// </summary>
public interface ITelegramBotClient
{
/// <summary>
/// Options used to configure the client.
/// </summary>
TelegramBotClientOptions Options { get; }

/// <summary>
/// Calls a method of the Telegram Bot API and returns the result.
/// </summary>
/// <typeparam name="TResult">Result type.</typeparam>
/// <param name="method">Method name.</param>
/// <param name="args">Method arguments.</param>
/// <returns>An object containing the result of the API call.</returns>
/// <exception cref="ArgumentException">The method arguments are invalid.</exception>
/// <exception cref="BotRequestException">The request failed and the Bot API returned an error.</exception>
/// <exception cref="HttpRequestException">The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.</exception>
/// <exception cref="JsonException">The response could not be deserialized.</exception>
TResult CallMethod<TResult>(string method, object? args = null);

/// <summary>
/// Calls a method of the Telegram Bot API and returns the result.
/// </summary>
/// <typeparam name="TResult">Result type.</typeparam>
/// <param name="method">Method name.</param>
/// <param name="args">Method arguments.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the request.</param>
/// <returns>An object containing the result of the API call.</returns>
/// <exception cref="ArgumentException">The method arguments are invalid.</exception>
/// <exception cref="BotRequestException">The request failed and the Bot API returned an error.</exception>
/// <exception cref="HttpRequestException">The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.</exception>
/// <exception cref="JsonException">The response could not be deserialized.</exception>
/// <exception cref="OperationCanceledException">The request was canceled.</exception>
Task<TResult> CallMethodAsync<TResult>(
string method,
object? args = null,
CancellationToken cancellationToken = default
);

/// <summary>
/// Calls a method of the Telegram Bot API and returns the response.
/// </summary>
/// <typeparam name="TReturn">Response type.</typeparam>
/// <param name="method">Method name.</param>
/// <param name="args">Method arguments.</param>
/// <returns>A <see cref="BotResponse{T}"/> object containing the response.</returns>
/// <exception cref="ArgumentException">The method arguments are invalid.</exception>
/// <exception cref="BotRequestException">The request failed and the Bot API returned an error.</exception>
/// <exception cref="HttpRequestException">The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.</exception>
/// <exception cref="JsonException">The response could not be deserialized.</exception>
BotResponse<TReturn> CallMethodDirect<TReturn>(string method, object? args = null);

/// <summary>
/// Calls a method of the Telegram Bot API and returns the response.
/// </summary>
/// <typeparam name="TReturn">Response type.</typeparam>
/// <param name="method">Method name.</param>
/// <param name="args">Method arguments.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the request.</param>
/// <returns>A <see cref="BotResponse{T}"/> object containing the response.</returns>
/// <exception cref="ArgumentException">The method arguments are invalid.</exception>
/// <exception cref="BotRequestException">The request failed and the Bot API returned an error.</exception>
/// <exception cref="HttpRequestException">The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.</exception>
/// <exception cref="JsonException">The response could not be deserialized.</exception>
/// <exception cref="OperationCanceledException">The request was canceled.</exception>
Task<BotResponse<TReturn>> CallMethodDirectAsync<TReturn>(
string method,
object? args = null,
CancellationToken cancellationToken = default
);
}
13 changes: 0 additions & 13 deletions src/library/Telegram.BotAPI/Abstractions/ITelegramFile.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/library/Telegram.BotAPI/Abstractions/IThumbnail.cs

This file was deleted.

23 changes: 0 additions & 23 deletions src/library/Telegram.BotAPI/Abstractions/IVenue.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2024 Quetzal Rivera.
// Licensed under the MIT License, See LICENCE in the project root for license information.

using Telegram.BotAPI.AvailableTypes;

namespace Telegram.BotAPI;

/// <summary>
/// Defines a property to send attached files through multipart/form-data.
/// </summary>
public abstract class AttachedFilesArgsBase
{
/// <summary>
/// Files to send.
/// </summary>
[JsonIgnore]
public IDictionary<string, InputFile> Files { get; set; } = new Dictionary<string, InputFile>();
}
71 changes: 0 additions & 71 deletions src/library/Telegram.BotAPI/Abstractions/SendMessageBase.cs

This file was deleted.

Loading

0 comments on commit 3026c54

Please sign in to comment.