Skip to content

Commit

Permalink
Implement Bot API 8.1 (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
atipugin authored Dec 5, 2024
1 parent e72b2e5 commit 91196dc
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 0 deletions.
41 changes: 41 additions & 0 deletions data/type_attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -4712,9 +4712,29 @@
"default": "failed"
}
},
"AffiliateInfo": {
"affiliate_user": {
"type": "User"
},
"affiliate_chat": {
"type": "Chat"
},
"commission_per_mille": {
"type": "integer",
"required": true
},
"amount": {
"type": "integer",
"required": true
},
"nanostar_amount": {
"type": "integer"
}
},
"TransactionPartner": {
"type": [
"TransactionPartnerUser",
"TransactionPartnerAffiliateProgram",
"TransactionPartnerFragment",
"TransactionPartnerTelegramAds",
"TransactionPartnerTelegramApi",
Expand All @@ -4732,6 +4752,9 @@
"type": "User",
"required": true
},
"affiliate": {
"type": "AffiliateInfo"
},
"invoice_payload": {
"type": "string"
},
Expand All @@ -4749,6 +4772,21 @@
"type": "Gift"
}
},
"TransactionPartnerAffiliateProgram": {
"type": {
"type": "string",
"required": true,
"required_value": "affiliate_program",
"default": "affiliate_program"
},
"sponsor_user": {
"type": "User"
},
"commission_per_mille": {
"type": "integer",
"required": true
}
},
"TransactionPartnerFragment": {
"type": {
"type": "string",
Expand Down Expand Up @@ -4797,6 +4835,9 @@
"type": "integer",
"required": true
},
"nanostar_amount": {
"type": "integer"
},
"date": {
"type": "integer",
"required": true
Expand Down
15 changes: 15 additions & 0 deletions lib/telegram/bot/types/affiliate_info.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Telegram
module Bot
module Types
class AffiliateInfo < Base
attribute? :affiliate_user, User
attribute? :affiliate_chat, Chat
attribute :commission_per_mille, Types::Integer
attribute :amount, Types::Integer
attribute? :nanostar_amount, Types::Integer
end
end
end
end
1 change: 1 addition & 0 deletions lib/telegram/bot/types/star_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Types
class StarTransaction < Base
attribute :id, Types::String
attribute :amount, Types::Integer
attribute? :nanostar_amount, Types::Integer
attribute :date, Types::Integer
attribute? :source, TransactionPartner
attribute? :receiver, TransactionPartner
Expand Down
1 change: 1 addition & 0 deletions lib/telegram/bot/types/transaction_partner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Types
# rubocop:disable Naming/ConstantName
TransactionPartner = (
TransactionPartnerUser |
TransactionPartnerAffiliateProgram |
TransactionPartnerFragment |
TransactionPartnerTelegramAds |
TransactionPartnerTelegramApi |
Expand Down
13 changes: 13 additions & 0 deletions lib/telegram/bot/types/transaction_partner_affiliate_program.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module Telegram
module Bot
module Types
class TransactionPartnerAffiliateProgram < Base
attribute :type, Types::String.constrained(eql: 'affiliate_program').default('affiliate_program')
attribute? :sponsor_user, User
attribute :commission_per_mille, Types::Integer
end
end
end
end
1 change: 1 addition & 0 deletions lib/telegram/bot/types/transaction_partner_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Types
class TransactionPartnerUser < Base
attribute :type, Types::String.constrained(eql: 'user').default('user')
attribute :user, User
attribute? :affiliate, AffiliateInfo
attribute? :invoice_payload, Types::String
attribute? :subscription_period, Types::Integer
attribute? :paid_media, Types::Array.of(PaidMedia)
Expand Down

0 comments on commit 91196dc

Please sign in to comment.