Skip to content

Commit

Permalink
telebot: refactor bot api 7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
demget committed Aug 9, 2024
1 parent 6713166 commit 8b69e47
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ func (b *Bot) MyShortDescription(language string) (*BotInfo, error) {
return b.botInfo(language, "getMyShortDescription")
}

func (b *Bot) GetStarTransactions(offset, limit int) ([]StarTransaction, error) {
func (b *Bot) StarTransactions(offset, limit int) ([]StarTransaction, error) {
params := map[string]int{
"offset": offset,
"limit": limit,
Expand Down
2 changes: 1 addition & 1 deletion media.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ type Location struct {

// (Optional) Unique identifier of the business connection
// on behalf of which the message to be edited was sent
BusinessConnectionID string `json:"business_connection_id"`
BusinessConnectionID string `json:"business_connection_id,omitempty"`
}

// Venue object represents a venue location with name, address and
Expand Down
61 changes: 31 additions & 30 deletions stars.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import "time"
type TransactionType = string

const (
TransactionTypeFragment TransactionType = "fragment"
TransactionTypeUser TransactionType = "user"
TransactionTypeOther TransactionType = "other"
TransactionTypeFragment TransactionType = "fragment"
TransactionPartnerTelegramAds TransactionType = "telegram_ads"
TransactionTypeOther TransactionType = "other"
)

type RevenueState = string
Expand All @@ -19,33 +19,8 @@ const (
RevenueStateFailed RevenueState = "failed"
)

type TransactionPartner struct {
// Type of the state
Type TransactionType `json:"type"`

// (Optional) State of the transaction if the transaction is outgoing$$
WithdrawalState RevenueWithdrawalState `json:"withdrawal_state,omitempty"`

// Information about the user
Partner *User `json:"user,omitempty"`

// (Optional) Bot-specified invoice payload
InvoicePayload string `json:"invoice_payload"`
}

type RevenueWithdrawalState struct {
// Type of the state
Type RevenueState `json:"type"`

// Date the withdrawal was completed in Unix time
Date int `json:"date,omitempty"`

// An HTTPS URL that can be used to see transaction details
URL string `json:"url,omitempty"`
}

type StarTransaction struct {
// Unique identifier of the transaction. Coincides with the identifer of the
// Unique identifier of the transaction. Coincides with the identifier of the
// original transaction for refund transactions. Coincides with
// SuccessfulPayment.telegram_payment_charge_id for successful incoming
// payments from users.
Expand All @@ -66,7 +41,33 @@ type StarTransaction struct {
Receiver TransactionPartner `json:"receiver"`
}

// Date returns the local datetime.
func (c *StarTransaction) Date() time.Time {
type TransactionPartner struct {
// Type of the state
Type TransactionType `json:"type"`
User *User `json:"user,omitempty"`
Payload string `json:"invoice_payload"`

// (Optional) State of the transaction if the transaction is outgoing$$
Withdrawal RevenueWithdrawal `json:"withdrawal_state,omitempty"`
}

type RevenueWithdrawal struct {
// Type of the state
Type RevenueState `json:"type"`

// Date the withdrawal was completed in Unix time
Unixtime int `json:"date,omitempty"`

// An HTTPS URL that can be used to see transaction details
URL string `json:"url,omitempty"`
}

// Time returns the date of the transaction.
func (c *StarTransaction) Time() time.Time {
return time.Unix(c.Unixtime, 0)
}

// Time returns the date of the withdrawal.
func (s *RevenueWithdrawal) Time() time.Time {
return time.Unix(int64(s.Unixtime), 0)
}

0 comments on commit 8b69e47

Please sign in to comment.