From 2d0dff3f7647532641d3eedf0f4804cd6f01f056 Mon Sep 17 00:00:00 2001 From: Chris Watson Date: Thu, 19 Sep 2024 01:21:05 +0000 Subject: [PATCH] bot api update --- src/tourmaline/client/api.cr | 164 ++++++++++++++++------- src/tourmaline/types/api.cr | 246 +++++++++++++++++++++++++++++++++-- 2 files changed, 350 insertions(+), 60 deletions(-) diff --git a/src/tourmaline/client/api.cr b/src/tourmaline/client/api.cr index d3dbaef73..cc0b4c5b5 100644 --- a/src/tourmaline/client/api.cr +++ b/src/tourmaline/client/api.cr @@ -147,23 +147,25 @@ module Tourmaline caption : String | ::Nil = nil, parse_mode : ParseMode = default_parse_mode, caption_entities : Array(Tourmaline::MessageEntity) | ::Nil = nil, + show_caption_above_media : Bool | ::Nil = nil, disable_notification : Bool | ::Nil = nil, protect_content : Bool | ::Nil = nil, reply_parameters : Tourmaline::ReplyParameters | ::Nil = nil, reply_markup : Tourmaline::InlineKeyboardMarkup | Tourmaline::ReplyKeyboardMarkup | Tourmaline::ReplyKeyboardRemove | Tourmaline::ForceReply | ::Nil = nil ) request(Tourmaline::MessageId, "copyMessage", { - chat_id: chat_id, - from_chat_id: from_chat_id, - message_id: message_id, - message_thread_id: message_thread_id, - caption: caption, - parse_mode: parse_mode, - caption_entities: caption_entities.try(&.to_json), - disable_notification: disable_notification, - protect_content: protect_content, - reply_parameters: reply_parameters, - reply_markup: reply_markup.try(&.to_json), + chat_id: chat_id, + from_chat_id: from_chat_id, + message_id: message_id, + message_thread_id: message_thread_id, + caption: caption, + parse_mode: parse_mode, + caption_entities: caption_entities.try(&.to_json), + show_caption_above_media: show_caption_above_media, + disable_notification: disable_notification, + protect_content: protect_content, + reply_parameters: reply_parameters, + reply_markup: reply_markup.try(&.to_json), }) end @@ -430,6 +432,39 @@ module Tourmaline }) end + # Use this method to send paid media. On success, the sent Message is returned. + def send_paid_media( + chat_id : Int32 | Int64 | String, + star_count : Int32 | Int64, + media : Array(Tourmaline::InputPaidMedia), + business_connection_id : String | ::Nil = nil, + payload : String | ::Nil = nil, + caption : String | ::Nil = nil, + parse_mode : ParseMode = default_parse_mode, + caption_entities : Array(Tourmaline::MessageEntity) | ::Nil = nil, + show_caption_above_media : Bool | ::Nil = nil, + disable_notification : Bool | ::Nil = nil, + protect_content : Bool | ::Nil = nil, + reply_parameters : Tourmaline::ReplyParameters | ::Nil = nil, + reply_markup : Tourmaline::InlineKeyboardMarkup | Tourmaline::ReplyKeyboardMarkup | Tourmaline::ReplyKeyboardRemove | Tourmaline::ForceReply | ::Nil = nil + ) + request(Tourmaline::Message, "sendPaidMedia", { + chat_id: chat_id, + star_count: star_count, + media: media.to_json, + business_connection_id: business_connection_id, + payload: payload, + caption: caption, + parse_mode: parse_mode, + caption_entities: caption_entities.try(&.to_json), + show_caption_above_media: show_caption_above_media, + disable_notification: disable_notification, + protect_content: protect_content, + reply_parameters: reply_parameters, + reply_markup: reply_markup.try(&.to_json), + }) + end + # Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned. def send_media_group( chat_id : Int32 | Int64 | String, @@ -1337,9 +1372,10 @@ module Tourmaline }) end - # Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + # Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. def edit_message_text( text : String, + business_connection_id : String | ::Nil = nil, chat_id : Int32 | Int64 | String | ::Nil = nil, message_id : Int32 | Int64 | ::Nil = nil, inline_message_id : String | ::Nil = nil, @@ -1349,19 +1385,21 @@ module Tourmaline reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil ) request(Tourmaline::Message | Bool, "editMessageText", { - text: text, - chat_id: chat_id, - message_id: message_id, - inline_message_id: inline_message_id, - parse_mode: parse_mode, - entities: entities.try(&.to_json), - link_preview_options: link_preview_options, - reply_markup: reply_markup.try(&.to_json), + text: text, + business_connection_id: business_connection_id, + chat_id: chat_id, + message_id: message_id, + inline_message_id: inline_message_id, + parse_mode: parse_mode, + entities: entities.try(&.to_json), + link_preview_options: link_preview_options, + reply_markup: reply_markup.try(&.to_json), }) end - # Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + # Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. def edit_message_caption( + business_connection_id : String | ::Nil = nil, chat_id : Int32 | Int64 | String | ::Nil = nil, message_id : Int32 | Int64 | ::Nil = nil, inline_message_id : String | ::Nil = nil, @@ -1371,30 +1409,34 @@ module Tourmaline reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil ) request(Tourmaline::Message | Bool, "editMessageCaption", { - chat_id: chat_id, - message_id: message_id, - inline_message_id: inline_message_id, - caption: caption, - parse_mode: parse_mode, - caption_entities: caption_entities.try(&.to_json), - reply_markup: reply_markup.try(&.to_json), + business_connection_id: business_connection_id, + chat_id: chat_id, + message_id: message_id, + inline_message_id: inline_message_id, + caption: caption, + parse_mode: parse_mode, + caption_entities: caption_entities.try(&.to_json), + show_caption_above_media: show_caption_above_media, + reply_markup: reply_markup.try(&.to_json), }) end - # Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + # Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. def edit_message_media( media : Tourmaline::InputMedia, + business_connection_id : String | ::Nil = nil, chat_id : Int32 | Int64 | String | ::Nil = nil, message_id : Int32 | Int64 | ::Nil = nil, inline_message_id : String | ::Nil = nil, reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil ) request(Tourmaline::Message | Bool, "editMessageMedia", { - media: media.to_json, - chat_id: chat_id, - message_id: message_id, - inline_message_id: inline_message_id, - reply_markup: reply_markup.try(&.to_json), + media: media.to_json, + business_connection_id: business_connection_id, + chat_id: chat_id, + message_id: message_id, + inline_message_id: inline_message_id, + reply_markup: reply_markup.try(&.to_json), }) end @@ -1402,6 +1444,7 @@ module Tourmaline def edit_message_live_location( latitude : Float64, longitude : Float64, + business_connection_id : String | ::Nil = nil, chat_id : Int32 | Int64 | String | ::Nil = nil, message_id : Int32 | Int64 | ::Nil = nil, inline_message_id : String | ::Nil = nil, @@ -1414,6 +1457,7 @@ module Tourmaline request(Tourmaline::Message | Bool, "editMessageLiveLocation", { latitude: latitude, longitude: longitude, + business_connection_id: business_connection_id, chat_id: chat_id, message_id: message_id, inline_message_id: inline_message_id, @@ -1427,31 +1471,35 @@ module Tourmaline # Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. def stop_message_live_location( + business_connection_id : String | ::Nil = nil, chat_id : Int32 | Int64 | String | ::Nil = nil, message_id : Int32 | Int64 | ::Nil = nil, inline_message_id : String | ::Nil = nil, reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil ) request(Tourmaline::Message | Bool, "stopMessageLiveLocation", { - chat_id: chat_id, - message_id: message_id, - inline_message_id: inline_message_id, - reply_markup: reply_markup.try(&.to_json), + business_connection_id: business_connection_id, + chat_id: chat_id, + message_id: message_id, + inline_message_id: inline_message_id, + reply_markup: reply_markup.try(&.to_json), }) end - # Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + # Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. def edit_message_reply_markup( + business_connection_id : String | ::Nil = nil, chat_id : Int32 | Int64 | String | ::Nil = nil, message_id : Int32 | Int64 | ::Nil = nil, inline_message_id : String | ::Nil = nil, reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil ) request(Tourmaline::Message | Bool, "editMessageReplyMarkup", { - chat_id: chat_id, - message_id: message_id, - inline_message_id: inline_message_id, - reply_markup: reply_markup.try(&.to_json), + business_connection_id: business_connection_id, + chat_id: chat_id, + message_id: message_id, + inline_message_id: inline_message_id, + reply_markup: reply_markup.try(&.to_json), }) end @@ -1459,12 +1507,14 @@ module Tourmaline def stop_poll( chat_id : Int32 | Int64 | String, message_id : Int32 | Int64, + business_connection_id : String | ::Nil = nil, reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil ) request(Tourmaline::Poll, "stopPoll", { - chat_id: chat_id, - message_id: message_id, - reply_markup: reply_markup.try(&.to_json), + chat_id: chat_id, + message_id: message_id, + business_connection_id: business_connection_id, + reply_markup: reply_markup.try(&.to_json), }) end @@ -1868,6 +1918,28 @@ module Tourmaline }) end + # Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object. + def get_star_transactions( + offset : Int32 | Int64 | ::Nil = nil, + limit : Int32 | Int64 | ::Nil = nil + ) + request(Tourmaline::StarTransactions, "getStarTransactions", { + offset: offset, + limit: limit, + }) + end + + # Refunds a successful payment in Telegram Stars. Returns True on success. + def refund_star_payment( + user_id : Int32 | Int64, + telegram_payment_charge_id : String + ) + request(Bool, "refundStarPayment", { + user_id: user_id, + telegram_payment_charge_id: telegram_payment_charge_id, + }) + end + # Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. # Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues. def set_passport_data_errors( diff --git a/src/tourmaline/types/api.cr b/src/tourmaline/types/api.cr index d3585ab22..3d416d4ae 100644 --- a/src/tourmaline/types/api.cr +++ b/src/tourmaline/types/api.cr @@ -26,7 +26,7 @@ module Tourmaline # Optional. The bot was connected to or disconnected from a business account, or a user edited an existing connection with the bot property business_connection : Tourmaline::BusinessConnection | ::Nil - # Optional. New non-service message from a connected business account + # Optional. New message from a connected business account property business_message : Tourmaline::Message | ::Nil # Optional. New version of a message from a connected business account @@ -56,6 +56,9 @@ module Tourmaline # Optional. New incoming pre-checkout query. Contains full information about checkout property pre_checkout_query : Tourmaline::PreCheckoutQuery | ::Nil + # Optional. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat + property purchased_paid_media : Tourmaline::PaidMediaPurchased | ::Nil + # Optional. New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot property poll : Tourmaline::Poll | ::Nil @@ -94,6 +97,7 @@ module Tourmaline @callback_query : Tourmaline::CallbackQuery | ::Nil = nil, @shipping_query : Tourmaline::ShippingQuery | ::Nil = nil, @pre_checkout_query : Tourmaline::PreCheckoutQuery | ::Nil = nil, + @purchased_paid_media : Tourmaline::PaidMediaPurchased | ::Nil = nil, @poll : Tourmaline::Poll | ::Nil = nil, @poll_answer : Tourmaline::PollAnswer | ::Nil = nil, @my_chat_member : Tourmaline::ChatMemberUpdated | ::Nil = nil, @@ -329,7 +333,7 @@ module Tourmaline # Optional. True, if users need to join the supergroup before they can send messages property? join_to_send_messages : Bool | ::Nil - # Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators + # Optional. True, if all users directly joining the supergroup without using an invite link need to be approved by supergroup administrators property? join_by_request : Bool | ::Nil # Optional. Description, for groups, supergroups and channel chats @@ -1573,9 +1577,6 @@ module Tourmaline # Longitude as defined by sender property longitude : Float64 - # Latitude as defined by sender - property latitude : Float64 - # Optional. The radius of uncertainty for the location, measured in meters; 0-1500 property horizontal_accuracy : Float64 | ::Nil @@ -1589,8 +1590,8 @@ module Tourmaline property proximity_alert_radius : Int32 | Int64 | ::Nil def initialize( - @longitude, @latitude, + @longitude, @horizontal_accuracy : Float64 | ::Nil = nil, @live_period : Int32 | Int64 | ::Nil = nil, @heading : Int32 | Int64 | ::Nil = nil, @@ -2085,9 +2086,17 @@ module Tourmaline end end - # This object represents a service message about the creation of a scheduled giveaway. Currently holds no information. + # This object represents a service message about the creation of a scheduled giveaway. class GiveawayCreated include JSON::Serializable + + # Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only + property prize_star_count : Int32 | Int64 | ::Nil + + def initialize( + @prize_star_count : Int32 | Int64 | ::Nil = nil + ) + end end # This object represents a message about a scheduled giveaway. @@ -2116,7 +2125,10 @@ module Tourmaline # Optional. A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways. property country_codes : Array(String) = [] of String - # Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for + # Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only + property prize_star_count : Int32 | Int64 | ::Nil + + # Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only property premium_subscription_month_count : Int32 | Int64 | ::Nil def initialize( @@ -2127,6 +2139,7 @@ module Tourmaline @has_public_winners : Bool | ::Nil = nil, @prize_description : String | ::Nil = nil, @country_codes : Array(String) = [] of String, + @prize_star_count : Int32 | Int64 | ::Nil = nil, @premium_subscription_month_count : Int32 | Int64 | ::Nil = nil ) end @@ -2155,7 +2168,10 @@ module Tourmaline # Optional. The number of other chats the user had to join in order to be eligible for the giveaway property additional_chat_count : Int32 | Int64 | ::Nil - # Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for + # Optional. The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only + property prize_star_count : Int32 | Int64 | ::Nil + + # Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only property premium_subscription_month_count : Int32 | Int64 | ::Nil # Optional. Number of undistributed prizes @@ -2177,6 +2193,7 @@ module Tourmaline @winner_count, @winners : Array(Tourmaline::User) = [] of Tourmaline::User, @additional_chat_count : Int32 | Int64 | ::Nil = nil, + @prize_star_count : Int32 | Int64 | ::Nil = nil, @premium_subscription_month_count : Int32 | Int64 | ::Nil = nil, @unclaimed_prize_count : Int32 | Int64 | ::Nil = nil, @only_new_members : Bool | ::Nil = nil, @@ -2199,10 +2216,14 @@ module Tourmaline # Optional. Message with the giveaway that was completed, if it wasn't deleted property giveaway_message : Tourmaline::Message | ::Nil + # Optional. True, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway. + property? is_star_giveaway : Bool | ::Nil + def initialize( @winner_count, @unclaimed_prize_count : Int32 | Int64 | ::Nil = nil, - @giveaway_message : Tourmaline::Message | ::Nil = nil + @giveaway_message : Tourmaline::Message | ::Nil = nil, + @is_star_giveaway : Bool | ::Nil = nil ) end end @@ -2505,7 +2526,7 @@ module Tourmaline # Optional. HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their identifier without using a username, if this is allowed by their privacy settings. property url : String | ::Nil - # Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes. Not supported for messages sent on behalf of a Telegram Business account. + # Optional. Data to be sent in a callback query to the bot when the button is pressed, 1-64 bytes property callback_data : String | ::Nil # Optional. Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot. Not supported for messages sent on behalf of a Telegram Business account. @@ -2820,7 +2841,7 @@ module Tourmaline # Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only. property invite_link : Tourmaline::ChatInviteLink | ::Nil - # Optional. True, if the user joined the chat after sending a direct join request and being approved by an administrator + # Optional. True, if the user joined the chat after sending a direct join request without using an invite link and being approved by an administrator property? via_join_request : Bool | ::Nil # Optional. True, if the user joined the chat via a chat folder invite link @@ -3717,7 +3738,7 @@ module Tourmaline end end - # The boost was obtained by the creation of a Telegram Premium giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription. + # The boost was obtained by the creation of a Telegram Premium or a Telegram Star giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription for Telegram Premium giveaways and prize_star_count / 500 times for one year for Telegram Star giveaways. class ChatBoostSourceGiveaway include JSON::Serializable @@ -3727,9 +3748,12 @@ module Tourmaline # Identifier of a message in the chat with the giveaway; the message could have been deleted already. May be 0 if the message isn't sent yet. property giveaway_message_id : Int32 | Int64 - # Optional. User that won the prize in the giveaway if any + # Optional. User that won the prize in the giveaway if any; for Telegram Premium giveaways only property user : Tourmaline::User | ::Nil + # Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only + property prize_star_count : Int32 | Int64 | ::Nil + # Optional. True, if the giveaway was completed, but there was no user to win the prize property? is_unclaimed : Bool | ::Nil @@ -3737,6 +3761,7 @@ module Tourmaline @source, @giveaway_message_id, @user : Tourmaline::User | ::Nil = nil, + @prize_star_count : Int32 | Int64 | ::Nil = nil, @is_unclaimed : Bool | ::Nil = nil ) end @@ -5889,6 +5914,199 @@ module Tourmaline end end + # This object contains information about a paid media purchase. + class PaidMediaPurchased + include JSON::Serializable + + # User who purchased the media + property from : Tourmaline::User + + # Bot-specified paid media payload + property paid_media_payload : String + + def initialize( + @from, + @paid_media_payload + ) + end + end + + # This object describes the state of a revenue withdrawal operation. Currently, it can be one of + # - RevenueWithdrawalStatePending + # - RevenueWithdrawalStateSucceeded + # - RevenueWithdrawalStateFailed + alias RevenueWithdrawalState = Tourmaline::RevenueWithdrawalStatePending | Tourmaline::RevenueWithdrawalStateSucceeded | Tourmaline::RevenueWithdrawalStateFailed + + # The withdrawal is in progress. + class RevenueWithdrawalStatePending + include JSON::Serializable + + # Type of the state, always "pending" + property type : String + + def initialize( + @type + ) + end + end + + # The withdrawal succeeded. + class RevenueWithdrawalStateSucceeded + include JSON::Serializable + + # Type of the state, always "succeeded" + property type : String + + # Date the withdrawal was completed in Unix time + @[JSON::Field(converter: Time::EpochConverter)] + property date : Time + + # An HTTPS URL that can be used to see transaction details + property url : String + + def initialize( + @type, + @date, + @url + ) + end + end + + # The withdrawal failed and the transaction was refunded. + class RevenueWithdrawalStateFailed + include JSON::Serializable + + # Type of the state, always "failed" + property type : String + + def initialize( + @type + ) + end + end + + # This object describes the source of a transaction, or its recipient for outgoing transactions. Currently, it can be one of + # - TransactionPartnerUser + # - TransactionPartnerFragment + # - TransactionPartnerTelegramAds + # - TransactionPartnerOther + alias TransactionPartner = Tourmaline::TransactionPartnerUser | Tourmaline::TransactionPartnerFragment | Tourmaline::TransactionPartnerTelegramAds | Tourmaline::TransactionPartnerOther + + # Describes a transaction with a user. + class TransactionPartnerUser + include JSON::Serializable + + # Type of the transaction partner, always "user" + property type : String + + # Information about the user + property user : Tourmaline::User + + # Optional. Bot-specified invoice payload + property invoice_payload : String | ::Nil + + # Optional. Information about the paid media bought by the user + property paid_media : Array(Tourmaline::PaidMedia) = [] of Tourmaline::PaidMedia + + # Optional. Bot-specified paid media payload + property paid_media_payload : String | ::Nil + + def initialize( + @type, + @user, + @invoice_payload : String | ::Nil = nil, + @paid_media : Array(Tourmaline::PaidMedia) = [] of Tourmaline::PaidMedia, + @paid_media_payload : String | ::Nil = nil + ) + end + end + + # Describes a withdrawal transaction with Fragment. + class TransactionPartnerFragment + include JSON::Serializable + + # Type of the transaction partner, always "fragment" + property type : String + + # Optional. State of the transaction if the transaction is outgoing + property withdrawal_state : Tourmaline::RevenueWithdrawalState | ::Nil + + def initialize( + @type, + @withdrawal_state : Tourmaline::RevenueWithdrawalState | ::Nil = nil + ) + end + end + + # Describes a withdrawal transaction to the Telegram Ads platform. + class TransactionPartnerTelegramAds + include JSON::Serializable + + # Type of the transaction partner, always "telegram_ads" + property type : String + + def initialize( + @type + ) + end + end + + # Describes a transaction with an unknown source or recipient. + class TransactionPartnerOther + include JSON::Serializable + + # Type of the transaction partner, always "other" + property type : String + + def initialize( + @type + ) + end + end + + # Describes a Telegram Star transaction. + class StarTransaction + include JSON::Serializable + + # Unique identifier of the transaction. Coincides with the identifer of the original transaction for refund transactions. Coincides with SuccessfulPayment.telegram_payment_charge_id for successful incoming payments from users. + property id : String + + # Number of Telegram Stars transferred by the transaction + property amount : Int32 | Int64 + + # Date the transaction was created in Unix time + @[JSON::Field(converter: Time::EpochConverter)] + property date : Time + + # Optional. Source of an incoming transaction (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal). Only for incoming transactions + property source : Tourmaline::TransactionPartner | ::Nil + + # Optional. Receiver of an outgoing transaction (e.g., a user for a purchase refund, Fragment for a withdrawal). Only for outgoing transactions + property receiver : Tourmaline::TransactionPartner | ::Nil + + def initialize( + @id, + @amount, + @date, + @source : Tourmaline::TransactionPartner | ::Nil = nil, + @receiver : Tourmaline::TransactionPartner | ::Nil = nil + ) + end + end + + # Contains a list of Telegram Star transactions. + class StarTransactions + include JSON::Serializable + + # The list of transactions + property transactions : Array(Tourmaline::StarTransaction) = [] of Tourmaline::StarTransaction + + def initialize( + @transactions : Array(Tourmaline::StarTransaction) = [] of Tourmaline::StarTransaction + ) + end + end + # Describes Telegram Passport data shared with the bot by the user. class PassportData include JSON::Serializable