1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2026-03-31 15:12:47 +00:00

Fix #190: Support for Google Places values in venue-related methods and types

This commit is contained in:
madhead
2020-11-05 19:13:43 +03:00
parent 654d84b1b4
commit 824fa9ba09
10 changed files with 204 additions and 35 deletions

View File

@@ -7,7 +7,7 @@ import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
val Venue.foursquare: Foursquare?
get() = foursquareId ?.let {
get() = foursquareId?.let {
Foursquare(it, foursquareType)
}
@@ -16,7 +16,7 @@ fun Venue(
title: String,
address: String,
foursquare: Foursquare
) = Venue(location, title, address, foursquare.id, foursquare.type)
) = Venue(location, title, address, foursquareId = foursquare.id, foursquareType = foursquare.type)
@Serializable
data class Foursquare(

View File

@@ -0,0 +1,27 @@
package dev.inmo.tgbotapi.extensions.utils.extensions.venue
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.location.StaticLocation
import dev.inmo.tgbotapi.types.venue.Venue
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
val Venue.googlePlace: GooglePlace?
get() = googlePlaceId?.let {
GooglePlace(it, googlePlaceType)
}
fun Venue(
location: StaticLocation,
title: String,
address: String,
googlePlace: GooglePlace
) = Venue(location, title, address, googlePlaceId = googlePlace.id, googlePlaceType = googlePlace.type)
@Serializable
data class GooglePlace(
@SerialName(googlePlaceIdField)
val id: GooglePlaceId,
@SerialName(googlePlaceTypeField)
val type: GooglePlaceType? = null
)