1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 08:37:12 +00:00

add support of nanostar_amount

This commit is contained in:
InsanusMokrassar 2024-12-06 12:32:38 +06:00
parent 4cdae11adc
commit 0b6d9e47b9
2 changed files with 14 additions and 0 deletions

View File

@ -467,6 +467,7 @@ const val actionField = "action"
const val positionField = "position"
const val labelField = "label"
const val amountField = "amount"
const val nanostarAmountField = "nanostar_amount"
const val pricesField = "prices"
const val payloadField = "payload"
const val vcardField = "vcard"

View File

@ -19,6 +19,7 @@ import kotlinx.serialization.json.JsonElement
sealed interface StarTransaction {
val id: StarTransactionId
val amount: Int
val nanostarAmount: Int
val date: TelegramDate
val partner: TransactionPartner
val source: TransactionPartner?
@ -30,6 +31,8 @@ sealed interface StarTransaction {
override val id: StarTransactionId,
@SerialName(amountField)
override val amount: Int,
@SerialName(nanostarAmountField)
override val nanostarAmount: Int,
@SerialName(dateField)
override val date: TelegramDate,
@SerialName(sourceField)
@ -48,6 +51,8 @@ sealed interface StarTransaction {
override val id: StarTransactionId,
@SerialName(amountField)
override val amount: Int,
@SerialName(nanostarAmountField)
override val nanostarAmount: Int,
@SerialName(dateField)
override val date: TelegramDate,
@SerialName(receiverField)
@ -65,6 +70,8 @@ sealed interface StarTransaction {
@SerialName(idField)
override val id: StarTransactionId,
override val amount: Int,
@SerialName(nanostarAmountField)
override val nanostarAmount: Int,
override val date: TelegramDate,
override val source: TransactionPartner?,
override val receiver: TransactionPartner?,
@ -79,6 +86,8 @@ sealed interface StarTransaction {
private data class Surrogate(
val id: StarTransactionId,
val amount: Int,
@SerialName(nanostarAmountField)
val nanostarAmount: Int,
val date: TelegramDate,
val source: TransactionPartner? = null,
val receiver: TransactionPartner? = null,
@ -94,6 +103,7 @@ sealed interface StarTransaction {
Unknown(
id = data.id,
amount = data.amount,
nanostarAmount = data.nanostarAmount,
date = data.date,
source = data.source,
receiver = data.receiver,
@ -104,12 +114,14 @@ sealed interface StarTransaction {
data.source != null -> Incoming(
id = data.id,
amount = data.amount,
nanostarAmount = data.nanostarAmount,
date = data.date,
partner = data.source
)
data.receiver != null -> Outgoing(
id = data.id,
amount = data.amount,
nanostarAmount = data.nanostarAmount,
date = data.date,
partner = data.receiver
)
@ -126,6 +138,7 @@ sealed interface StarTransaction {
val surrogate = Surrogate(
id = value.id,
amount = value.amount,
nanostarAmount = value.nanostarAmount,
date = value.date,
source = value.source,
receiver = value.receiver,