From 9d506b11a384621708f6bb7cfc56dbe50bfbe3d9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 18 Apr 2024 14:43:14 +0600 Subject: [PATCH] add support of birthdate --- .../dev/inmo/tgbotapi/types/Birthdate.kt | 19 +++++++++++++++++++ .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 5 +++++ .../dev/inmo/tgbotapi/types/chat/Extended.kt | 2 ++ .../tgbotapi/types/chat/ExtendedAbstracts.kt | 1 + 4 files changed, 27 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Birthdate.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Birthdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Birthdate.kt new file mode 100644 index 0000000000..4a0ddd7e45 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Birthdate.kt @@ -0,0 +1,19 @@ +package dev.inmo.tgbotapi.types + +import korlibs.time.Date +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class Birthdate( + @SerialName(dayField) + val day: Int, + @SerialName(monthField) + val month: Int, + @SerialName(yearField) + val year: Int +) { + val date: Date by lazy { + Date(year, month, day) + } +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 60fd4e8c02..8cd24f3675 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -151,6 +151,7 @@ const val profileAccentColorIdField = "profile_accent_color_id" const val backgroundCustomEmojiIdField = "background_custom_emoji_id" const val profileBackgroundCustomEmojiIdField = "profile_background_custom_emoji_id" const val personalChatField = "personal_chat" +const val birthdateField = "birthdate" const val hasVisibleHistoryField = "has_visible_history" const val unrestrictBoostsCountField = "unrestrict_boost_count" const val customEmojiStickerSetNameField = "custom_emoji_sticker_set_name" @@ -592,3 +593,7 @@ const val businessConnectionIdField = "business_connection_id" const val businessIntroField = "business_intro" const val businessLocationField = "business_location" const val businessOpeningHoursField = "business_opening_hours" + +const val dayField = "day" +const val monthField = "month" +const val yearField = "year" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt index b1e4ce9666..ef27cd7486 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt @@ -133,6 +133,8 @@ data class ExtendedPrivateChatImpl( override val businessLocation: BusinessLocation? = null, @SerialName(businessOpeningHoursField) override val businessOpeningHours: BusinessOpeningHours? = null, + @SerialName(birthdateField) + override val birthdate: Birthdate? = null, @SerialName(personalChatField) @Serializable(PreviewChatSerializer::class) override val personalChat: PreviewChannelChat? = null diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt index f6b6bee834..bc1fe8a3ee 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt @@ -46,6 +46,7 @@ sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChatWithUsername, Ex val businessLocation: BusinessLocation? val businessOpeningHours: BusinessOpeningHours? + val birthdate: Birthdate? val personalChat: PreviewChannelChat? val allowCreateUserIdLink: Boolean