diff --git a/bot.go b/bot.go index 3062705a..0a546b12 100644 --- a/bot.go +++ b/bot.go @@ -1252,6 +1252,28 @@ func (b *Bot) MyShortDescription(language string) (*BotInfo, error) { return b.botInfo(language, "getMyShortDescription") } +func (b *Bot) GetStarTransactions(offset, limit int) ([]StarTransaction, error) { + params := map[string]int{ + "offset": offset, + "limit": limit, + } + + data, err := b.Raw("getStarTransactions", params) + if err != nil { + return nil, err + } + + var resp struct { + Result struct { + Transactions []StarTransaction `json:"transactions"` + } + } + if err := json.Unmarshal(data, &resp); err != nil { + return nil, wrapError(err) + } + return resp.Result.Transactions, nil +} + func (b *Bot) botInfo(language, key string) (*BotInfo, error) { params := map[string]string{ "language_code": language, diff --git a/media.go b/media.go index bdce5557..f4d952c0 100644 --- a/media.go +++ b/media.go @@ -341,6 +341,10 @@ type Location struct { // Period in seconds for which the location will be updated // (see Live Locations, should be between 60 and 86400.) LivePeriod int `json:"live_period,omitempty"` + + // (Optional) Unique identifier of the business connection + // on behalf of which the message to be edited was sent + BusinessConnectionID string `json:"business_connection_id"` } // Venue object represents a venue location with name, address and diff --git a/stars.go b/stars.go new file mode 100644 index 00000000..fb196d00 --- /dev/null +++ b/stars.go @@ -0,0 +1,72 @@ +package telebot + +import "time" + +type TransactionType = string + +const ( + TransactionTypeFragment TransactionType = "fragment" + TransactionTypeUser TransactionType = "user" + TransactionTypeOther TransactionType = "other" + TransactionPartnerTelegramAds TransactionType = "telegram_ads" +) + +type RevenueState = string + +const ( + RevenueStatePending RevenueState = "pending" + RevenueStateSucceeded RevenueState = "succeeded" + 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 + // original transaction for refund transactions. Coincides with + // SuccessfulPayment.telegram_payment_charge_id for successful incoming + // payments from users. + ID string `json:"id"` + + // Number of Telegram Stars transferred by the transaction + Amount int `json:"amount"` + + // Date the transaction was created in Unix time + Unixtime int64 `json:"date"` + + // (Optional) Source of an incoming transaction (e.g., a user purchasing goods + // or services, Fragment refunding a failed withdrawal). Only for incoming transactions + Source TransactionPartner `json:"source"` + + // (Optional) Receiver of an outgoing transaction (e.g., a user for a purchase + // refund, Fragment for a withdrawal). Only for outgoing transactions + Receiver TransactionPartner `json:"receiver"` +} + +// Date returns the local datetime. +func (c *StarTransaction) Date() time.Time { + return time.Unix(c.Unixtime, 0) +}