-
-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BOT API v7.11 #401
Merged
BOT API v7.11 #401
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
61cd461
Add CopyTextButton to InlineKeyboardButton
anfanik 1256312
Add allow_paid_broadcast parameter to send requests
anfanik c49e109
Add TransactionPartnerTelegramApi transaction partner, rewrite Transa…
anfanik 00096b6
Merge branch 'master' into v7.11
pengrad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, Kotlin migration, such a beauty 😁