-
-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #401 from pengrad/v7.11
BOT API v7.11
- Loading branch information
Showing
9 changed files
with
95 additions
and
34 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
library/src/main/java/com/pengrad/telegrambot/model/request/CopyTextButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.pengrad.telegrambot.model.request | ||
|
||
data class CopyTextButton( | ||
val text: String | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
.../main/java/com/pengrad/telegrambot/model/stars/partner/TransactionPartnerTelegramApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.pengrad.telegrambot.model.stars.partner; | ||
|
||
import java.util.Objects; | ||
|
||
public class TransactionPartnerTelegramApi extends TransactionPartner { | ||
|
||
public final static String TYPE = "telegram_api"; | ||
|
||
private Integer request_count; | ||
|
||
public TransactionPartnerTelegramApi() { | ||
super(TYPE); | ||
} | ||
|
||
public Integer requestCount() { | ||
return request_count; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof TransactionPartnerTelegramApi)) return false; | ||
if (!super.equals(o)) return false; | ||
TransactionPartnerTelegramApi that = (TransactionPartnerTelegramApi) o; | ||
return Objects.equals(request_count, that.request_count); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(super.hashCode(), request_count); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "TransactionPartnerTelegramApi{" + | ||
"request_count=" + request_count + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
...ary/src/main/java/com/pengrad/telegrambot/utility/gson/TransactionPartnerTypeAdapter.java
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
library/src/main/java/com/pengrad/telegrambot/utility/gson/TransactionPartnerTypeAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.pengrad.telegrambot.utility.gson | ||
|
||
import com.google.gson.* | ||
import com.pengrad.telegrambot.model.stars.partner.* | ||
import java.lang.reflect.Type | ||
|
||
object TransactionPartnerTypeAdapter : JsonDeserializer<TransactionPartner> { | ||
|
||
private val typeMapping = mapOf( | ||
TransactionPartnerUser.TYPE to TransactionPartnerUser::class, | ||
TransactionPartnerFragment.TYPE to TransactionPartnerFragment::class, | ||
TransactionPartnerTelegramAds.TYPE to TransactionPartnerTelegramAds::class, | ||
TransactionPartnerTelegramApi.TYPE to TransactionPartnerTelegramApi::class, | ||
TransactionPartnerOther.TYPE to TransactionPartnerOther::class | ||
) | ||
|
||
@Throws(JsonParseException::class) | ||
override fun deserialize( | ||
element: JsonElement, | ||
type: Type, | ||
context: JsonDeserializationContext | ||
): TransactionPartner { | ||
val obj = element.asJsonObject | ||
val discriminator = obj.getAsJsonPrimitive("type")?.asString ?: "unknown" | ||
|
||
return typeMapping[discriminator]?.let { | ||
context.deserialize(obj, it.java) | ||
} ?: TransactionPartner(discriminator) | ||
} | ||
|
||
} |