Skip to content

Commit

Permalink
Telegram Bot API July 7, 2024 updates (v7.7)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnspade committed Jul 11, 2024
1 parent d3eac5f commit 0c8acd6
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# F[Tg] - Telegramium

[![Telegram](https://img.shields.io/badge/Telegram%20Bot%20API-7.6%20(July%201%2C%202024)-blue)](https://core.telegram.org/bots/api#recent-changes)
[![Telegram](https://img.shields.io/badge/Telegram%20Bot%20API-7.7%20(July%207%2C%202024)-blue)](https://core.telegram.org/bots/api#recent-changes)
[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.apimorphism/telegramium-core_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.apimorphism/telegramium-core_2.13)

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
enablePlugins(GitPlugin)

ThisBuild / version := Version.mkVersion(
"9.76.0",
"9.77.0",
git.gitCurrentBranch.value,
git.gitDescribedVersion.value,
git.gitUncommittedChanges.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ sealed trait MaybeInaccessibleMessage {}
* Optional. Message is an invoice for a payment, information about the invoice.
* @param successfulPayment
* Optional. Message is a service message about a successful payment, information about the payment.
* @param refundedPayment
* Optional. Message is a service message about a refunded payment, information about the payment.
* @param usersShared
* Optional. Service message: users were shared with the bot
* @param chatShared
Expand Down Expand Up @@ -264,6 +266,7 @@ final case class Message(
pinnedMessage: Option[MaybeInaccessibleMessage] = Option.empty,
invoice: Option[Invoice] = Option.empty,
successfulPayment: Option[SuccessfulPayment] = Option.empty,
refundedPayment: Option[RefundedPayment] = Option.empty,
usersShared: Option[UsersShared] = Option.empty,
chatShared: Option[ChatShared] = Option.empty,
connectedWebsite: Option[String] = Option.empty,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package telegramium.bots

/** This object contains basic information about a refunded payment.
*
* @param currency
* Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars. Currently, always “XTR”
* @param totalAmount
* Total refunded price in the smallest units of the currency (integer, not float/double). For example, for a price
* of US$
* 1.45, total_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal
* point for each currency (2 for the majority of currencies).
* @param invoicePayload
* Bot-specified invoice payload
* @param telegramPaymentChargeId
* Telegram payment identifier
* @param providerPaymentChargeId
* Optional. Provider payment identifier
*/
final case class RefundedPayment(
currency: String,
totalAmount: Int,
invoicePayload: String,
telegramPaymentChargeId: String,
providerPaymentChargeId: Option[String] = Option.empty
)
35 changes: 35 additions & 0 deletions telegramium-core/src/main/scala/telegramium/bots/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2473,6 +2473,7 @@ object CirceImplicits {
"pinned_message" -> x.pinnedMessage.asJson,
"invoice" -> x.invoice.asJson,
"successful_payment" -> x.successfulPayment.asJson,
"refunded_payment" -> x.refundedPayment.asJson,
"users_shared" -> x.usersShared.asJson,
"chat_shared" -> x.chatShared.asJson,
"connected_website" -> x.connectedWebsite.asJson,
Expand Down Expand Up @@ -2566,6 +2567,7 @@ object CirceImplicits {
_pinnedMessage <- h.get[Option[MaybeInaccessibleMessage]]("pinned_message")
_invoice <- h.get[Option[Invoice]]("invoice")
_successfulPayment <- h.get[Option[SuccessfulPayment]]("successful_payment")
_refundedPayment <- h.get[Option[RefundedPayment]]("refunded_payment")
_usersShared <- h.get[Option[UsersShared]]("users_shared")
_chatShared <- h.get[Option[ChatShared]]("chat_shared")
_connectedWebsite <- h.get[Option[String]]("connected_website")
Expand Down Expand Up @@ -2652,6 +2654,7 @@ object CirceImplicits {
pinnedMessage = _pinnedMessage,
invoice = _invoice,
successfulPayment = _successfulPayment,
refundedPayment = _refundedPayment,
usersShared = _usersShared,
chatShared = _chatShared,
connectedWebsite = _connectedWebsite,
Expand Down Expand Up @@ -6193,6 +6196,38 @@ object CirceImplicits {
}
}

implicit lazy val refundedpaymentEncoder: Encoder[RefundedPayment] =
(x: RefundedPayment) => {
Json.fromFields(
List(
"currency" -> x.currency.asJson,
"total_amount" -> x.totalAmount.asJson,
"invoice_payload" -> x.invoicePayload.asJson,
"telegram_payment_charge_id" -> x.telegramPaymentChargeId.asJson,
"provider_payment_charge_id" -> x.providerPaymentChargeId.asJson
).filter(!_._2.isNull)
)
}

implicit lazy val refundedpaymentDecoder: Decoder[RefundedPayment] =
Decoder.instance { h =>
for {
_currency <- h.get[String]("currency")
_totalAmount <- h.get[Int]("total_amount")
_invoicePayload <- h.get[String]("invoice_payload")
_telegramPaymentChargeId <- h.get[String]("telegram_payment_charge_id")
_providerPaymentChargeId <- h.get[Option[String]]("provider_payment_charge_id")
} yield {
RefundedPayment(
currency = _currency,
totalAmount = _totalAmount,
invoicePayload = _invoicePayload,
telegramPaymentChargeId = _telegramPaymentChargeId,
providerPaymentChargeId = _providerPaymentChargeId
)
}
}

implicit lazy val replyparametersEncoder: Encoder[ReplyParameters] =
(x: ReplyParameters) => {
Json.fromFields(
Expand Down

0 comments on commit 0c8acd6

Please sign in to comment.