From 1e4de0ce38cab14453c78787c0f7d474ae85635a Mon Sep 17 00:00:00 2001 From: Niklas Weimann Date: Wed, 25 Dec 2024 17:06:48 +0100 Subject: [PATCH] Add support for api v8.1 Signed-off-by: Niklas Weimann --- README.md | 2 +- .../BaseTypes/Enums/TransactionPartnerType.cs | 6 ++-- .../Interface/Payments/AffiliateInfo.cs | 36 +++++++++++++++++++ .../Interface/Payments/StarTransaction.cs | 5 +++ .../TransactionPartnerAffiliateProgram.cs | 25 +++++++++++++ .../Payments/TransactionPartnerOther.cs | 2 +- .../Payments/TransactionPartnerTelegramAds.cs | 2 +- .../Payments/TransactionPartnerUser.cs | 2 ++ src/RxTelegram.Bot/RxTelegram.Bot.csproj | 2 +- 9 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 src/RxTelegram.Bot/Interface/Payments/AffiliateInfo.cs create mode 100644 src/RxTelegram.Bot/Interface/Payments/TransactionPartnerAffiliateProgram.cs diff --git a/README.md b/README.md index 2efabf8..b0bf58f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=RxTelegram_RxTelegram.Bot&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=RxTelegram_RxTelegram.Bot) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=RxTelegram_RxTelegram.Bot&metric=coverage)](https://sonarcloud.io/summary/new_code?id=RxTelegram_RxTelegram.Bot) -RxTelegram.Bot supports Telegram Bot API 8.0 (as at November 17, 2024). +RxTelegram.Bot supports Telegram Bot API 8.1 (as at December 4, 2024). This is a reactive designed .NET Library for the Telegram Bot API. It works with the official [Reactive Extentions](https://github.com/dotnet/reactive). diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/Enums/TransactionPartnerType.cs b/src/RxTelegram.Bot/Interface/BaseTypes/Enums/TransactionPartnerType.cs index 07cfc09..35791f0 100644 --- a/src/RxTelegram.Bot/Interface/BaseTypes/Enums/TransactionPartnerType.cs +++ b/src/RxTelegram.Bot/Interface/BaseTypes/Enums/TransactionPartnerType.cs @@ -15,10 +15,12 @@ public enum TransactionPartnerType [ImplementationType(typeof(TransactionPartnerTelegramAds))] TelegramAds, - [ImplementationType(typeof(TransactionPartnerOther))] Other, [ImplementationType(typeof(TransactionPartnerTelegramApi))] - TelegramApi + TelegramApi, + + [ImplementationType(typeof(TransactionPartnerAffiliateProgram))] + AffiliateProgram } diff --git a/src/RxTelegram.Bot/Interface/Payments/AffiliateInfo.cs b/src/RxTelegram.Bot/Interface/Payments/AffiliateInfo.cs new file mode 100644 index 0000000..3a186e5 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Payments/AffiliateInfo.cs @@ -0,0 +1,36 @@ +using RxTelegram.Bot.Interface.BaseTypes; + +namespace RxTelegram.Bot.Interface.Payments; + +/// +/// Contains information about the affiliate that received a commission via this transaction. +/// +public class AffiliateInfo +{ + /// + /// Optional. The bot or the user that received an affiliate commission if it was received by a bot or a user + /// + public User AffiliateUser { get; set; } + + /// + /// Optional. The chat that received an affiliate commission if it was received by a chat + /// + public Chat AffiliateChat { get; set; } + + /// + /// The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred users + /// + public int CommissionPerMille { get; set; } + + /// + /// Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; + /// can be negative for refunds + /// + public int Amount { get; set; } + + /// + /// Optional. The number of 1/1000000000 shares of Telegram Stars received by the affiliate; from -999999999 to 999999999; + /// can be negative for refunds + /// + public int? NanostarAmount { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Payments/StarTransaction.cs b/src/RxTelegram.Bot/Interface/Payments/StarTransaction.cs index b14ac92..88d19e4 100644 --- a/src/RxTelegram.Bot/Interface/Payments/StarTransaction.cs +++ b/src/RxTelegram.Bot/Interface/Payments/StarTransaction.cs @@ -16,6 +16,11 @@ public class StarTransaction /// public int Amount { get; set; } + /// + /// Optional. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999 + /// + public int? NanostarAmount { get; set; } + /// /// Date the transaction was created in Unix time /// diff --git a/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerAffiliateProgram.cs b/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerAffiliateProgram.cs new file mode 100644 index 0000000..7f7b68c --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerAffiliateProgram.cs @@ -0,0 +1,25 @@ +using RxTelegram.Bot.Interface.BaseTypes; +using RxTelegram.Bot.Interface.BaseTypes.Enums; + +namespace RxTelegram.Bot.Interface.Payments; + +/// +/// Describes the affiliate program that issued the affiliate commission received via this transaction. +/// +public class TransactionPartnerAffiliateProgram : TransactionPartner +{ + /// + /// Type of the transaction partner, always “affiliate_program” + /// + public override TransactionPartnerType Type { get; set; } = TransactionPartnerType.AffiliateProgram; + + /// + /// Optional. Information about the bot that sponsored the affiliate program + /// + public User SponsorUser { get; set; } + + /// + /// The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program sponsor from referred users + /// + public int CommissionPerMille { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerOther.cs b/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerOther.cs index e39e7dc..d37095f 100644 --- a/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerOther.cs +++ b/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerOther.cs @@ -10,5 +10,5 @@ public class TransactionPartnerOther : TransactionPartner /// /// Type of the transaction partner, always “other” /// - public override TransactionPartnerType Type { get; set; } + public override TransactionPartnerType Type { get; set; } = TransactionPartnerType.Other; } diff --git a/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerTelegramAds.cs b/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerTelegramAds.cs index ce481dd..86439af 100644 --- a/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerTelegramAds.cs +++ b/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerTelegramAds.cs @@ -10,5 +10,5 @@ public class TransactionPartnerTelegramAds : TransactionPartner /// /// Type of the transaction partner, always “telegram_ads” /// - public override TransactionPartnerType Type { get; set; } + public override TransactionPartnerType Type { get; set; } = TransactionPartnerType.TelegramAds; } diff --git a/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerUser.cs b/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerUser.cs index 3953d53..490d2ea 100644 --- a/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerUser.cs +++ b/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerUser.cs @@ -20,6 +20,8 @@ public class TransactionPartnerUser : TransactionPartner /// public User User { get; set; } + public AffiliateInfo Affiliate { get; set; } + /// /// Optional. Bot-specified invoice payload /// diff --git a/src/RxTelegram.Bot/RxTelegram.Bot.csproj b/src/RxTelegram.Bot/RxTelegram.Bot.csproj index b3d2b6c..9e4b02e 100644 --- a/src/RxTelegram.Bot/RxTelegram.Bot.csproj +++ b/src/RxTelegram.Bot/RxTelegram.Bot.csproj @@ -10,7 +10,7 @@ https://github.com/RxTelegram/RxTelegram.Bot git Telegram;Bot;Api;Rx;Reactive;Observable;RxTelegram;RxTelegram.Bot - 8.0.0 + 8.1.0 icon.png true bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml